/* ============================================================
   KFZ Portal – Auth & Desktop Layout CSS
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --blue:    #1e4080;
    --blue2:   #2756b0;
    --green:   #27ae60;
    --red:     #e74c3c;
    --light:   #f4f6fb;
    --border:  #dde3ef;
    --text:    #1a1a2e;
    --muted:   #6b7280;
    --white:   #ffffff;
    --sidebar-w: 240px;
    --topbar-h:  56px;
    --radius:  8px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--light);
}

/* ══════════════════════════════════════════════════════════════
   AUTH PAGES (Login, 2FA, Setup)
══════════════════════════════════════════════════════════════ */

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e4080 0%, #2756b0 50%, #1a3060 100%);
    padding: 20px;
}

.auth-card {
    background: var(--white);
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    text-align: center;
}

.setup-card { max-width: 480px; text-align: left; }

.auth-logo {
    font-size: 3rem;
    margin-bottom: 12px;
    display: block;
}

.auth-title {
    font-size: 1.6rem;
    color: var(--blue);
    font-weight: 700;
    margin-bottom: 6px;
}

.auth-sub {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 28px;
    line-height: 1.5;
}

/* ── Fehlermeldung ──────────────────────────────────────────── */
.auth-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-error-icon { font-size: 1.1rem; flex-shrink: 0; }

/* ── Formularfelder ─────────────────────────────────────────── */
.auth-field {
    margin-bottom: 16px;
    text-align: left;
}

.auth-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.auth-field input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.15s;
    color: var(--text);
}

.auth-field input:focus {
    outline: none;
    border-color: var(--blue2);
    box-shadow: 0 0 0 3px rgba(39,86,176,.12);
}

/* TOTP-Eingabe größer und zentriert */
.totp-input {
    font-size: 2rem !important;
    letter-spacing: 0.4rem;
    text-align: center;
    font-weight: 700;
    color: var(--blue) !important;
}

/* ── Passwort anzeigen Button ───────────────────────────────── */
.password-wrap { position: relative; }
.password-wrap input { padding-right: 48px; }
.pw-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--muted);
    padding: 4px;
}

/* ── Auth Button ────────────────────────────────────────────── */
.auth-btn {
    width: 100%;
    padding: 13px;
    background: var(--blue);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.15s;
    letter-spacing: 0.3px;
}

.auth-btn:hover { background: var(--blue2); }
.auth-btn:active { transform: scale(0.99); }
.auth-btn-green { background: var(--green) !important; }
.auth-btn-green:hover { background: #219a52 !important; }

/* ── TOTP Timer ─────────────────────────────────────────────── */
.totp-timer {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    margin: 12px 0 4px;
    overflow: hidden;
}

.totp-timer-bar {
    height: 100%;
    border-radius: 3px;
    background: var(--green);
    transition: width 1s linear, background 0.3s;
}

.totp-timer-label {
    font-size: 0.8rem;
    color: var(--muted);
    text-align: center;
    margin-bottom: 16px;
}

/* ── Divider / Links ────────────────────────────────────────── */
.auth-divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

.auth-back, .auth-hint {
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 12px;
    line-height: 1.5;
}

.auth-back a { color: var(--blue2); text-decoration: none; }
.auth-back a:hover { text-decoration: underline; }

/* ── 2FA Setup Steps ────────────────────────────────────────── */
.setup-step {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    align-items: flex-start;
}

.setup-step-nr {
    width: 32px;
    height: 32px;
    background: var(--blue);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.setup-step-content { flex: 1; }
.setup-step-content strong { display: block; margin-bottom: 4px; color: var(--blue); }
.setup-step-content p { font-size: 0.9rem; color: var(--muted); line-height: 1.5; }

.qr-container {
    margin: 12px 0;
    display: flex;
    justify-content: center;
}

.qr-container img { border-radius: 8px; border: 4px solid var(--border); }

.secret-reveal summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--blue2);
    margin-top: 8px;
}

.secret-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    background: var(--light);
    border-radius: var(--radius);
    padding: 10px 12px;
}

.secret-box code {
    flex: 1;
    font-family: monospace;
    font-size: 0.9rem;
    letter-spacing: 0.1rem;
    word-break: break-all;
}

.copy-btn {
    background: var(--blue);
    color: var(--white);
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════
   PORTAL LAYOUT (nach Login)
══════════════════════════════════════════════════════════════ */

.portal-body {
    background: var(--light);
    overflow: hidden;
}

.portal-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.portal-sidebar {
    width: var(--sidebar-w);
    background: var(--blue);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    transition: transform 0.25s ease;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    color: var(--white);
    font-weight: 700;
    font-size: 1rem;
}

.sidebar-logo-icon { font-size: 1.4rem; }

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-nav-item:hover {
    background: rgba(255,255,255,.08);
    color: var(--white);
}

.sidebar-nav-item.active {
    background: rgba(255,255,255,.12);
    color: var(--white);
    border-left-color: #fff;
    font-weight: 600;
}

.nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }

/* ── Sidebar Footer ─────────────────────────────────────────── */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    background: rgba(255,255,255,.2);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    min-width: 0;
    color: var(--white);
}

.sidebar-user-info strong {
    display: block;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info small {
    font-size: 0.75rem;
    opacity: 0.7;
}

.sidebar-logout {
    color: rgba(255,255,255,.6);
    text-decoration: none;
    font-size: 1.3rem;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.sidebar-logout:hover { background: rgba(255,255,255,.1); color: var(--white); }

/* ── Hauptbereich ───────────────────────────────────────────── */
.portal-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.portal-topbar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--muted);
    padding: 4px 8px;
}

.topbar-breadcrumb {
    flex: 1;
    font-weight: 600;
    color: var(--blue);
    font-size: 1rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-time {
    font-size: 0.85rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.topbar-logout {
    font-size: 0.85rem;
    color: var(--muted);
    text-decoration: none;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: all 0.15s;
}

.topbar-logout:hover { background: var(--light); color: var(--text); }

/* ── Content ────────────────────────────────────────────────── */
.portal-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Coming Soon */
.coming-soon {
    text-align: center;
    padding: 80px 24px;
}

.coming-soon-icon { font-size: 3rem; margin-bottom: 16px; }
.coming-soon h2 { color: var(--blue); margin-bottom: 8px; }
.coming-soon p  { color: var(--muted); margin-bottom: 16px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
    .sidebar-toggle { display: block; }

    .portal-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }

    .portal-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,.2);
    }

    .portal-content { padding: 16px; }
}
