/* =========================================================================
 * SchulBuchManager — Operator-Portal-Layout
 * Sidebar links + Main-Area rechts. Dunkle Markenfarbe in Sidebar.
 * ========================================================================= */

body.op-body {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
    background: var(--sbm-gray-50);
}

/* ----- Sidebar -----
 * Aussen kein Scroll: Sidebar ist auf 100vh fixiert, der innere Bereich
 * `.op-nav-wrap` ist der einzige Scroll-Container. Damit funktioniert die
 * Scroll-Persistence beim Seitenwechsel deterministisch (siehe Skript im
 * Header-Template).
 */
.op-sidebar {
    background: var(--sbm-primary-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

.op-sidebar .op-brand {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 12px;
}

.op-sidebar .op-brand img {
    width: 100%;
    max-width: 170px;
    height: auto;
}

.op-sidebar .op-role {
    padding: 0 20px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 4px;
}

.op-nav-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 0 0 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.op-nav-wrap::-webkit-scrollbar { width: 6px; }
.op-nav-wrap::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }
.op-nav-wrap::-webkit-scrollbar-track { background: transparent; }

.op-nav-group { margin-bottom: 6px; }
.op-nav-group:last-child { margin-bottom: 0; }
.op-nav-group-label {
    padding: 12px 20px 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.42);
}

.op-nav { list-style: none; padding: 0; margin: 0; }

.op-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.op-nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; text-decoration: none; }
.op-nav a.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-left-color: var(--sbm-secondary-dark);
}
.op-nav svg { flex-shrink: 0; }
.op-nav-badge {
    margin-left: auto;
    background: var(--sbm-warning, #D97706);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
}
.op-nav a.active .op-nav-badge { background: #fff; color: var(--sbm-primary); }

.op-user-box {
    padding: 14px 16px;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.12);
}

.op-user-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.op-user-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sbm-secondary), var(--sbm-secondary-dark));
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.op-user-info {
    flex: 1;
    min-width: 0;
}
.op-user-info .op-user-name {
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.op-user-info .op-user-email {
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    line-height: 1.3;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.op-user-info .op-user-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 1px 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sbm-secondary-dark);
    background: rgba(107, 199, 209, 0.12);
    border: 1px solid rgba(107, 199, 209, 0.35);
    border-radius: 999px;
}

.op-user-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 7px 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--sbm-radius-sm);
    color: rgba(255, 255, 255, 0.78);
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.op-user-logout:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    text-decoration: none;
}
.op-user-logout svg { flex-shrink: 0; }

/* ----- Main ----- */
.op-main { padding: 28px 36px; min-width: 0; }

.op-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--sbm-gray-200);
}
.op-page-header h1 { margin: 0; font-size: 26px; }
.op-page-header .subtitle { color: var(--sbm-gray-500); font-size: 14px; margin-top: 4px; }
.op-page-header .actions { display: flex; gap: 10px; }

/* ----- Filter-Leiste (Schulen/Rechnungen/Verträge) ----- */
.op-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    margin: calc(-1 * var(--sbm-space-5));
    margin-bottom: var(--sbm-space-4);
    padding: 12px 20px;
    border-bottom: 1px solid var(--sbm-gray-200);
    background: var(--sbm-gray-50);
    border-top-left-radius: var(--sbm-radius-lg);
    border-top-right-radius: var(--sbm-radius-lg);
}

.op-status-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.op-status-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--sbm-radius);
    color: var(--sbm-gray-600);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background 120ms ease, color 120ms ease;
}
.op-status-tab:hover { background: var(--sbm-gray-100); color: var(--sbm-gray-800); text-decoration: none; }
.op-status-tab.active {
    background: var(--sbm-primary);
    color: #fff;
}
.op-status-tab .count {
    display: inline-block;
    min-width: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    color: inherit;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    line-height: 18px;
}
.op-status-tab.active .count { background: rgba(255, 255, 255, 0.2); }

.op-search {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 260px;
}
.op-search svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--sbm-gray-400);
    pointer-events: none;
}
.op-search input[type="search"] {
    padding-left: 34px;
    background: #fff;
    font-size: 13px;
}

/* ----- Schulen-Tabelle: klickbare Zeilen ----- */
.op-schools-table .op-row-link { cursor: pointer; transition: background 80ms ease; }
.op-schools-table .op-row-link:hover { background: var(--sbm-gray-50); }
.op-schools-table tbody td { vertical-align: middle; }
.op-schools-table .text-right { text-align: right; }

/* ----- Stat-Kacheln fürs Dashboard ----- */
.op-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.op-stat {
    background: #fff;
    border: 1px solid var(--sbm-gray-200);
    border-radius: var(--sbm-radius-lg);
    padding: 18px 20px;
    box-shadow: var(--sbm-shadow-1);
}
.op-stat .stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sbm-gray-500);
    font-weight: 600;
}
.op-stat .stat-value {
    font-size: 30px;
    font-weight: 600;
    color: var(--sbm-gray-900);
    line-height: 1.1;
    margin-top: 4px;
}
.op-stat .stat-meta {
    font-size: 13px;
    color: var(--sbm-gray-500);
    margin-top: 4px;
}

/* ----- Login-Seite (volle Höhe, zentriert) ----- */
body.op-login-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(180deg, var(--sbm-gray-50), #fff);
}
.op-login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border: 1px solid var(--sbm-gray-200);
    border-radius: var(--sbm-radius-lg);
    box-shadow: var(--sbm-shadow-2);
    padding: 36px 32px;
}
.op-login-card .brand {
    text-align: center;
    margin-bottom: 24px;
}
.op-login-card .brand img { margin: 0 auto; max-width: 220px; }
.op-login-card h1 {
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    color: var(--sbm-gray-500);
    margin: 16px 0 24px;
}

/* ----- Setup-Seite ----- */
body.setup-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background: var(--sbm-gray-50);
}
.setup-card {
    width: 100%;
    max-width: 520px;
    background: #fff;
    border: 1px solid var(--sbm-gray-200);
    border-radius: var(--sbm-radius-lg);
    box-shadow: var(--sbm-shadow-2);
    padding: 40px;
}
.setup-card .brand { text-align: center; margin-bottom: 24px; }
.setup-card .brand img { margin: 0 auto; max-width: 260px; }

/* ----- Schul-Detail ----- */
.op-approve-card { border-left: 4px solid var(--sbm-secondary); }

.op-reset-link {
    display: block;
    width: 100%;
    padding: 8px 10px;
    margin: 4px 0;
    background: #fff;
    border: 1px solid var(--sbm-gray-300);
    border-radius: var(--sbm-radius-sm);
    font-family: var(--sbm-font-mono);
    font-size: 12px;
    word-break: break-all;
}

/* ----- Responsive (Mobil-Ansicht nur notdürftig — Betreiber arbeitet i.d.R. am Desktop) ----- */
@media (max-width: 768px) {
    body.op-body {
        grid-template-columns: 1fr;
    }
    .op-sidebar {
        position: relative;
        height: auto;
        padding: 12px 0;
    }
    .op-main { padding: 20px; }
}

/* ----- System-Wartung-Banner im Operator-Portal ----- */
.op-system-maint-banner {
    margin-bottom: 16px;
    padding: 10px 14px;
    background: linear-gradient(90deg, #D97706 0%, #DC2626 100%);
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.18);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.op-system-maint-banner strong { color: #fff; }
.op-system-maint-banner a {
    margin-left: auto;
    color: #fff;
    text-decoration: underline;
    font-weight: 600;
}
.op-system-maint-banner a:hover { text-decoration: none; }
