body { font-family: 'Inter', sans-serif; background-color: #f8fafc; color: #1e293b; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Animationen */
.fade-in { animation: fadeIn 0.3s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* DIN A4 Papier Simulation */
.din-a4 {
    width: 210mm;
    min-height: 297mm;
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    position: relative;
    margin: 0 auto;
    padding: 0;
    font-family: 'Arial', sans-serif;
    font-size: 11pt;
    color: black;
    overflow: hidden;
}

.din-header {
    position: absolute; top: 15mm; right: 20mm;
    text-align: right; 
}
.din-logo {
    max-height: 25mm; max-width: 80mm;
    margin-bottom: 2mm; display: block; margin-left: auto;
}
.din-header-text { font-size: 8pt; color: #64748b; }

.din-back-addr {
    position: absolute; top: 45mm; left: 25mm;
    width: 85mm; height: 5mm;
    font-size: 7pt; color: #64748b; text-decoration: underline;
}

.din-recipient {
    position: absolute; top: 50mm; left: 25mm;
    width: 85mm; height: 40mm;
    font-size: 10pt; line-height: 1.3;
}

.din-meta-block {
    position: absolute; 
    top: 50mm; 
    right: 20mm;
    width: 70mm;
    font-size: 9pt; 
    text-align: left;
}
.din-meta-table {
    width: 100%;
    border-collapse: collapse;
}
.din-meta-table td {
    padding-bottom: 1.5mm;
    vertical-align: top;
}
.din-meta-label {
    font-weight: bold;
    color: #334155;
    width: 35%;
}
.din-meta-value {
    color: #0f172a;
    text-align: right;
}

.din-content {
    position: absolute; top: 105mm; left: 25mm; right: 20mm; bottom: 25mm;
}

.din-subject { font-weight: bold; margin-bottom: 8mm; font-size: 12pt; }
.din-text { line-height: 1.4; text-align: justify; }

/* Falzmarken */
.fold-mark { position: absolute; left: 6mm; width: 3mm; height: 1px; background: #cbd5e1; }
.fold-1 { top: 105mm; }
.fold-2 { top: 148.5mm; width: 5mm; background: #64748b; }
.fold-3 { top: 210mm; }

@media print {
    body { background: white; margin: 0; }
    .din-a4 { box-shadow: none; margin: 0; width: 100%; height: 100%; position: absolute; top: 0; left: 0; }
    .no-print { display: none !important; }
}

.glass-panel { background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,0.5); }
.nav-active { background-color: #eff6ff; color: #4f46e5; border-right: 3px solid #4f46e5; }

/* Kacheln */
.file-card {
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
}
.file-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: #cbd5e1;
}

/* NEU: Tabellen Ansicht & Badges */
.doc-table-header {
    background-color: #f1f5f9;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
}
.doc-table-header:hover { background-color: #e2e8f0; color: #4f46e5; }
.doc-row { border-bottom: 1px solid #f1f5f9; transition: background-color 0.1s; }
.doc-row:hover { background-color: #f8fafc; }

.badge {
    display: inline-flex; items-center: center; 
    padding: 0.125rem 0.5rem; 
    border-radius: 9999px; 
    font-size: 0.65rem; 
    font-weight: 600; 
    text-transform: uppercase;
}
.badge-red { background-color: #fee2e2; color: #991b1b; }
.badge-blue { background-color: #dbeafe; color: #1e40af; }
.badge-green { background-color: #dcfce7; color: #166534; }
.badge-gray { background-color: #f1f5f9; color: #64748b; }

/* LETTERHEAD / EDITOR FIXES */
#inp-content{
  white-space: pre-wrap;
  word-break: break-word;
}
.din-text{
  white-space: pre-wrap;
  word-break: break-word;
}
.din-text p{ margin: 0 0 3mm 0; }
.din-text ul, .din-text ol{
  margin: 2mm 0 3mm 6mm;
  padding: 0;
  list-style-position: inside;
}
.din-text li{ margin: 1mm 0; }
.din-text .align-left{ text-align:left; }
.din-text .align-right{ text-align:right; }
.din-text .align-center{ text-align:center; }
.din-text .align-justify{ text-align:justify; }

/* Allow configurable positioning via CSS variables (defaults keep existing layout) */
.din-header{ top: var(--pos-header-top, 15mm); right: var(--pos-header-right, 20mm); }
.din-back-addr{ top: var(--pos-backaddr-top, 45mm); left: var(--pos-backaddr-left, 25mm); }
.din-recipient{ top: var(--pos-recipient-top, 50mm); left: var(--pos-recipient-left, 25mm); }
.din-meta-block{ top: var(--pos-meta-top, 50mm); right: var(--pos-meta-right, 20mm); }
.din-a4.has-logo .din-meta-block{ top: var(--pos-meta-top-haslogo, 58mm); }
.din-content{ top: var(--pos-content-top, 105mm); left: var(--pos-content-left, 25mm); right: var(--pos-content-right, 20mm); bottom: var(--pos-content-bottom, 25mm); }

/* Letterhead background layer */
.letterhead-bg{
  position:absolute;
  inset:0;
  z-index:0;
  pointer-events:none;
  background-repeat:no-repeat;
  background-position:center;
  background-size:cover;
}
.din-a4 > .letterhead-bg + *{ position:relative; z-index:1; }

/* Toggle visibility of blocks */
.din-a4.hide-header .din-header{ display:none; }
.din-a4.hide-backaddr .din-back-addr{ display:none; }
.din-a4.hide-recipient .din-recipient{ display:none; }
.din-a4.hide-meta .din-meta-block{ display:none; }
.din-a4.hide-contenthead .din-subject{ display:none; }

/* Edit mode helpers */
.din-a4.layout-edit .layout-draggable{
  outline: 2px dashed rgba(99,102,241,0.6);
  outline-offset: 2px;
  cursor: move;
  user-select:none;
}
.din-a4.layout-edit .layout-draggable:hover{
  outline-color: rgba(236,72,153,0.7);
}
