/*
 * Theme „Bibliothek" — Digitales Archivportal
 * ============================================
 * Ein ruhiges, elegantes Lesesaal-Design: Elfenbein-Papier, tiefes
 * Flaschengrün, Messing-Akzente und klassische Buchtypografie.
 *
 * Wird NACH css/app.css geladen und überschreibt dessen Variablen
 * und Komponenten. Eigenes (hochgeladenes) CSS lädt danach und
 * gewinnt weiterhin.
 *
 * Schriften: EB Garamond (Überschriften) und Inter (Fließtext) werden
 * von Google Fonts geladen. Ohne Internetzugang greifen automatisch
 * die lokalen Ersatzschriften (Palatino/Georgia bzw. Segoe UI).
 */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================
   Variablen
   ============================================================ */
:root {
    /* Papier & Flächen */
    --color-bg:           #f3eee2;
    --color-bg-alt:       #ebe4d1;
    --color-surface:      #fdfbf4;
    --color-border:       #d8ccb0;
    --color-border-light: #e8e0cc;

    /* Flaschengrün als Hauptfarbe */
    --color-primary:       #2c4a3b;
    --color-primary-light: #3e6450;
    --color-primary-dark:  #1d3329;

    /* Messing / Gold als Akzent */
    --color-accent:        #97783a;
    --color-accent-light:  #c3a35d;

    --color-text:       #272219;
    --color-text-muted: #6e6353;
    --color-text-light: #9a8d77;

    --color-success: #3a6b47;
    --color-warning: #8a6a1c;
    --color-danger:  #813131;
    --color-info:    #2e5570;

    /* Typografie */
    --font-serif: 'EB Garamond', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
    --font-sans:  'Inter', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;

    /* Weichere Geometrie */
    --radius-sm: 7px;
    --radius-md: 11px;
    --radius-lg: 16px;

    /* Mehrschichtige, weiche Schatten */
    --shadow-sm: 0 1px 2px rgba(31, 26, 16, 0.05), 0 2px 10px rgba(31, 26, 16, 0.05);
    --shadow-md: 0 2px 6px rgba(31, 26, 16, 0.06), 0 12px 28px rgba(31, 26, 16, 0.08);
    --shadow-lg: 0 6px 18px rgba(31, 26, 16, 0.10), 0 28px 64px rgba(31, 26, 16, 0.14);

    /* Navigation: dunkler Lesesaal */
    --nav-width:     260px;
    --nav-bg:        #16241c;
    --nav-text:      #cdc4ab;
    --nav-hover-bg:  rgba(195, 163, 93, 0.09);
    --nav-active-bg: rgba(195, 163, 93, 0.16);
}

/* ============================================================
   Basis
   ============================================================ */
body {
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    background-color: var(--color-bg);
    /* Dezente Papierstruktur */
    background-image:
        radial-gradient(ellipse 1400px 600px at 50% -200px, rgba(255, 253, 245, 0.7), transparent),
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(151, 120, 58, 0.012) 2px, rgba(151, 120, 58, 0.012) 4px);
    background-attachment: fixed;
}

::selection {
    background: rgba(195, 163, 93, 0.35);
}

a { color: var(--color-primary-light); }
a:hover { color: var(--color-accent); }

/* ============================================================
   Sidebar — dunkler Lesesaal mit Messing-Details
   ============================================================ */
.sidebar {
    background: linear-gradient(180deg, #1b2c22 0%, #141f18 60%, #101913 100%);
    border-right: 1px solid rgba(195, 163, 93, 0.22);
}

.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(195, 163, 93, 0.25);
    border-radius: 4px;
}

.sidebar-brand {
    padding: 1.6rem 1.25rem 1.3rem;
    border-bottom: none;
    position: relative;
}

/* Doppelte Messinglinie unter dem Markennamen */
.sidebar-brand::after {
    content: '';
    position: absolute;
    left: 1.25rem;
    right: 1.25rem;
    bottom: 0;
    height: 5px;
    border-top: 1px solid rgba(195, 163, 93, 0.45);
    border-bottom: 1px solid rgba(195, 163, 93, 0.18);
}

.sidebar-brand a {
    color: #f0e7cf;
    font-family: var(--font-serif);
    font-size: 1.3rem;
    letter-spacing: 0.01em;
    line-height: 1.25;
}

.sidebar-brand .brand-sub {
    font-family: var(--font-sans);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--color-accent-light);
    opacity: 0.85;
    margin-top: 0.35rem;
}

.sidebar-nav { padding: 1.25rem 0.6rem; }

.nav-section { margin-bottom: 1.4rem; }

.nav-section-label {
    padding: 0.25rem 0.75rem 0.45rem;
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    color: rgba(195, 163, 93, 0.7);
    font-weight: 600;
}

