/* =============================================================================
 * BEPO – Berliner Prüfungs-Optimierer
 * public/assets/css/parts/summary.css – Post-Exam Summary View
 * @media screen (nicht print)
 * ============================================================================= */

/* ---------------------------------------------------------------------------
 * 1. Page-Level Overrides (Summary-Seite scrollbar machen)
 *    core.css setzt html,body { height:100%; overflow:hidden } – wir
 *    überschreiben das nur für die Summary-Ansicht.
 * --------------------------------------------------------------------------- */
body.summary-page,
html:has(body.summary-page) {
    height: auto !important;
    min-height: 100vh;
    overflow-y: auto !important;
    overflow-x: hidden;
}

/* ---------------------------------------------------------------------------
 * 2. Summary-Container
 * --------------------------------------------------------------------------- */
.summary-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1.5rem;
    padding-bottom: 3rem;
}

/* ---------------------------------------------------------------------------
 * 2. Header
 * --------------------------------------------------------------------------- */
.summary-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--color-border, #334155);
}

.summary-header h1 {
    font-size: 1.6rem;
    color: var(--color-primary, #0ea5e9);
    margin: 0 0 0.5rem;
}

.summary-header .summary-meta {
    font-size: 0.95rem;
    color: var(--color-text-secondary, #94a3b8);
    line-height: 1.6;
}

.summary-header .summary-meta strong {
    color: var(--color-text, #e2e8f0);
}

/* ---------------------------------------------------------------------------
 * 3. KPI-Row
 * --------------------------------------------------------------------------- */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--color-surface, #1e293b);
    border: 1px solid var(--color-border, #334155);
    border-radius: 12px;
    padding: 1.2rem 1rem;
    text-align: center;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: border-color 0.15s;
}

.kpi-card:hover {
    border-color: var(--color-primary, #0ea5e9);
}

.kpi-card .kpi-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-secondary, #94a3b8);
    margin-bottom: 0.35rem;
}

.kpi-card .kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text, #e2e8f0);
    line-height: 1.2;
}

.kpi-card .kpi-sub {
    font-size: 0.85rem;
    color: var(--color-text-secondary, #94a3b8);
    margin-top: 0.2rem;
}

/* Farbliche Hervorhebung für bestanden / nicht bestanden */
.kpi-card.kpi-passed .kpi-value {
    color: var(--color-success, #22c55e);
}

.kpi-card.kpi-failed .kpi-value {
    color: var(--color-danger, #ef4444);
}

.kpi-card.kpi-total-fp .kpi-value {
    color: var(--color-warning, #f59e0b);
}

/* ---------------------------------------------------------------------------
 * 4. Ergebnistabelle
 * --------------------------------------------------------------------------- */
.summary-section-title {
    font-size: 1.1rem;
    color: var(--color-text, #e2e8f0);
    margin: 0 0 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--color-border, #334155);
}

.results-table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 2rem;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.results-table thead th {
    background: var(--color-surface-alt, #0f172a);
    color: var(--color-text-secondary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    padding: 0.7rem 0.6rem;
    text-align: left;
    border-bottom: 2px solid var(--color-border, #334155);
    white-space: nowrap;
}

.results-table tbody td {
    padding: 0.6rem;
    border-bottom: 1px solid var(--color-border, #334155);
    color: var(--color-text, #e2e8f0);
    vertical-align: middle;
}

.results-table tbody tr:hover {
    background: rgba(14, 165, 233, 0.05);
}

/* Status-Badge in Tabelle */
.results-table .status-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.status-active {
    background: rgba(14, 165, 233, 0.15);
    color: var(--color-primary, #0ea5e9);
}

.status-badge.status-absent {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-danger, #ef4444);
}

.status-badge.status-passive {
    background: rgba(161, 98, 7, 0.15);
    color: var(--color-passive, #a16207);
}

/* Ergebnis-Badge */
.results-table .result-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.result-badge.result-passed {
    background: rgba(34, 197, 94, 0.15);
    color: var(--color-success, #22c55e);
}

.result-badge.result-failed {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-danger, #ef4444);
}

.result-badge.result-na {
    background: rgba(148, 163, 184, 0.15);
    color: var(--color-text-secondary, #94a3b8);
}

/* ---------------------------------------------------------------------------
 * 5. Action-Buttons
 * --------------------------------------------------------------------------- */
.summary-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.summary-actions .summary-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.7rem 1.4rem;
    border: 1px solid var(--color-border, #334155);
    border-radius: 8px;
    background: var(--color-surface, #1e293b);
    color: var(--color-text, #e2e8f0);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    text-decoration: none;
    min-height: 48px;
    min-width: 48px;
}

.summary-actions .summary-btn:hover {
    background: var(--color-surface-alt, #0f172a);
    border-color: var(--color-primary, #0ea5e9);
}

.summary-actions .summary-btn-primary {
    background: var(--color-primary, #0ea5e9);
    border-color: var(--color-primary, #0ea5e9);
    color: #fff;
    font-weight: 600;
}

.summary-actions .summary-btn-primary:hover {
    background: #0284c7;
    border-color: #0284c7;
}

/* ---------------------------------------------------------------------------
 * 6. Footer (abgespeckt für Summary)
 * --------------------------------------------------------------------------- */
.summary-footer {
    text-align: center;
    padding: 1rem 0;
    border-top: 1px solid var(--color-border, #334155);
    font-size: 0.8rem;
    color: var(--color-text-secondary, #94a3b8);
}

/* ---------------------------------------------------------------------------
 * 7. Responsive (Tablet / Mobile)
 * --------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .summary-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .summary-actions .summary-btn {
        justify-content: center;
    }

    .summary-header h1 {
        font-size: 1.3rem;
    }

    .kpi-card .kpi-value {
        font-size: 1.6rem;
    }

    /* Fehler-Detail-Spalte auf Mobile kompakter */
    .detail-col {
        min-width: 0;
        max-width: 90px;
    }

    .detail-panel {
        max-width: 95vw !important;
        margin: 0.5rem;
    }
}

@media (max-width: 480px) {
    .kpi-row {
        grid-template-columns: 1fr;
    }
}

/* ---------------------------------------------------------------------------
 * 8. Fehler-Detail-Button, Clickable-Rows & Print-Fehler-Zelle
 * --------------------------------------------------------------------------- */

/* Clickable-Rows: Cursor + Hover */
.results-table tbody tr.clickable-row {
    cursor: pointer;
}

.results-table tbody tr.clickable-row:hover {
    background: rgba(14, 165, 233, 0.08);
}

/* Detail-Spalte (6. Spalte) */
.results-table .detail-col {
    min-width: 110px;
    white-space: nowrap;
}

/* Detail-Button */
.detail-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--color-border, #334155);
    border-radius: 5px;
    background: var(--color-surface, #1e293b);
    color: var(--color-primary, #0ea5e9);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    min-height: 32px;
    min-width: 32px;
    line-height: 1;
}

.detail-btn:hover {
    background: rgba(14, 165, 233, 0.12);
    border-color: var(--color-primary, #0ea5e9);
}

.detail-btn:focus-visible {
    outline: 2px solid var(--color-primary, #0ea5e9);
    outline-offset: 2px;
}

/* Leere Fehler-Anzeige */
.detail-empty {
    color: var(--color-text-secondary, #94a3b8);
    font-size: 0.85rem;
}

/* Print-Fehler-Zelle: auf Screen ausgeblendet, im Print sichtbar */
.print-fehler-cell {
    display: none;
}

/* ---------------------------------------------------------------------------
 * 9. Student-Detail-Modal (Inline im Summary, eigener Panel-Stil)
 * --------------------------------------------------------------------------- */

/* Modal-Overlay (kann vom dashboard-modal.css oder eigenständig sein) */
#student-detail-modal.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

#student-detail-modal.modal-overlay[style*="display: flex"],
#student-detail-modal.modal-overlay[style*="display:flex"] {
    display: flex !important;
}

/* Eigenes Panel für das Student-Detail (schmaler als Dashboard-Modal) */
#student-detail-modal .detail-panel {
    background: var(--color-bg, #0f172a);
    border: 1px solid var(--color-border, #334155);
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: detailFadeIn 0.2s ease-out;
}

@keyframes detailFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Header */
#student-detail-modal .modal-header {
    padding: 1.2rem 1.5rem 0.6rem;
    border-bottom: 1px solid var(--color-border, #334155);
}

#student-detail-modal .modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text, #e2e8f0);
    margin-bottom: 0.2rem;
}

#student-detail-modal .modal-name {
    font-size: 0.85rem;
    color: var(--color-text-secondary, #94a3b8);
}

#student-detail-modal .modal-name strong {
    color: var(--color-text, #e2e8f0);
}

/* Body */
#student-detail-modal .modal-body {
    padding: 1.2rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

#student-detail-modal .modal-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary, #94a3b8);
    margin-bottom: 0.6rem;
}

/* Fehler-Liste im Modal */
.modal-fehlerliste {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

/* Einzelner Fehler-Eintrag */
.modal-fehler-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.7rem;
    background: var(--color-surface, #1e293b);
    border: 1px solid var(--color-border, #334155);
    border-radius: 6px;
    transition: border-color 0.1s;
}

.modal-fehler-item:hover {
    border-color: var(--color-primary, #0ea5e9);
}

.modal-fehler-item-art {
    font-size: 0.9rem;
    color: var(--color-text, #e2e8f0);
    font-weight: 500;
}

.modal-fehler-item-fp {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-warning, #f59e0b);
    white-space: nowrap;
    margin-left: 1rem;
}

/* Leerer Zustand */
.modal-fehlerliste-empty {
    text-align: center;
    padding: 1.5rem 0;
    color: var(--color-text-secondary, #94a3b8);
    font-size: 0.9rem;
}

/* Footer */
#student-detail-modal .modal-footer {
    padding: 0.8rem 1.5rem;
    border-top: 1px solid var(--color-border, #334155);
    display: flex;
    justify-content: flex-end;
}

#student-detail-modal .modal-btn {
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    border: 1px solid var(--color-border, #334155);
    transition: background 0.15s;
    min-height: 40px;
    min-width: 40px;
}

#student-detail-modal .modal-btn-cancel {
    background: var(--color-surface, #1e293b);
    color: var(--color-text, #e2e8f0);
}

#student-detail-modal .modal-btn-cancel:hover {
    background: var(--color-surface-alt, #0f172a);
    border-color: var(--color-primary, #0ea5e9);
}

/* Body-Lock bei offenem Modal */
body.modal-open {
    overflow: hidden !important;
}

/* ---------------------------------------------------------------------------
 * 10. Confirm-Modal: "Neue Prüfung starten" (eigenes Modal, kleiner)
 * --------------------------------------------------------------------------- */

/* Overlay (teilt Klasse .modal-overlay mit student-detail) */
#confirm-new-exam-modal.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

#confirm-new-exam-modal.modal-overlay[style*="display: flex"],
#confirm-new-exam-modal.modal-overlay[style*="display:flex"] {
    display: flex !important;
}

/* Panel – kompakter als Student-Detail */
#confirm-new-exam-modal .confirm-panel {
    background: var(--color-bg, #0f172a);
    border: 1px solid var(--color-border, #334155);
    border-radius: 12px;
    max-width: 420px;
    width: 90%;
    display: flex;
    flex-direction: column;
    animation: detailFadeIn 0.2s ease-out;
}

/* Header */
#confirm-new-exam-modal .modal-header {
    padding: 1.2rem 1.5rem 0.4rem;
}

#confirm-new-exam-modal .modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text, #e2e8f0);
}

/* Body – Message-Text */
#confirm-new-exam-modal .modal-body {
    padding: 0.6rem 1.5rem;
}

#confirm-new-exam-modal .confirm-message {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--color-text-secondary, #94a3b8);
}

/* Footer – Button-Reihe */
#confirm-new-exam-modal .confirm-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border, #334155);
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}

#confirm-new-exam-modal .modal-btn {
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    border: 1px solid var(--color-border, #334155);
    transition: background 0.15s;
    min-height: 40px;
    min-width: 40px;
    font-weight: 500;
}

#confirm-new-exam-modal .modal-btn-cancel {
    background: var(--color-surface, #1e293b);
    color: var(--color-text, #e2e8f0);
}

#confirm-new-exam-modal .modal-btn-cancel:hover {
    background: var(--color-surface-alt, #0f172a);
    border-color: var(--color-primary, #0ea5e9);
}

#confirm-new-exam-modal .modal-btn-primary {
    background: var(--color-primary, #0ea5e9);
    color: #fff;
    border-color: var(--color-primary, #0ea5e9);
}

#confirm-new-exam-modal .modal-btn-primary:hover {
    background: #0284c7;
    border-color: #0284c7;
}
