/* Dokumentum rendszer – link státusz, integritás, előnézet modál */

.doc-link-status {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.doc-link-status--pending { background: #e0e7ff; color: #3730a3; }
.doc-link-status--opened { background: #fef3c7; color: #92400e; }
.doc-link-status--signed { background: #dcfce7; color: #166534; }
.doc-link-status--expired { background: #fee2e2; color: #b91c1c; }

.doc-integrity {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin: 0.75rem 0;
    line-height: 1.4;
}

.doc-integrity--ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.doc-integrity--warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.doc-integrity code { font-size: 0.78rem; }

.doc-versions {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.45rem;
}

.doc-versions li {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    font-size: 0.85rem;
    background: #f8fafc;
}

.doc-versions__action { font-weight: 600; color: #0f172a; }
.doc-versions__meta { color: #64748b; font-size: 0.8rem; margin-top: 0.1rem; }

.doc-versions-panel {
    margin: 0.75rem 0;
}
.doc-versions-panel summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
    color: #475569;
}

/* PDF előnézet modál */
.doc-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.doc-preview-modal[hidden] { display: none; }

.doc-preview-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}

.doc-preview-modal__sheet {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(960px, 100%);
    max-height: 100vh;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.doc-preview-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.doc-preview-modal__head h3 { margin: 0; font-size: 1.05rem; }

.doc-preview-modal__close {
    border: none;
    background: transparent;
    cursor: pointer;
    color: #64748b;
}

.doc-preview-modal__body {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow-y: auto;
    background: #f1f5f9;
}

.doc-preview-modal__frame {
    width: 100%;
    height: min(70vh, 720px);
    border: none;
    display: block;
}

.doc-preview-modal__frame[hidden],
.doc-preview-modal__pdfjs[hidden] {
    display: none !important;
}

.doc-preview-modal__loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    color: #64748b;
    pointer-events: none;
}

.doc-preview-modal__loading[hidden] {
    display: none;
}

.doc-preview-modal__foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #e2e8f0;
}

/* PDF.js előnézet (mobil / PWA) – eredeti arány, nagyítható */
.doc-preview-modal--pdfjs .doc-preview-modal__sheet {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
}

.doc-preview-modal--pdfjs .doc-preview-modal__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.doc-preview-modal__viewer-host {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

/* Közös PDF.js megjelenítő – modál és tokenes portál */
.doc-pdf-viewer {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
}

.doc-pdf-viewer__zoom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.doc-pdf-viewer__zoom-btn {
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #0f172a;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.doc-pdf-viewer__zoom-btn--text {
    min-width: auto;
    font-size: 0.8rem;
    font-weight: 600;
}

.doc-pdf-viewer__zoom-label {
    min-width: 4.5rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.doc-pdf-viewer__pages {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.75rem 0.5rem 1rem;
    background: #525659;
}

.doc-pdf-viewer__page {
    width: -moz-fit-content;
    width: fit-content;
    min-width: 100%;
    display: flex;
    justify-content: center;
    margin: 0 auto 0.75rem;
}

.doc-pdf-viewer__page:last-child {
    margin-bottom: 0;
}

.doc-pdf-viewer__page-canvas {
    display: block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.doc-pdf-viewer__loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    color: #64748b;
    pointer-events: none;
}

.doc-pdf-viewer__loading[hidden] {
    display: none;
}

.doc-pdf-viewer__error {
    padding: 1.5rem;
    text-align: center;
    color: #b91c1c;
}

.doc-preview-modal__pdfjs {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.doc-preview-modal__zoom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.doc-preview-modal__zoom-btn {
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #0f172a;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.doc-preview-modal__zoom-btn--text {
    min-width: auto;
    font-size: 0.8rem;
    font-weight: 600;
}

.doc-preview-modal__zoom-label {
    min-width: 4.5rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.doc-preview-modal__pages {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.75rem 0.5rem 1rem;
    background: #525659;
}

.doc-preview-modal__page {
    width: -moz-fit-content;
    width: fit-content;
    min-width: 100%;
    display: flex;
    justify-content: center;
    margin: 0 0 0.75rem;
}

.doc-preview-modal__page:last-child {
    margin-bottom: 0;
}

.doc-preview-modal__page-canvas {
    display: block;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    background: #fff;
}

.doc-preview-modal__error {
    margin: 1rem;
    padding: 1rem;
    background: #fff;
    border-radius: 8px;
    color: #b91c1c;
    text-align: center;
    font-size: 0.9rem;
}

body.doc-preview-open { overflow: hidden; }

/* Tokenes karbantartási jegyzőkönyv – beágyazott PDF nézet */
/* Tokenes dokumentum portál – közös váz (karbantartás, munkalap, TIG, ajánlat, napló) */
body.document-portal,
body.maintenance-doc-portal {
    margin: 0;
    min-height: 100vh;
    background: #f1f5f9;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: #0f172a;
}

.document-portal__shell,
.maintenance-doc-portal__shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1100px;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
}

.document-portal__head,
.maintenance-doc-portal__head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.document-portal__head h1,
.maintenance-doc-portal__head h1 {
    margin: 0 0 0.35rem;
    font-size: 1.15rem;
    line-height: 1.35;
    color: #b91c1c;
}

.document-portal__meta,
.maintenance-doc-portal__meta {
    margin: 0.15rem 0;
    font-size: 0.9rem;
    color: #475569;
}

.document-portal__meta--signed,
.maintenance-doc-portal__meta--signed {
    color: #047857;
}

.document-portal__actions,
.maintenance-doc-portal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.document-portal__btn,
.maintenance-doc-portal__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.document-portal__btn .material-symbols-outlined,
.maintenance-doc-portal__btn .material-symbols-outlined {
    font-size: 1.15rem;
}

.document-portal__viewer,
.maintenance-doc-portal__viewer {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #e2e8f0;
    position: relative;
}

.document-portal__pdf-root {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.maintenance-doc-portal__frame {
    flex: 1;
    width: 100%;
    min-height: calc(100vh - 11rem);
    border: none;
    display: block;
    background: #525659;
}

@media (max-width: 640px) {
    .document-portal__shell,
    .maintenance-doc-portal__shell {
        box-shadow: none;
    }
    .document-portal__head,
    .maintenance-doc-portal__head {
        padding: 0.85rem 1rem;
    }
    .document-portal__head h1,
    .maintenance-doc-portal__head h1 {
        font-size: 1rem;
    }
    .document-portal__actions,
    .maintenance-doc-portal__actions {
        width: 100%;
    }
    .document-portal__actions .btn,
    .maintenance-doc-portal__actions .btn {
        flex: 1 1 calc(50% - 0.25rem);
        justify-content: center;
    }
    .document-portal__pdf-root {
        min-height: calc(100vh - 14rem);
    }
}

@media (max-width: 640px) {
    .doc-preview-modal__sheet {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    .doc-preview-modal__frame {
        height: calc(100vh - 8rem);
    }
    .doc-preview-modal__foot .btn {
        flex: 1;
        justify-content: center;
    }
}

/* Dokumentum export oldal */
.doc-export-page .page-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    min-width: 0;
}
.doc-export-page .page-subtitle { margin: 0; }
@media (max-width: 640px) {
    .doc-export-page .page-header {
        flex-direction: column;
        align-items: stretch;
    }
}
.doc-export-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
}
.doc-export-checks {
    display: grid;
    gap: 0.4rem;
    margin: 0.75rem 0 1rem;
}
.doc-export-checks label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.92rem;
}
.doc-export-maintenance-types {
    margin: -0.35rem 0 0.75rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}
.doc-export-subtitle {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}
.doc-export-checks--nested {
    margin: 0;
}