.sidebar-nav a {
    margin: 1px 0;
    padding: 0.55rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 450;
    border-left: none;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover {
    background-color: var(--nav-hover-bg);
    color: #efe6cd;
}

.sidebar-nav a.active {
    background-color: var(--nav-active-bg);
    color: #f5edd6;
    box-shadow: inset 2.5px 0 0 var(--color-accent-light);
}

.sidebar-nav .nav-icon {
    opacity: 0.65;
    color: var(--color-accent-light);
}
.sidebar-nav a.active .nav-icon { opacity: 1; }

.sidebar-footer {
    padding: 1rem 1.25rem 1.15rem;
    border-top: 1px solid rgba(195, 163, 93, 0.22);
    font-size: 0.8rem;
    color: rgba(205, 196, 171, 0.75);
    background: rgba(0, 0, 0, 0.18);
}

/* ============================================================
   Topbar — Elfenbein mit Glaseffekt
   ============================================================ */
.topbar {
    background: rgba(253, 251, 244, 0.82);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border-light);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 2px 12px rgba(31, 26, 16, 0.04);
    min-height: 56px;
    padding: 0.5rem 2rem;
}

.topbar-breadcrumb {
    font-size: 0.83rem;
    letter-spacing: 0.01em;
}

/* ============================================================
   Seitenkopf — Buchtitel-Typografie
   ============================================================ */
.page-body { padding: 2.25rem 2.5rem; }

.page-title {
    font-size: 2.15rem;
    font-weight: 500;
    letter-spacing: 0.005em;
    color: var(--color-primary-dark);
}

/* Kurze Messinglinie als Schmuckelement unter dem Titel */
.page-title::after {
    content: '';
    display: block;
    width: 64px;
    height: 3px;
    margin-top: 0.55rem;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--color-accent-light), rgba(195, 163, 93, 0.15));
}

.page-subtitle {
    font-size: 0.92rem;
    margin-top: 0.45rem;
    max-width: 64ch;
}

/* ============================================================
   Karten
   ============================================================ */
.card {
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    background: linear-gradient(180deg, rgba(243, 238, 226, 0.5), transparent);
    border-bottom: 1px solid var(--color-border-light);
    padding: 0.9rem 1.5rem;
}

.card-title {
    font-size: 1.12rem;
    font-weight: 600;
    color: var(--color-primary-dark);
}

.card-header h2 {
    font-family: var(--font-serif);
    font-weight: 600;
    color: var(--color-primary-dark);
    font-size: 1.05rem !important;
}

.card-footer {
    background-color: rgba(235, 228, 209, 0.5);
}

/* ============================================================
   Statistikkarten
   ============================================================ */
.stat-card {
    border: 1px solid var(--color-border-light);
    border-top: 3px solid var(--color-accent-light);
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    padding: 1.4rem 1rem 1.2rem;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 500;
    color: var(--color-primary-dark);
    margin-bottom: 0.35rem;
}

.stat-label {
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    color: var(--color-accent);
    font-weight: 600;
}

/* ============================================================
   Tabellen — Katalog-Stil
   ============================================================ */
thead th {
    background: transparent;
    color: var(--color-accent);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--color-accent-light);
    padding: 0.6rem 1rem;
}

tbody tr { border-bottom: 1px solid var(--color-border-light); }

tbody tr:hover { background-color: rgba(195, 163, 93, 0.07); }

tbody td { padding: 0.65rem 1rem; }

/* ============================================================
   Formulare
   ============================================================ */
label {
    font-size: 0.75rem;
    letter-spacing: 0.07em;
    color: #857455;
    font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="url"],
select,
textarea {
    background-color: #fffef9;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.75rem;
    box-shadow: inset 0 1px 2px rgba(31, 26, 16, 0.04);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(195, 163, 93, 0.22), inset 0 1px 2px rgba(31, 26, 16, 0.03);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    border-radius: 8px;
    font-weight: 500;
    letter-spacing: 0.01em;
    padding: 0.5rem 1.1rem;
    transition: background 0.15s, border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: linear-gradient(180deg, #365846, #2a4637);
    border: 1px solid var(--color-primary-dark);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 1px 3px rgba(31, 26, 16, 0.18);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #3e6450, #31503f);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 3px 8px rgba(31, 26, 16, 0.22);
}

.btn-secondary {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-primary-dark);
    box-shadow: 0 1px 2px rgba(31, 26, 16, 0.06);
}

.btn-secondary:hover {
    background-color: #f7f2e4;
    border-color: var(--color-accent-light);
}

.btn-danger {
    background: transparent;
    border: 1px solid #c9a3a3;
    color: var(--color-danger);
}
.btn-danger:hover {
    background: var(--color-danger);
    border-color: var(--color-danger);
}

/* ============================================================
   Badges & Tags
   ============================================================ */
.badge {
    border-radius: 6px;
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    padding: 0.22rem 0.55rem;
}

.tag-chip {
    background: #f7f2e4;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.76rem;
    padding: 0.22rem 0.6rem;
    transition: border-color 0.15s, background 0.15s;
}

.tag-chip:hover {
    border-color: var(--color-accent);
    background: rgba(195, 163, 93, 0.12);
}

