/* Mitgelieferte, metrisch Arial-kompatible Schrift (SIL OFL) — Windows-Dev und
   Linux-Prod rendern damit identisch (#415 Phase 2). */
@font-face { font-family: "Liberation Sans"; src: url("../fonts/LiberationSans-Regular.ttf"); font-weight: normal; font-style: normal; }
@font-face { font-family: "Liberation Sans"; src: url("../fonts/LiberationSans-Bold.ttf"); font-weight: bold; font-style: normal; }
@font-face { font-family: "Liberation Sans"; src: url("../fonts/LiberationSans-Italic.ttf"); font-weight: normal; font-style: italic; }
@font-face { font-family: "Liberation Sans"; src: url("../fonts/LiberationSans-BoldItalic.ttf"); font-weight: bold; font-style: italic; }

/* ===== A4-Blattstapel (A4-WYSIWYG, #415) ===== */
.sd-stack {
    display: flex;
    flex-direction: column;
    gap: 28px;               /* Luecke zwischen den Blaettern — ersetzt die rote Trennlinie */
    align-items: center;
}

.sd-sheet {
    width: 794px;            /* A4 @ 96dpi */
    height: 1123px;          /* FESTE Hoehe: ein echtes Blatt */
    background: #fff;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
    padding: 60px 75px 0;    /* DIN-5008-Raender wie bisher; unten reserviert .sd-footer */
    font-family: "Liberation Sans", Arial, sans-serif;
    font-size: 11pt;
    color: #222;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;        /* Sicherheitsnetz: nichts ragt uebers Blatt hinaus */
    display: flex;
    flex-direction: column;
}

.sd-sheet-content { flex: 1 1 auto; min-height: 0; }

/* Footer: fixer Bestandteil jedes Blattes (kein absolute mehr noetig — im Flex unten) */
.sd-footer {
    flex: 0 0 auto;
    border-top: 1px solid #999;
    padding: 8px 0 40px;
    display: grid;
    grid-template-columns: 1.2fr 1fr 1.2fr 1fr;
    gap: 14px;
    font-size: 6.5pt;
    color: #555;
    line-height: 1.4;
}
.sd-footer .col-head { font-weight: bold; color: #333; display: block; margin-bottom: 2px; }

.sd-page-num {
    position: absolute;
    right: 75px;
    bottom: 14px;
    font-size: 7.5pt;
    color: #888;
}

/* Kompakter Kopf fuer Folgeseiten */
.sd-header-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #999;
    padding-bottom: 4px;
    margin-bottom: 18px;
    font-size: 8pt;
    color: #666;
}
.sd-header-compact img { max-height: 36px; }

.sd-warning {
    max-width: 794px;
    margin: 0 auto 10px;
    padding: 8px 12px;
    background: #fef3cd;
    border: 1px solid #f0ad4e;
    border-radius: 6px;
    font-size: .85rem;
    color: #664d03;
}

/* Print-Mode-Freitexte (a4-print-text) sollen Zeilenumbrueche aus dem Editor beibehalten */
.a4-print-text { white-space: pre-wrap; }

/* ===== Inline-Edit-Aktionen IM Dokument (nur Edit-Mode, eigene Bloecke) =====
   Dezente, papierfreundliche Pills direkt unter Positionstabelle bzw. Tagesaufstellung —
   ersetzen die frueheren Bootstrap-Buttons unter dem Blattstapel. */
.sd-inline-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin: 4px 0 12px;
}

.sd-inline-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px dashed #c3c9d2;
    background: transparent;
    color: #5b6472;
    border-radius: 999px;
    padding: 4px 13px;
    font: inherit;
    font-size: 9.5pt;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}

.sd-inline-action i { font-size: 10pt; }

