/* ============================================================
   Farbpalette
   ============================================================ */
:root {
    --navy:        #1a2744;
    --navy-dark:   #111b30;
    --gold:        #c9a84c;
    --gold-dark:   #a8872e;
    --bg:          #f2f1ed;
    --surface:     #ffffff;
    --surface-soft: #f8f9fc;
    --text:        #1a2744;
    --muted:       #6b7280;
    --border:      #d1d5db;
    --border-soft: #f1f5f9;
    --danger:      #dc2626;
    --danger-bg:   #fee2e2;
    --font-display: 'Crimson Pro', Georgia, 'Times New Roman', serif;
}

/* ============================================================
   Basis
   ============================================================ */
html {
    min-height: 100%;
}
body {
    min-height: 100%;
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.9rem;
    background-color: var(--bg);
    color: var(--text);
}

.page-container {
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* ============================================================
   Header / Navbar
   ============================================================ */
.base-bg {
    background-color: var(--navy);
}

.app-header {
    background-color: var(--navy);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.app-header .header-logo img {
    height: 64px;
    width: auto;
}

.app-header .header-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: rgba(255,255,255,0.85);
    font-size: 0.85rem;
}

.app-header .header-user .user-name {
    color: var(--gold);
    font-weight: 500;
}

.btn-sync {
    background: transparent;
    border: 1px solid rgba(201,168,76,0.5);
    color: var(--gold);
    width: 30px;
    height: 30px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}
.btn-sync:hover { background: rgba(201,168,76,0.15); border-color: var(--gold); }
.btn-sync.syncing { opacity: 0.6; cursor: not-allowed; }
.btn-sync.syncing .fa-rotate { animation: spin 1s linear infinite; }

@media (max-width: 767px) {
    .btn-sync {
        background: var(--gold);
        border-color: var(--gold);
        color: var(--navy);
        width: auto;
        height: 36px;
        padding: 0 0.75rem;
        border-radius: 18px;
        font-size: 0.78rem;
        font-weight: 600;
        gap: 0.4rem;
    }
    .btn-sync::after { content: 'Sync'; }
    .btn-sync:hover { background: var(--gold-dark); border-color: var(--gold-dark); color: var(--navy); }
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.app-header .header-user .btn-logout {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.85);
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    font-size: 0.8rem;
    text-decoration: none;
    transition: all 0.2s;
}

.app-header .header-user .btn-logout:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.6);
    color: #fff;
}

/* Schmale Navigationsleiste unter dem Header */
.app-subnav {
    background-color: var(--navy-dark);
    border-bottom: 2px solid var(--gold);
}

.app-subnav .nav-link {
    color: rgba(255,255,255,0.7);
    font-size: 0.82rem;
    padding: 0.5rem 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.2s;
}

.app-subnav .nav-link:hover,
.app-subnav .nav-link.active {
    color: var(--gold);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-base {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--navy);
    --bs-btn-border-color: var(--navy);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--navy-dark);
    --bs-btn-hover-border-color: var(--navy-dark);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--navy-dark);
    --bs-btn-active-border-color: var(--navy-dark);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--muted);
    --bs-btn-disabled-border-color: var(--muted);
}

.btn-gold {
    --bs-btn-color: var(--navy);
    --bs-btn-bg: var(--gold);
    --bs-btn-border-color: var(--gold);
    --bs-btn-hover-color: var(--navy);
    --bs-btn-hover-bg: var(--gold-dark);
    --bs-btn-hover-border-color: var(--gold-dark);
    --bs-btn-active-color: var(--navy);
    --bs-btn-active-bg: var(--gold-dark);
}

/* ============================================================
   Karten & Tabellen
   ============================================================ */
