/* =========================================================
   HAINBUCH Manual Viewer – Screen & Print Layout
   Ziel: möglichst nah am PDF-Layout (A4, Logo, Kopf/Fuß)
   ========================================================= */

:root {
    --hb-red: #e2001a;
    --hb-bg: #f5f5f7;
    --hb-page-bg: #ffffff;
    --hb-border: #e5e7eb;
    --hb-text: #111827;
    --hb-muted: #6b7280;
    --hb-radius-page: 18px;
    --hb-shadow-page: 0 20px 45px rgba(15, 23, 42, 0.20);
    --hb-font-base: system-ui, -apple-system, BlinkMacSystemFont,
                    "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Grundlayout ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--hb-font-base);
    color: var(--hb-text);
    background: var(--hb-bg);
}

/* Container um alles – wie im PDF zentriert */
.hb-app-shell {
    max-width: 1400px;
    margin: 24px auto 32px;
    padding: 0 16px;
}

/* ---------- App Header (oben über allen Seiten) ---------- */

.hb-app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.hb-app-header-left {
    min-width: 0;
}

.hb-back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--hb-muted);
    text-decoration: none;
    margin-bottom: 4px;
}

.hb-back-link:hover {
    text-decoration: underline;
}

.hb-app-title {
    font-size: 22px;
    font-weight: 600;
    margin: 0;
    color: var(--hb-red);
}

.hb-app-subtitle {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--hb-muted);
}

.hb-app-header-right {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

/* Druck-Button */
.hb-print-btn {
    border: none;
    border-radius: 999px;
    padding: 8px 18px;
    font-size: 14px;
    cursor: pointer;
    background: var(--hb-red);
    color: #ffffff;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(220, 38, 38, 0.35);
    transition: transform 0.1s ease, box-shadow 0.1s ease,
                background-color 0.15s ease;
}

.hb-print-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 36px rgba(220, 38, 38, 0.40);
    background: #c80016;
}

.hb-print-btn:active {
    transform: translateY(0);
    box-shadow: 0 8px 24px rgba(220, 38, 38, 0.30);
}

/* ---------- Seitencontainer ---------- */

.hb-pages {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/*
   Jede Seite wird wie ein A4-Blatt dargestellt.
   Breite/Höhe in mm, damit Druck und PDF sauber sind.
*/

.hb-page {
    position: relative;
    width: 210mm;
    height: 297mm;
    margin: 0 auto;
    background: var(--hb-page-bg);
    border-radius: var(--hb-radius-page);
    box-shadow: var(--hb-shadow-page);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ---------- Seitenkopf (Logo, Titel, Seitenzahl) ---------- */

.hb-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 14mm 18mm 6mm 18mm;
    border-bottom: 1px solid var(--hb-border);
}

.hb-logo-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hb-logo {
    height: 16mm;
    width: auto;
    display: block;
}

/* Text rechts neben dem Logo */
.hb-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hb-header-manual-type {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--hb-muted);
}

.hb-header-product {
    font-size: 17px;
    font-weight: 600;
    color: var(--hb-text);
}

/* Seiteninfos rechts oben */
.hb-page-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.hb-page-count {
    font-size: 11px;
    color: var(--hb-muted);
}

/* ---------- Seiteninhalt ---------- */

.hb-page-body {
    flex: 1 1 auto;
    padding: 10mm 18mm 12mm 18mm;
    font-size: 11pt;
    line-height: 1.45;
    overflow: hidden; /* Inhalt sollte durch die Importlogik passen */
}

/* Grundformatierung für typischen Anleitungs-HTML-Inhalt */
.hb-page-body h1,
.hb-page-body h2,
.hb-page-body h3,
.hb-page-body h4 {
    margin: 0 0 8px;
    font-weight: 600;
    color: var(--hb-text);
}

.hb-page-body h1 {
    font-size: 18px;
    color: var(--hb-red);
}

.hb-page-body h2 {
    font-size: 15px;
}

.hb-page-body h3 {
    font-size: 13px;
}

.hb-page-body p {
    margin: 0 0 6px;
}

.hb-page-body ul,
.hb-page-body ol {
    margin: 0 0 6px 18px;
    padding-left: 0;
}

.hb-page-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 6px 0 10px;
    font-size: 10pt;
}

.hb-page-body table th,
.hb-page-body table td {
    border: 1px solid var(--hb-border);
    padding: 4px 6px;
    vertical-align: top;
}

.hb-page-body table th {
    background: #f3f4f6;
    font-weight: 600;
}

/* Bilder möglichst schön darstellen */
.hb-page-body img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 6px auto;
}

/* ---------- Seitenfuß ---------- */

.hb-page-footer {
    flex: 0 0 auto;
    padding: 6mm 18mm 10mm 18mm;
    border-top: 1px solid var(--hb-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 8.5pt;
    color: var(--hb-muted);
}

.hb-footer-left,
.hb-footer-right {
    white-space: nowrap;
}

/* ---------- Responsives Verhalten auf kleineren Screens ---------- */

@media (max-width: 900px) {
    .hb-page {
        transform: scale(0.75);
        transform-origin: top center;
    }

    .hb-app-shell {
        margin-top: 8px;
    }
}

@media (max-width: 640px) {
    .hb-page {
        transform: scale(0.6);
    }

    .hb-app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .hb-app-header-right {
        align-self: stretch;
        justify-content: flex-start;
    }
}

/* ---------- Druck-Layout ---------- */

@page {
    size: A4;
    margin: 0;
}

/*
   Beim Drucken:
   – Hintergrund hell
   – Schatten/Rundung entfernen
   – Jede .hb-page wird eine physische Seite
*/

@media print {
    html, body {
        background: #ffffff;
    }

    .hb-app-shell {
        margin: 0;
        padding: 0;
        max-width: none;
    }

    .hb-app-header {
        /* Kopfbereich der Web-App beim Drucken ausblenden */
        display: none !important;
    }

    .hb-pages {
        gap: 0;
    }

    .hb-page {
        box-shadow: none;
        border-radius: 0;
        margin: 0;
        width: 210mm;
        height: 297mm;
        page-break-after: always;
        page-break-inside: avoid;
    }

    .hb-page:last-child {
        page-break-after: auto;
    }
}
