/* ============================================================
   PMG-Quarantäne-Portal - eigenes Stylesheet
   Branding-Farben unter :root anpassen.
   ============================================================ */

:root {
    /* --- Markenfarben (hier anpassen!) ------------------------ */
    --brand-primary:        #1d3557;
    --brand-primary-hover:  #264872;
    --brand-accent:         #2a9d8f;
    --brand-bg-gradient-1:  #1d3557;
    --brand-bg-gradient-2:  #2a9d8f;

    /* --- Score-Farben --------------------------------------- */
    --score-low:    #198754;
    --score-mid:    #fd7e14;
    --score-high:   #dc3545;
    --score-extreme:#7a1212;

    /* --- Layout --------------------------------------------- */
    --topbar-height:   58px;
    --radius:          .6rem;
    --radius-lg:       1rem;
    --shadow-card:     0 4px 24px rgba(15, 23, 42, .06);
    --shadow-lift:     0 8px 32px rgba(15, 23, 42, .12);
}

[data-bs-theme="dark"] {
    --brand-primary:        #0f1e35;
    --brand-primary-hover:  #1d3557;
    --shadow-card:          0 4px 24px rgba(0, 0, 0, .4);
}

.btn-primary {
    --bs-btn-bg: var(--brand-primary);
    --bs-btn-border-color: var(--brand-primary);
    --bs-btn-hover-bg: var(--brand-primary-hover);
    --bs-btn-hover-border-color: var(--brand-primary-hover);
    --bs-btn-active-bg: var(--brand-primary-hover);
    --bs-btn-active-border-color: var(--brand-primary-hover);
}
.text-primary { color: var(--brand-primary) !important; }
.link-primary { color: var(--brand-primary) !important; }