/* ============================================================
   Flash-Meldungen — Lesezeichen-Stil
   ============================================================ */
.flash-message {
    border-radius: var(--radius-sm);
    border-left-width: 4px;
    box-shadow: var(--shadow-sm);
    padding: 0.7rem 1.25rem;
}

/* ============================================================
   Suchleiste & Filter
   ============================================================ */
.search-bar input[type="text"] {
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
}

.filter-bar {
    background: rgba(253, 251, 244, 0.7);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

/* ============================================================
   Archiv-Pfad
   ============================================================ */
.archive-path {
    background: transparent;
    border: none;
    border-left: 3px solid var(--color-accent-light);
    border-radius: 0;
    padding: 0.35rem 0.9rem;
    font-style: italic;
    font-family: var(--font-serif);
    font-size: 0.92rem;
}

/* ============================================================
   Metadaten
   ============================================================ */
.metadata-table td:first-child {
    color: #857455;
    font-size: 0.74rem;
    letter-spacing: 0.07em;
}

/* ============================================================
   Workflow-Verlauf
   ============================================================ */
.workflow-timeline::before {
    background: linear-gradient(180deg, var(--color-accent-light), var(--color-border-light));
}

.workflow-entry::before {
    background: var(--color-accent-light);
    border-color: var(--color-surface);
    box-shadow: 0 0 0 1px rgba(151, 120, 58, 0.35);
}

/* ============================================================
   Paginierung
   ============================================================ */
.pagination a,
.pagination span {
    border-radius: 7px;
    border-color: var(--color-border-light);
    min-width: 2rem;
    text-align: center;
}

.pagination a:hover {
    border-color: var(--color-accent-light);
    background: rgba(195, 163, 93, 0.1);
}

.pagination .active span {
    background: var(--color-primary);
    border-color: var(--color-primary-dark);
}

/* ============================================================
   Upload & Dateien
   ============================================================ */
.upload-zone {
    border: 2px dashed var(--color-accent-light);
    background: rgba(253, 251, 244, 0.6);
    border-radius: var(--radius-md);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--color-accent);
    background: rgba(195, 163, 93, 0.08);
}

.upload-zone-icon { color: var(--color-accent); }

.file-list {
    border-color: var(--color-border-light);
    border-radius: var(--radius-md);
}

/* ============================================================
   Login — Abendlicher Lesesaal
   ============================================================ */
.auth-page {
    background-color: #131f18;
    background-image:
        radial-gradient(ellipse 900px 600px at 50% -10%, rgba(62, 100, 80, 0.55), transparent 70%),
        radial-gradient(ellipse 700px 500px at 85% 110%, rgba(195, 163, 93, 0.12), transparent 65%),
        repeating-linear-gradient(90deg, transparent, transparent 120px, rgba(195, 163, 93, 0.025) 120px, rgba(195, 163, 93, 0.025) 122px);
}

.auth-card {
    background: #fdfbf4;
    border: 1px solid rgba(195, 163, 93, 0.4);
    border-top: 4px solid var(--color-accent-light);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 4px 16px rgba(0, 0, 0, 0.3);
    padding: 3rem 2.75rem;
}

.auth-logo h1 {
    font-size: 1.85rem;
    font-weight: 500;
    color: var(--color-primary-dark);
}

.auth-logo h1::after {
    content: '';
    display: block;
    width: 48px;
    height: 2px;
    margin: 0.7rem auto 0;
    background: var(--color-accent-light);
}

.auth-logo p {
    font-size: 0.85rem;
    margin-top: 0.7rem;
}

/* ============================================================
   Galerie & OCR
   ============================================================ */
.image-gallery-item {
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    transition: box-shadow 0.18s, transform 0.18s;
}

.image-gallery-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.ocr-result-text {
    border-radius: var(--radius-sm);
    background: #fffef9;
}

/* ============================================================
   Sonstiges
   ============================================================ */
.sensitive-warning {
    border-radius: var(--radius-md);
    border-left: 4px solid var(--color-warning);
    background: #f8f1da;
}

.divider {
    border-top: 1px solid var(--color-border-light);
}

.sidebar-toggle:hover {
    background: rgba(195, 163, 93, 0.14);
}

/* ============================================================
   Usability & Barrierefreiheit
   ============================================================ */

/* Deutlich sichtbarer Tastatur-Fokus auf allen Bedienelementen */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input[type="radio"]:focus-visible,
input[type="checkbox"]:focus-visible,
input[type="file"]:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.sidebar-nav a:focus-visible {
    outline-color: var(--color-accent-light);
    outline-offset: -2px;
}

/* Größere, leichter klickbare Tabellenzeilen-Links */
tbody td a {
    display: inline-block;
    padding: 0.1rem 0;
}

/* Animationen abschalten, wenn der Nutzer es im System so eingestellt hat */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .stat-card:hover,
    .image-gallery-item:hover {
        transform: none;
    }
}