.card {
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.card-header {
    background-color: var(--navy);
    color: #fff;
    border-radius: 7px 7px 0 0 !important;
    font-weight: 500;
    padding: 0.75rem 1.25rem;
    border-bottom: none;
}

table {
    table-layout: fixed;
    width: 100%;
}

th {
    font-weight: 600;
    color: var(--navy);
    border-bottom: 2px solid var(--border) !important;
    vertical-align: middle;
}

/* ============================================================
   Footer
   ============================================================ */
footer {
    text-align: center;
    background-color: var(--navy);
    color: rgba(255,255,255,0.4);
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    width: 100%;
    border-top: 1px solid rgba(255,255,255,0.06);
}

footer a {
    color: rgba(255,255,255,0.45);
    text-decoration: none;
}

/* ============================================================
   Status-Badges
   ============================================================ */
.badge-stat    { display: inline-block; min-width: 44px; text-align: center; padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.82rem; font-weight: 600; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-neutral { background: #e5e7eb; color: #374151; }
.val-unknown { color:#f59e0b; font-size:0.82rem; font-weight:600; white-space:nowrap; }

/* ============================================================
   Farb-Utilities (abwärtskompatibel)
   ============================================================ */
.base-color   { color: var(--navy); }
.bg-gray      { background-color: #9a9da0 !important; }
.bg-card-gray { background-color: #f5f6f8; }
.text-gray    { color: var(--muted) !important; }

.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
    background-color: var(--navy);
    color: #fff;
}

.nav-pills .nav-link {
    color: var(--navy);
}

/* ============================================================
   Hilfreich
   ============================================================ */
.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--navy);
    width: 30px; height: 30px;
    padding: 0;
    border-radius: 6px;
    transition: all 0.15s;
}
.btn-icon:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

.btn-icon-danger {
    background: transparent;
    border: 1px solid #fca5a5;
    color: #dc2626;
    width: 30px; height: 30px;
    padding: 0;
    border-radius: 6px;
    transition: all 0.15s;
}
.btn-icon-danger:hover { background: #dc2626; color: #fff; border-color: #dc2626; }

.bearbeiter-badge-inline { background: #fef3c7; color: #92400e; font-size: 0.78rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 20px; }

/* btn-xs (Bootstrap 3 compat) */
.btn-xs { padding: 0.15rem 0.45rem; font-size: 0.75rem; border-radius: 4px; line-height: 1.5; }

.hidden   { display: none; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.navbar { margin-bottom: 0; border-radius: 0; }

/* ============================================================
   Select2
   ============================================================ */
.input-group .select2-container { width: 100% !important; flex: 1; }
.input-group .select2-container--bootstrap-5 .select2-selection {
    border: 1px solid #ced4da;
    border-top-right-radius: .375rem;
    border-bottom-right-radius: .375rem;
    height: calc(2.25rem + 2px);
    padding: 0.375rem 0.75rem;
}
.input-group .select2-container--bootstrap-5 .select2-selection__rendered { line-height: 1.5; }

.select-group .select2-container { width: 100% !important; flex: 1; }
.select-group .select2-container--bootstrap-5 .select2-selection {
    border: 1px solid #ced4da;
    border-radius: .375rem;
    height: calc(2.25rem + 2px);
    padding: 0.375rem 0.75rem;
}
.select-group .select2-container--bootstrap-5 .select2-selection__rendered { line-height: 1.5; }

.information-select-group { display: flex; align-items: center; width: 100%; }
.information-select-group .input-group-text {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: 1px solid #ced4da;
}
.information-select-group .select2-container { width: 100% !important; flex: 1; }
.information-select-group .select2-container--bootstrap-5 .select2-selection {
    border: 1px solid #ced4da;
    border-left: 0;
    height: calc(2.25rem + 2px);
    padding: 0.375rem 0.75rem;
}
.information-select-group .select2-container--bootstrap-5 .select2-selection__rendered { line-height: 1.5; }
.information-select-group .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    height: calc(2.25rem + 2px);
}

/* ============================================================
   Akte – shared layout
   ============================================================ */
.akte-layout { display: flex; flex-direction: column; }

.akte-hero {
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.akte-hero-parteien { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; color: var(--navy); margin-bottom: 0.3rem; letter-spacing: -0.01em; }
.akte-hero-meta { font-size: 0.8rem; color: var(--muted); display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

.akte-top-bar { padding: 1.25rem 1.5rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.akte-top-bar .akte-field-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; display: block; margin-bottom: 0.25rem; }
.akte-top-bar .form-control, .akte-top-bar .form-select { font-size: 0.9rem; }

.akte-columns { display: grid; grid-template-columns: 300px 1fr; }
.akte-sidebar { background: #f8f9fc; border-right: 1px solid var(--border); padding: 1.25rem; }
.akte-main { padding: 0; min-width: 0; }

/* Sidebar: readonly definition list */
.bk-search-dropdown { display:none; position:absolute; top:100%; left:0; right:0; z-index:1050; background:#fff; border:1px solid var(--border); border-radius:6px; box-shadow:0 4px 16px rgba(0,0,0,0.12); max-height:240px; overflow-y:auto; margin-top:2px; }
.bk-search-item { padding:0.45rem 0.75rem; cursor:pointer; font-size:0.88rem; border-bottom:1px solid #f1f5f9; }
.bk-search-item:last-child { border-bottom:none; }
.bk-search-item:hover { background:#f0f4ff; }
.akte-dl { margin: 0; }
.akte-dl-row { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.akte-dl-row:last-of-type { border-bottom: none; }
.akte-dl dt { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.akte-dl dd { font-size: 0.88rem; font-weight: 500; color: var(--text); margin: 0; }

/* Sidebar: editable fields */
.akte-field { margin-bottom: 0.8rem; }
.akte-field-label { font-size: 0.67rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; display: block; margin-bottom: 0.25rem; }
.akte-field .form-control, .akte-field .form-select { font-size: 0.88rem; padding: 0.35rem 0.65rem; }

.akte-notiz-box { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 0.65rem 0.8rem; font-size: 0.85rem; color: var(--text); white-space: pre-wrap; min-height: 60px; }

/* Tabs */
.akte-tabs { display: flex; border-bottom: 2px solid var(--border); padding: 0 0.75rem; background: var(--surface); overflow-x: auto; scrollbar-width: none; }
.akte-tabs::-webkit-scrollbar { display: none; }
.akte-tabs .nav-item { margin-bottom: -2px; flex-shrink: 0; }
.akte-tabs .nav-link { color: var(--muted); font-size: 0.72rem; font-weight: 600; padding: 0.7rem 0.9rem; border: none; border-bottom: 2px solid transparent; border-radius: 0; text-transform: uppercase; letter-spacing: 0.05em; background: none; transition: color 0.15s, border-color 0.15s; white-space: nowrap; }
.akte-tabs .nav-link:hover { color: var(--navy); }
.akte-tabs .nav-link.active { color: var(--navy); border-bottom-color: var(--gold); }

.akte-tab-content { min-height: 420px; }

.akte-section-title { font-size: 0.67rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 1.25rem 0 0.75rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--border); }
.akte-section-title:first-child { margin-top: 0; }

/* Detail stats */
.detail-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.8rem 1rem; height: 100%; }
.detail-stat-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.2rem; }
.detail-stat-value { font-size: 0.9rem; font-weight: 700; color: var(--navy); }

/* Anruf-cards */
.anruf-card { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); height: 100%; }
.anruf-card-header { display: flex; align-items: center; gap: 0.5rem; background: var(--navy); color: #fff; padding: 0.45rem 0.9rem; font-size: 0.78rem; font-weight: 500; border-bottom: 1px solid rgba(255,255,255,0.1); }
.anruf-card-header .ms-auto { color: rgba(255,255,255,0.55); font-size: 0.7rem; }
.anruf-card-body { padding: 0.55rem 0.9rem; }
.anruf-row { display: flex; justify-content: space-between; padding: 0.18rem 0; font-size: 0.78rem; border-bottom: 1px solid #f1f3f5; }
.anruf-row:last-child { border-bottom: none; }
.anruf-label { color: var(--muted); font-size: 0.68rem; min-width: 65px; }
.anruf-value { font-weight: 500; text-align: right; word-break: break-all; }
.anruf-card-footer { padding: 0.5rem 0.9rem; background: #f8f9fc; border-top: 1px solid var(--border); }

/* Bezifferung table */
.bz-table { font-size: 0.88rem; margin-bottom: 0; }
.bz-table th { font-size: 0.65rem !important; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted) !important; padding: 0.5rem 0.75rem; background: #f8f9fc; border-bottom: 1px solid var(--border) !important; font-weight: 600; }
.bz-table td { padding: 0.6rem 0.75rem; vertical-align: middle; border-bottom: 1px solid #f1f3f5 !important; }
.bz-table tr:last-child td { border-bottom: none !important; }
.bz-table .bz-label-cell { font-size: 0.72rem; font-weight: 700; color: var(--navy); background: #f8f9fc; white-space: nowrap; width: 55px; }
.bz-table .form-control { font-size: 0.85rem; padding: 0.3rem 0.6rem; }

/* Misc */
.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.text-gold      { color: var(--gold); }
.text-gold-muted { color: var(--gold); }
.card-header .badge-stat { font-size: 0.7rem; }
.bearbeiter-badge { background: #fef3c7; color: #92400e; font-size: 0.73rem; font-weight: 600; padding: 0.12rem 0.5rem; border-radius: 20px; white-space: nowrap; }

/* ============================================================
   Spaltenbreiten
   ============================================================ */
.th-large { width: 30%; }
.th-small { width: 10%; }

/* ============================================================
   Hamburger / Mobile Nav
   ============================================================ */
.btn-hamburger {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.85);
    width: 36px;
    height: 36px;
    border-radius: 6px;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-hamburger:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.6); }

.mobile-nav-link {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.25rem;
    color: rgba(255,255,255,0.75);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}
.mobile-nav-link:hover { background: rgba(255,255,255,0.07); color: #fff; }
.mobile-nav-link.active { color: var(--gold); border-left-color: var(--gold); background: rgba(201,168,76,0.08); }

/* ============================================================
   Responsive
   ============================================================ */
.mobile { display: none; }

@media (min-width: 651px) and (max-width: 1530px) {
    .mobile        { display: none; }
    .not-important { display: none; }
}

@media (min-width: 470px) and (max-width: 650px) {
    .mobile           { display: inline; }
    .desktop          { display: none; }
    .not-important    { display: none; }
    .not-so-important { display: none; }
}

@media (max-width: 469px) {
    .mobile           { display: inline; font-size: 0.8em; }
    .desktop          { display: none; }
    .not-important    { display: none; }
    .not-so-important { display: none; }
    .almost-important { display: none; }
}

@media (max-width: 767px) {
    /* Header: Logo kleiner auf Mobile */
    .header-logo svg { width: 190px; height: auto; }
    .app-header { height: 56px; padding: 0 1rem; }

    /* Container: kein seitlicher Abstand nötig */
    .container { padding-left: 0.75rem; padding-right: 0.75rem; }

    /* Akte-Spalten: single column auf Mobile */
    .akte-columns { grid-template-columns: 1fr; }
    .akte-sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ============================================================
   Toast-Benachrichtigungen
   ============================================================ */
.rae-toast { border-radius: 10px !important; padding: 11px 16px !important; font-size: .875rem !important; font-family: 'Segoe UI', Arial, sans-serif !important; box-shadow: 0 4px 24px rgba(0,0,0,.2) !important; min-width: 220px; max-width: 360px !important; }
.rae-toast .t-toast-inner { display: flex; align-items: center; gap: 9px; }
.rae-toast .t-toast-inner i { font-size: .9rem; flex-shrink: 0; opacity: .9; }

/* ============================================================
   Modal-Header (global – navy, kein Gold-Border)
   ============================================================ */
.modal-content .modal-header {
    background: var(--navy);
    border: none;
    padding: 0.8rem 1.25rem;
}
.modal-content .modal-header .modal-title,
.modal-content .modal-header h5,
.modal-content .modal-header h6 { color: #fff; font-size: 0.88rem; font-weight: 600; }
.modal-content .modal-header .btn-close { filter: invert(1) grayscale(1) brightness(2); opacity: 0.8; }

/* ============================================================
   Card-Header ohne Gold-Border (für Karten mit eigener Gestaltung)
   ============================================================ */
.card-header.card-header-plain { border-bottom: none; padding: 1rem 1.25rem; }

/* ============================================================
   Badge Gold
   ============================================================ */
.badge-gold { background: var(--gold); color: var(--navy); }

/* ============================================================
   Priorität-Badges (global)
   ============================================================ */
.prio-badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.prio-kritisch { background: #fee2e2; color: #991b1b; }
.prio-hoch     { background: #ffedd5; color: #9a3412; }
.prio-mittel   { background: #fef3c7; color: #92400e; }
.prio-einfach  { background: #dcfce7; color: #166534; }
.prio-erledigt { background: #f3f4f6; color: #6b7280; }

/* ============================================================
   Klickbare Tabellenzeilen
   ============================================================ */
.table-row-link { cursor: pointer; transition: background 0.1s; }
.table-row-link:hover { background: #f0f4ff; }

/* ============================================================
   Display-Font Utilities
   ============================================================ */
.az-header {
    font-family: var(--font-display);
    letter-spacing: 0.01em;
}

/* ============================================================
   Sekundäre Card-Header (Sidebar-Widgets, Info-Karten)
   ============================================================ */
.card-header-secondary {
    background: var(--surface-soft);
    color: var(--navy);
    border-left: 3px solid var(--gold);
    border-bottom: 1px solid var(--border);
    border-radius: 7px 7px 0 0 !important;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.65rem 1rem 0.65rem 0.85rem;
}
.card-header-secondary a { color: var(--navy); opacity: 0.65; font-size: 0.78rem; }
.card-header-secondary a:hover { opacity: 1; }

/* Akte-Hero: Aktenzeichen als Display-Element */
.akte-hero-az,
.bk-az {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 600;
    color: var(--navy);
    letter-spacing: 0.01em;
    line-height: 1.1;
}

@media (max-width: 767px) {
    .akte-hero-az, .bk-az { font-size: 1.1rem; }
}

/* ============================================================
   Focus-States (Accessibility)
   ============================================================ */
.btn:focus-visible,
.btn-icon:focus-visible,
.btn-icon-danger:focus-visible,
.btn-hamburger:focus-visible,
.btn-logout:focus-visible,
.mobile-nav-link:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