html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f4f6fa;
    color: #1f2937;
}
[data-bs-theme="dark"] body { background: #0b1220; color: #e5e7eb; }

.view { display: none; }
.view.active { display: block; }

/* ==========================================================
   AUTH-VIEWS (verify / request / error)
   ========================================================== */
#view-verify.active,
#view-request.active,
#view-error.active {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at top left, rgba(42,157,143,.18), transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(29,53,87,.30), transparent 60%),
        linear-gradient(135deg, var(--brand-bg-gradient-1) 0%, #0f2540 100%);
    padding: 2rem 1rem;
}

.login-wrapper { width: 100%; max-width: 440px; }

.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lift);
}
[data-bs-theme="dark"] .login-card { background: #131e36; color: #e5e7eb; }

.login-brand { text-align: center; margin-bottom: 2rem; }
.login-brand i {
    font-size: 2.5rem;
    color: var(--brand-primary);
    background: rgba(29, 53, 87, .08);
    width: 4rem; height: 4rem;
    line-height: 4rem;
    border-radius: 50%;
    margin-bottom: 1rem;
    display: inline-block;
}
.login-brand h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: .5rem;
    color: var(--brand-primary);
}
[data-bs-theme="dark"] .login-brand h1 { color: #fff; }

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}
[data-bs-theme="dark"] .login-footer { border-color: #1f2a44; }

#requestSubmit .spinner-border { vertical-align: -2px; }
#requestSubmit.is-loading .btn-label { display: none; }
#requestSubmit.is-loading .spinner-border { display: inline-block !important; }

/* ==========================================================
   TOPBAR
   ========================================================== */
.topbar {
    background: var(--brand-primary);
    color: #fff;
    height: var(--topbar-height);
    padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.topbar .navbar-brand { color: #fff; font-weight: 600; letter-spacing: .2px; }
.topbar .navbar-brand i { color: rgba(255,255,255,.85); }
.topbar .user-info { color: rgba(255,255,255,.85); font-size: .9rem; }
.topbar .btn-outline-light {
    --bs-btn-border-color: rgba(255,255,255,.4);
    --bs-btn-hover-bg: rgba(255,255,255,.12);
    --bs-btn-hover-border-color: rgba(255,255,255,.6);
}

/* ==========================================================
   TOOLBAR
   ========================================================== */
.toolbar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: .9rem 0;
    position: sticky;
    top: 0;
    z-index: 10;
}
[data-bs-theme="dark"] .toolbar { background: #0f1a30; border-color: #1f2a44; }

.bulk-bar {
    background: rgba(29, 53, 87, .07);
    border: 1px solid rgba(29, 53, 87, .15);
    border-radius: var(--radius);
    padding: .5rem .85rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    font-size: .9rem;
}
[data-bs-theme="dark"] .bulk-bar {
    background: rgba(255,255,255,.05);
    border-color: rgba(255,255,255,.1);
}

/* ==========================================================
   CONTENT / TABELLE
   ========================================================== */
.content-area {
    padding: 1.25rem 0 2rem;
    min-height: calc(100vh - var(--topbar-height) - 200px);
}

.quarantine-table {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
[data-bs-theme="dark"] .quarantine-table { background: #131e36; }

.quarantine-table .table { margin: 0; }

.quarantine-table thead th {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    color: #4b5563;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
    padding: .75rem .9rem;
    white-space: nowrap;
    user-select: none;
}
[data-bs-theme="dark"] .quarantine-table thead th {
    background: #0f1a30; color: #94a3b8; border-color: #1f2a44;
}

.quarantine-table thead th[data-sort] { cursor: pointer; }
.quarantine-table thead th[data-sort]:hover { color: var(--brand-primary); }
[data-bs-theme="dark"] .quarantine-table thead th[data-sort]:hover { color: #fff; }
.sort-icon { opacity: .35; margin-left: .25rem; font-size: .75rem; }
.sort-active { opacity: 1; color: var(--brand-primary); }

.quarantine-table tbody td {
    padding: .65rem .9rem;
    vertical-align: middle;
    border-color: #f1f3f5;
}
[data-bs-theme="dark"] .quarantine-table tbody td { border-color: #1f2a44; }

.quarantine-table tbody tr.clickable-row { cursor: pointer; }
.quarantine-table tbody tr.clickable-row:hover {
    background: rgba(29, 53, 87, .04);
}
[data-bs-theme="dark"] .quarantine-table tbody tr.clickable-row:hover {
    background: rgba(255,255,255,.04);
}
/* Innerhalb der Action- und Checkbox-Zellen den Pointer wieder normal */
.quarantine-table tbody tr.clickable-row td[data-no-row-click] { cursor: default; }
.quarantine-table tbody tr.clickable-row td[data-no-row-click] .row-check,
.quarantine-table tbody tr.clickable-row td[data-no-row-click] .btn { cursor: pointer; }

.col-check  { width: 44px; }
.col-score  { width: 90px; }
.col-date   { width: 170px; }
.col-size   { width: 90px; }
.col-actions{ width: 180px; }

.mail-from {
    font-weight: 500;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
    display: inline-block;
    vertical-align: middle;
}
[data-bs-theme="dark"] .mail-from { color: #f1f5f9; }

.mail-subject {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}
.mail-subject:hover { text-decoration: underline; }
[data-bs-theme="dark"] .mail-subject { color: #93c5fd; }

.mail-date, .mail-size { color: #6b7280; font-size: .85rem; }
.mail-date { white-space: nowrap; }

.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 24px;
    padding: 0 .4rem;
    border-radius: 12px;
    font-size: .78rem;
    font-weight: 600;
    color: #fff;
    background: var(--score-mid);
}
.score-badge.score-low     { background: var(--score-low); }
.score-badge.score-mid     { background: var(--score-mid); }
.score-badge.score-high    { background: var(--score-high); }
.score-badge.score-extreme { background: var(--score-extreme); }

.row-actions { display: inline-flex; gap: .25rem; justify-content: flex-end; }
.row-actions .btn {
    --bs-btn-padding-y: .25rem;
    --bs-btn-padding-x: .55rem;
    --bs-btn-font-size: .82rem;
}

/* ==========================================================
   MODAL
   ========================================================== */
.modal-header {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}
[data-bs-theme="dark"] .modal-header { background: #0f1a30; border-color: #1f2a44; }

.mail-meta {
    background: #f9fafb;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    font-size: .9rem;
}
[data-bs-theme="dark"] .mail-meta { background: #0f1a30; border-color: #1f2a44; }

.meta-row { padding: 2px 0; word-break: break-word; }
.meta-label {
    color: #6b7280;
    font-weight: 500;
    display: inline-block;
    min-width: 60px;
}

.mail-iframe {
    width: 100%;
    min-height: 420px;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius);
    background: #fff;
}
[data-bs-theme="dark"] .mail-iframe { border-color: #1f2a44; }

#modalHeaders {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius);
    padding: 1rem;
    max-height: 480px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
    font-family: ui-monospace, "SF Mono", Monaco, Consolas, monospace;
    font-size: .82rem;
}
[data-bs-theme="dark"] #modalHeaders { background: #0a1226; border-color: #1f2a44; color: #cbd5e1; }

/* ==========================================================
   FOOTER, TOASTS
   ========================================================== */
.app-footer {
    border-top: 1px solid #e5e7eb;
    padding: .9rem 0;
    background: #fff;
    margin-top: 2rem;
}
[data-bs-theme="dark"] .app-footer { background: #0f1a30; border-color: #1f2a44; }

.toast { border: 1px solid #e5e7eb; }
.toast.success-toast { border-left: 4px solid var(--score-low); }
.toast.error-toast   { border-left: 4px solid var(--score-high); }
.toast.info-toast    { border-left: 4px solid var(--brand-primary); }

/* ==========================================================
   ANHÄNGE
   ========================================================== */
.attachments-header {
    font-size: .85rem;
    color: #4b5563;
    margin-bottom: .35rem;
}
[data-bs-theme="dark"] .attachments-header { color: #94a3b8; }
.attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}
.attachment-pill {
    display: inline-flex;
    align-items: center;
    padding: .35rem .65rem;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    background: #fff;
    color: #1f2937;
    text-decoration: none;
    font-size: .82rem;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease;
}
.attachment-pill:hover {
    background: #f3f4f6;
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}
[data-bs-theme="dark"] .attachment-pill {
    background: #1f2a44;
    color: #e2e8f0;
    border-color: #334155;
}
[data-bs-theme="dark"] .attachment-pill:hover {
    background: #2c3a5b;
    border-color: #93c5fd;
    color: #93c5fd;
}
.att-name {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.att-size {
    color: #6b7280;
    margin-left: .5rem;
    font-size: .78rem;
}

/* ==========================================================
   SPAM-INFO (Regel-Tabelle im Modal)
   ========================================================== */
.spaminfo-table td { vertical-align: middle; }
.spaminfo-table thead th:first-child { width: 80px; text-align: end; }
.score-badge-sm { min-width: 56px; height: 22px; font-size: .72rem; padding: 0 .4rem; }
.score-rule-good    { background: var(--score-low);    }
.score-rule-low     { background: #6b7280;             }
.score-rule-mid     { background: var(--score-mid);    }
.score-rule-high    { background: var(--score-high);   }
.score-rule-extreme { background: var(--score-extreme); }

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 768px) {

    /* Score- und Größen-Spalte verschwinden ganz; Datum kompakt rechts oben */
    .col-size { display: none !important; }

    /* Tabelle → Karten-Layout */
    .quarantine-table { background: transparent; box-shadow: none; }
    .quarantine-table thead { display: none; }
    .quarantine-table .table { margin: 0; }
    .quarantine-table tbody tr.clickable-row {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-areas:
            "check  score   date"
            "from   from    from"
            "subj   subj    subj"
            "act    act     act";
        gap: 4px 10px;
        align-items: center;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        margin-bottom: 10px;
        padding: 10px 14px;
    }
    [data-bs-theme="dark"] .quarantine-table tbody tr.clickable-row {
        background: #131e36;
        border-color: #1f2a44;
    }
    .quarantine-table tbody tr.clickable-row.table-active {
        border-color: var(--brand-accent);
        box-shadow: 0 0 0 2px rgba(42, 157, 143, .25);
        background: rgba(42, 157, 143, .05);
    }
    .quarantine-table tbody td { display: block; padding: 0; border: 0; }

    .col-check   { grid-area: check;   }
    .col-score   { grid-area: score;   }
    .col-from    { grid-area: from;    }
    .col-subj    { grid-area: subj;    }
    .col-date    { grid-area: date;  text-align: right; }
    .col-actions { grid-area: act;   text-align: right; margin-top: 4px; }

    .mail-from {
        max-width: none;
        font-size: .82rem;
        color: #6b7280;
        display: block;
    }
    [data-bs-theme="dark"] .mail-from { color: #94a3b8; }
    .mail-subject {
        font-weight: 500;
        font-size: .95rem;
        white-space: normal;
        word-break: break-word;
        color: #1f2937;
    }
    [data-bs-theme="dark"] .mail-subject { color: #f1f5f9; }
    .mail-date {
        font-size: .72rem;
        color: #6b7280;
        white-space: nowrap;
    }
    .row-actions { display: inline-flex; gap: .35rem; }
    .row-actions .btn {
        --bs-btn-padding-y: .35rem;
        --bs-btn-padding-x: .7rem;
    }

    /* Toolbar: Filter etc. besser stacken */
    .toolbar .input-group { max-width: none !important; flex: 1 1 100%; }
    .toolbar select       { max-width: none !important; flex: 1 1 auto; }
    .bulk-bar              { font-size: .82rem; }
    .bulk-bar .btn         { padding: .3rem .55rem; }
    .att-name              { max-width: 160px; }
}