.sd-inline-action:hover {
    border-style: solid;
    border-color: var(--drk-accent, #dc2626);
    color: var(--drk-accent, #dc2626);
    background: rgba(220, 38, 38, .04);
}

/* Katalog-Auswahl, die unter der Inline-Aktion aufklappt (mitgemessener Block-Inhalt) */
.sd-inline-panel {
    max-width: 420px;
    border: 1px solid #e2e5ea;
    border-radius: 10px;
    background: #fbfbfc;
    padding: 8px 12px;
    margin: 2px 0 12px;
    font-size: 10pt;
}

.sd-inline-panel-title {
    font-size: 8.5pt;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #8a93a1;
    margin-bottom: 4px;
}

.sd-inline-panel-list { max-height: 200px; overflow-y: auto; }

.sd-inline-panel-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 5px 2px;
    border-bottom: 1px solid #eef0f3;
    cursor: pointer;
}

.sd-inline-panel-row:last-child { border-bottom: none; }
.sd-inline-panel-row:hover { color: var(--drk-accent, #dc2626); }

/* Mobile: Skalierung uebernimmt sales-document.js (applyScale) — CSS-transform mit
   calc-Laengendivision ist ungueltig. Hier nur der Scroll-Schutz. */
.sd-scale-wrap { width: 100%; overflow-x: hidden; }

/* ===== Uebernommene a4-*-Regeln aus InvoiceEditor.razor (unveraendert) ===== */

.a4-logo-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
    padding-bottom: 5px;
    border-bottom: 1px solid #999;  /* Linie durch ganze Breite */
}

.a4-sender-small {
    font-size: 7pt;
    color: #666;
    /* border-bottom ist auf .a4-logo-row -- geht durch die ganze Breite */
}

.a4-logo-box {
    width: 300px;
    height: 140px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: 4px;
}

.a4-top-grid {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 30px;
    align-items: start;
    margin-bottom: 40px;
}

.a4-recipient {
    line-height: 1.5;
    min-height: 140px;
}

.a4-doc-meta {
    text-align: left;
    font-size: 9.5pt;
}

    .a4-doc-meta h1 {
        font-size: 14pt;
        margin: 0 0 10px;
        color: #dc2626;
    }

    .a4-doc-meta .meta-row {
        display: grid;
        grid-template-columns: 130px 1fr;
        padding: 1px 0;
    }

    .a4-doc-meta .meta-row .k {
        color: #666;
    }

.a4-group-divider {
    border-top: 1px solid #ddd;
    margin: 8px 0;
}

.a4-subject {
    font-weight: bold;
    margin-bottom: 14px;
}

.a4-event-info {
    margin: 18px 0;
    display: grid;
    grid-template-columns: 210px 1fr;
    row-gap: 6px;
    column-gap: 16px;
    font-size: 10.5pt;
}

    .a4-event-info .k {
        color: #333;
    }

.a4-positions-table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 10pt;
}

    .a4-positions-table th {
        text-align: left;
        border-bottom: 2px solid #dc2626;
        padding: 6px 4px;
        font-size: 9pt;
    }

    .a4-positions-table td {
        padding: 5px 4px;
        border-bottom: 1px solid #eee;
    }

    .a4-positions-table .total-row {
        font-weight: bold;
    }

.a4-tax-note {
    margin: 16px 0 18px;
    padding: 10px 14px;
    background: #fafafa;
    border-left: 3px solid #dc2626;
    font-size: 10.5pt;
    line-height: 1.5;
}

.a4-signature-block {
    margin-top: 40px;
    display: flex;
    gap: 30px;
    align-items: flex-end;
}

.a4-sig-img {
    max-width: 200px;
    max-height: 70px;
}

/* Inline-Edit-Inputs sehen wie Papier aus */
.a4-input,
.a4-textarea {
    border: 1px dashed transparent;
    background: transparent;
    width: 100%;
    font: inherit;
    color: inherit;
    padding: 2px 4px;
    margin: -2px -4px;
    border-radius: 2px;
    box-sizing: border-box;
    resize: vertical;
}

    .a4-input:hover,
    .a4-textarea:hover {
        border-color: #dc2626;
        background: rgba(220,38,38,.03);
    }

    .a4-input:focus,
    .a4-textarea:focus {
        border-color: #dc2626;
        background: white;
        outline: none;
    }

/* Disabled / Readonly via fieldset */
fieldset[disabled] .a4-input,
fieldset[disabled] .a4-textarea {
    cursor: default;
    color: #333;
}

fieldset[disabled] .a4-input:hover,
fieldset[disabled] .a4-textarea:hover {
    border-color: transparent;
    background: transparent;
}

.a4-subject-input {
    font-weight: bold;
    font-size: 11pt;
}

.a4-qty-input {
    width: 55px;
    text-align: right;
}

.a4-price-input {
    width: 80px;
    text-align: right;
}

.a4-pos-name-input {
    width: 100%;
}

.a4-action-btn {
    background: transparent;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 10pt;
}

    .a4-action-btn:hover {
        background: #fef2f2;
        border-color: #dc2626;
    }

/* ===== Druck (HtmlPdfService, #415 Phase 2): jedes .sd-sheet = eine A4-Seite ===== */
@page { size: A4; margin: 0; }
@media print {
    /* app.css blendet beim Drucken global alles aus (body * { visibility: hidden } fuer
       die Alt-Druckkoepfe einzelner Seiten). Die PDF-Druck-Route (PrintLayout rendert in
       .print-root) muss davon ausgenommen sein — sonst druckt Chromium leere A4-Seiten. */
    .print-root, .print-root * { visibility: visible !important; }
    .sd-stack { gap: 0 !important; transform: none !important; align-items: flex-start !important; }
    .sd-scale-wrap { height: auto !important; overflow: visible !important; }
    .sd-sheet {
        box-shadow: none !important;
        page-break-after: always;
        break-after: page;
    }
    .sd-sheet:last-child { page-break-after: auto; break-after: auto; }
    .sd-warning { display: none !important; }
}
