/* ============================================================
   RBL Download Manager – UI 2.0
   CI: Dunkelblau #081c4a · Orange #FE9032 / #e5963a
   ============================================================ */

:root {
    --ci-navy: #081c4a;
    --ci-navy-soft: #12295e;
    --ci-navy-deep: #050f2c;
    --ci-orange: #fe9032;
    --ci-orange-dark: #d86f10;
    --ci-bg: #eef1f6;
    --ci-text: #1f2a37;
    --ci-muted: #6b7a90;
    --ci-border: #dde3ec;
    --ci-card-shadow: 0 1px 2px rgba(8, 28, 74, 0.06), 0 8px 24px rgba(8, 28, 74, 0.07);
    --ci-radius: 16px;
    --sidebar-width: 264px;
}

* { box-sizing: border-box; }

body.app-body,
body.login-body {
    background: var(--ci-bg);
    color: var(--ci-text);
    font-family: "Segoe UI", "Inter", Tahoma, Arial, sans-serif;
    font-size: 0.95rem;
    min-height: 100vh;
    margin: 0;
}

/* ------------------------------------------------------------
   Grund-Layout: Sidebar + Main
   ------------------------------------------------------------ */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--ci-navy) 0%, var(--ci-navy-deep) 100%);
    color: #cdd6e6;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.25rem 0.9rem;
    border: none;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding: 0.5rem 0.75rem 1.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 1.1rem;
}

.sidebar-logo {
    width: 150px;
    height: auto;
}

.sidebar-app-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    letter-spacing: 0.01em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex-grow: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #b9c4d9;
    text-decoration: none;
    font-weight: 500;
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.07);
}

.sidebar-link.active {
    color: #fff;
    background: rgba(254, 144, 50, 0.16);
    box-shadow: inset 3px 0 0 var(--ci-orange);
    font-weight: 600;
}

.sidebar-link.active .sidebar-icon { color: var(--ci-orange); }

.sidebar-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    flex-shrink: 0;
}

.sidebar-icon svg { width: 100%; height: 100%; }

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logout-form { margin: 0; }

button.sidebar-logout {
    width: 100%;
    background: transparent;
    border: none;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

/* Offcanvas-Variante (mobil) */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        height: 100%;
        z-index: 1045;
    }
}

.app-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ------------------------------------------------------------
   Topbar
   ------------------------------------------------------------ */

.app-topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.75rem;
    background: #fff;
    border-bottom: 1px solid var(--ci-border);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.sidebar-toggle {
    border: 1px solid var(--ci-border);
    border-radius: 10px;
    color: var(--ci-navy);
    padding: 0.35rem 0.55rem;
}

.topbar-title { flex-grow: 1; min-width: 0; }

.topbar-title h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ci-navy);
    margin: 0;
    letter-spacing: -0.01em;
}

.topbar-title p {
    margin: 0.15rem 0 0;
    color: var(--ci-muted);
    font-size: 0.85rem;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--ci-bg);
    border: 1px solid var(--ci-border);
    border-radius: 999px;
    padding: 0.3rem 0.9rem 0.3rem 0.3rem;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--ci-navy);
    color: var(--ci-orange);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-name { font-weight: 600; font-size: 0.85rem; color: var(--ci-navy); }
.user-role { font-size: 0.72rem; color: var(--ci-muted); }

/* ------------------------------------------------------------
   Content
   ------------------------------------------------------------ */

.app-content {
    padding: 1.75rem;
    flex-grow: 1;
}

.app-footer {
    padding: 1rem 1.75rem;
    color: var(--ci-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--ci-border);
}

.card {
    border: none;
    border-radius: var(--ci-radius);
    box-shadow: var(--ci-card-shadow);
    background: #fff;
}

.card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--ci-border);
    padding: 1rem 1.25rem;
    border-radius: var(--ci-radius) var(--ci-radius) 0 0 !important;
}

.card .card-header h2 {
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--ci-navy);
    margin: 0;
}

.card .card-body { padding: 1.25rem; }

/* Statistik-Kacheln (Dashboard) */
.stat-card {
    border-radius: var(--ci-radius);
    padding: 1.15rem 1.3rem;
    background: #fff;
    box-shadow: var(--ci-card-shadow);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--ci-orange);
    border-radius: 4px 0 0 4px;
}

.stat-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ci-muted);
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--ci-navy);
    line-height: 1;
}

/* Filterleisten */
.filter-card {
    background: #f7f9fd;
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius);
    box-shadow: none;
}

/* ------------------------------------------------------------
   Tabellen
   ------------------------------------------------------------ */

.table { margin-bottom: 0; }

.table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--ci-muted);
    border-bottom: 1px solid var(--ci-border);
    white-space: nowrap;
    padding: 0.6rem 0.75rem;
}

.table tbody td {
    border-color: #edf1f7;
    padding: 0.65rem 0.75rem;
    vertical-align: middle;
}

.table tbody tr:hover { background: #f8fafd; }

.table code { color: #9c3410; background: #fef3ea; padding: 0.1rem 0.35rem; border-radius: 6px; font-size: 0.82rem; }

/* Badges */
.badge-state {
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.35rem 0.65rem;
}

.badge-on { background: #e2f5e8; color: #14743a; }
.badge-off { background: #edeff3; color: #5a6676; }
.badge-warn { background: #fff3d6; color: #8a6100; }
.badge-danger { background: #fde5e3; color: #a12318; }

.badge-create { background: #e2f5e8; color: #14743a; }
.badge-update { background: #fff3d6; color: #8a6100; }
.badge-invalid { background: #fde5e3; color: #a12318; }

/* ------------------------------------------------------------
   Formulare & Buttons
   ------------------------------------------------------------ */

.form-label {
    font-weight: 600;
    color: #243244;
    margin-bottom: 0.4rem;
    font-size: 0.86rem;
}

.form-control,
.form-select {
    border-radius: 10px;
    border: 1px solid #c7d0db;
    min-height: 42px;
    font-size: 0.92rem;
}

textarea.form-control { min-height: 96px; }

.form-control:focus,
.form-select:focus {
    border-color: var(--ci-orange);
    box-shadow: 0 0 0 0.2rem rgba(254, 144, 50, 0.18);
}

.form-text { font-size: 0.78rem; }

.btn { border-radius: 10px; font-weight: 600; }

.btn-primary {
    background: var(--ci-orange);
    border-color: var(--ci-orange);
    color: #1a1005;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background: var(--ci-orange-dark) !important;
    border-color: var(--ci-orange-dark) !important;
    color: #fff !important;
}

.btn-outline-primary {
    color: var(--ci-navy);
    border-color: var(--ci-navy);
}

.btn-outline-primary:hover {
    background: var(--ci-navy);
    border-color: var(--ci-navy);
    color: #fff;
}

/* Feed-Auswahl als Checkliste mit grünem Haken (Freigaben-Formular) */
.feed-checks {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #c7d0db;
    border-radius: 10px;
    padding: 0.5rem;
    background: #fff;
}

.feed-check {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0;
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.feed-check:hover { background: #f7f9fd; }

.feed-check input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.feed-check .check-box {
    width: 22px;
    height: 22px;
    border: 2px solid #c7d0db;
    border-radius: 6px;
    background: #fff;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.feed-check .check-box svg { opacity: 0; transition: opacity 0.12s ease; }

.feed-check input:checked ~ .check-box {
    background: #2e9e4f;
    border-color: #2e9e4f;
}

.feed-check input:checked ~ .check-box svg { opacity: 1; }

.feed-check:has(input:checked) {
    background: #eef8f1;
    border-color: #bfe6cc;
}

.feed-check input:focus-visible ~ .check-box {
    outline: 2px solid var(--ci-orange);
    outline-offset: 1px;
}

.feed-check-label { line-height: 1.25; font-size: 0.9rem; }
.feed-check-label code { background: transparent; padding: 0; }

/* JSON-Detailboxen im Audit-Log */
pre.json-box {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.8rem;
    background: #f7f9fd;
    border: 1px solid var(--ci-border);
    border-radius: 10px;
    padding: 0.6rem;
    max-height: 320px;
    overflow: auto;
}

details > summary {
    cursor: pointer;
    color: var(--ci-navy);
    font-weight: 600;
    font-size: 0.85rem;
}

/* ------------------------------------------------------------
   Login-Seite
   ------------------------------------------------------------ */

body.login-body {
    display: flex;
    align-items: stretch;
}

.login-shell {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.login-hero {
    flex: 1 1 55%;
    background: linear-gradient(160deg, var(--ci-navy) 0%, var(--ci-navy-deep) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem;
    position: relative;
    overflow: hidden;
}

.login-hero::after {
    content: "";
    position: absolute;
    width: 480px;
    height: 480px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(254, 144, 50, 0.22) 0%, transparent 70%);
    bottom: -160px;
    right: -120px;
}

.login-hero .hero-logo { width: 240px; margin-bottom: 2.5rem; }

.login-hero h1 {
    font-size: 2.3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 1rem;
}

.login-hero p {
    color: #b9c4d9;
    font-size: 1.05rem;
    max-width: 34rem;
    margin: 0;
}

.hero-points {
    margin-top: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.hero-point {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: #d6deec;
    font-size: 0.95rem;
}

.hero-point .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ci-orange);
    flex-shrink: 0;
}

.login-panel {
    flex: 1 1 45%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 20px;
    box-shadow: var(--ci-card-shadow);
    padding: 2.5rem;
}

.login-card h2 {
    color: var(--ci-navy);
    font-weight: 800;
    font-size: 1.5rem;
    margin-bottom: 0.4rem;
}

.login-card .login-sub {
    color: var(--ci-muted);
    margin-bottom: 1.8rem;
    font-size: 0.92rem;
}

.login-footer {
    margin-top: 2rem;
    color: var(--ci-muted);
    font-size: 0.78rem;
    line-height: 1.6;
}

@media (max-width: 991.98px) {
    .login-hero { display: none; }
    .login-panel { padding-top: 4rem; align-items: flex-start; }
}

/* ------------------------------------------------------------
   Kleinigkeiten
   ------------------------------------------------------------ */

.alert { border-radius: 12px; }

.section-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.empty-row td {
    color: var(--ci-muted);
    text-align: center;
    padding: 1.5rem 0.75rem !important;
}

@media (max-width: 767.98px) {
    .app-content { padding: 1rem; }
    .app-topbar { padding: 0.85rem 1rem; }
    .user-meta { display: none; }
    .user-chip { padding: 0.25rem; border: none; background: transparent; }
}
