/* ============================================================
   FESTMANAGER – Stylesheet  (Dark Mode)
   ============================================================ */

/* ---- CSS-Variablen (Dark Mode Standard) ------------------- */
:root {
    --bg-base:      #080810;
    --bg-surface:   #0f0f1a;
    --bg-card:      #161622;
    --bg-card-hover:#1e1e2e;
    --bg-input:     #1a1a28;
    --border:       rgba(255,255,255,.07);
    --border-focus: rgba(245,158,11,.5);

    --accent:       #f59e0b;
    --accent-dim:   rgba(245,158,11,.15);
    --accent-glow:  rgba(245,158,11,.35);
    --indigo:       #6366f1;
    --indigo-dim:   rgba(99,102,241,.15);
    --green:        #10b981;
    --green-dim:    rgba(16,185,129,.15);
    --red:          #ef4444;
    --red-dim:      rgba(239,68,68,.15);
    --pink:         #ec4899;

    --text:         #e2e8f0;
    --text-muted:   #64748b;
    --text-faint:   #334155;

    --sidebar-w:    260px;
    --topbar-h:     64px;
    --radius:       10px;
    --radius-lg:    16px;
    --transition:   .2s ease;
    --shadow:       0 4px 24px rgba(0,0,0,.4);
    --shadow-lg:    0 8px 40px rgba(0,0,0,.6);

    --font-head:    'Syne', sans-serif;
    --font-body:    'DM Sans', sans-serif;
    --font-mono:    'JetBrains Mono', monospace;
}

/* Verhindert Theme-Flash beim Laden */
html.light-early body,
html.light-early {
    background: #f0f2f5;
}

/* ---- Light Mode Override ---------------------------------- */
body.light {
    --bg-base:      #f0f2f5;
    --bg-surface:   #ffffff;
    --bg-card:      #ffffff;
    --bg-card-hover:#f8f9fb;
    --bg-input:     #f4f5f7;
    --border:       rgba(0,0,0,.09);
    --border-focus: rgba(245,158,11,.5);

    --accent:       #d97706;
    --accent-dim:   rgba(217,119,6,.12);
    --accent-glow:  rgba(217,119,6,.3);
    --indigo:       #4f46e5;
    --indigo-dim:   rgba(79,70,229,.12);
    --green:        #059669;
    --green-dim:    rgba(5,150,105,.12);
    --red:          #dc2626;
    --red-dim:      rgba(220,38,38,.12);
    --pink:         #db2777;

    --text:         #111827;
    --text-muted:   #6b7280;
    --text-faint:   #d1d5db;

    --shadow:       0 4px 24px rgba(0,0,0,.08);
    --shadow-lg:    0 8px 40px rgba(0,0,0,.14);
}

body.light .sidebar {
    background: #ffffff;
    border-right-color: rgba(0,0,0,.08);
}

body.light .topbar {
    background: rgba(240,242,245,.9);
    border-bottom-color: rgba(0,0,0,.08);
}

body.light .nav-item:hover {
    background: #f0f2f5;
}

body.light .logo-text {
    color: var(--accent);
}

body.light input[type="text"],
body.light input[type="number"],
body.light input[type="email"],
body.light input[type="tel"],
body.light input[type="date"],
body.light input[type="search"],
body.light input[type="datetime-local"],
body.light select,
body.light textarea {
    background: #f4f5f7;
    color: #111827;
    border-color: rgba(0,0,0,.12);
}

body.light .modal {
    background: #ffffff;
}

body.light .modal-backdrop {
    background: rgba(0,0,0,.5);
}

body.light .toast {
    background: #ffffff;
    border-color: rgba(0,0,0,.1);
    color: #111827;
}

body.light ::-webkit-scrollbar-track { background: #f0f2f5; }
body.light ::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); }

/* ---- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    background: var(--bg-base);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #fbbf24; }

/* ---- Scrollbar -------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    font-size: 26px;
    line-height: 1;
}

.logo-text {
    font-family: var(--font-head);
    font-size: 18px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -.5px;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.nav-group { display: flex; flex-direction: column; gap: 2px; }

.nav-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 10px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
}

.nav-item i { width: 16px; text-align: center; font-size: 14px; }

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text);
}

.nav-item.active {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-faint);
}

/* ============================================================
   MAIN WRAPPER
   ============================================================ */
.main-wrapper {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---- Topbar ----------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-h);
    background: rgba(8,8,16,.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    z-index: 100;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
}

.page-title {
    font-family: var(--font-head);
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    flex: 1;
}

.topbar-firma {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition);
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
}

/* ---- Content Area ----------------------------------------- */
.content {
    flex: 1;
    padding: 28px;
}

/* ============================================================
   CARDS & STATS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: transform var(--transition), box-shadow var(--transition);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    color: var(--text);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent);
    opacity: 0;
    transition: opacity var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card:hover::before { opacity: 1; }

.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius);
    display: grid; place-items: center;
    font-size: 18px;
    flex-shrink: 0;
}

.stat-icon.amber  { background: var(--accent-dim);  color: var(--accent); }
.stat-icon.indigo { background: var(--indigo-dim);  color: var(--indigo); }
.stat-icon.green  { background: var(--green-dim);   color: var(--green); }
.stat-icon.red    { background: var(--red-dim);     color: var(--red); }

.stat-body {}
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value {
    font-family: var(--font-head);
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
}
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   TABLES
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}

.card-title {
    font-family: var(--font-head);
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.card-body { padding: 22px; }

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

thead tr { border-bottom: 1px solid var(--border); }

th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255,255,255,.04);
    color: var(--text);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
    transition: background var(--transition);
}

tbody tr:hover { background: var(--bg-card-hover); }

.mono { font-family: var(--font-mono); font-size: 12px; }

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .3px;
}

.badge-amber  { background: var(--accent-dim);  color: var(--accent); }
.badge-indigo { background: var(--indigo-dim);  color: var(--indigo); }
.badge-green  { background: var(--green-dim);   color: var(--green); }
.badge-red    { background: var(--red-dim);     color: var(--red); }
.badge-gray   { background: rgba(100,116,139,.15); color: var(--text-muted); }
.badge-pink   { background: rgba(236,72,153,.15);  color: var(--pink); }

/* Lagerbestand-Indikatoren */
.stock-ok      { color: var(--green); font-weight: 600; }
.stock-warn    { color: var(--accent); font-weight: 600; }
.stock-critical{ color: var(--red); font-weight: 600; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: none;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #000;
    font-weight: 600;
}
.btn-primary:hover { background: #fbbf24; color: #000; box-shadow: 0 0 18px var(--accent-glow); }

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--text-faint); }

.btn-danger {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(239,68,68,.25);
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-card); color: var(--text); }

.btn-icon {
    padding: 7px 8px;
    font-size: 13px;
}

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: var(--text-muted);
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="search"],
select,
textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 13.5px;
    padding: 9px 13px;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea { resize: vertical; min-height: 90px; }

.form-hint { font-size: 11px; color: var(--text-muted); }

.input-group {
    display: flex;
    align-items: stretch;
}
.input-group input { border-radius: var(--radius) 0 0 var(--radius); flex: 1; }
.input-group .btn  { border-radius: 0 var(--radius) var(--radius) 0; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
}

.modal-backdrop.open .modal { transform: translateY(0); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-family: var(--font-head);
    font-size: 15px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: color var(--transition), background var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--bg-input); }

.modal-body { padding: 22px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
}

/* ============================================================
   ALERTS & TOASTS
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
}

.alert-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(16,185,129,.25); }
.alert-danger   { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(239,68,68,.25); }
.alert-warning  { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(245,158,11,.25); }

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 18px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
    animation: slideIn .25s ease forwards;
    min-width: 260px;
    max-width: 380px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red);   }
.toast.info    { border-left: 3px solid var(--indigo); }

@keyframes slideIn {
    from { transform: translateX(40px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.mt-4         { margin-top: 16px; }
.mt-6         { margin-top: 24px; }
.mb-4         { margin-bottom: 16px; }
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-indigo  { color: var(--indigo); }
.text-amber   { color: var(--accent); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.font-mono    { font-family: var(--font-mono); }
.font-head    { font-family: var(--font-head); }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.d-none       { display: none !important; }

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 36px; margin-bottom: 12px; opacity: .4; }
.empty-state p           { font-size: 14px; }

/* Ladeanimation */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   SEARCH & FILTER BAR
   ============================================================ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 180px;
    max-width: 320px;
}

.search-box i {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
    pointer-events: none;
}

.search-box input {
    padding-left: 34px;
}

/* ============================================================
   INVOICE / PRINT
   ============================================================ */
@media print {
    .sidebar, .topbar, .btn, .modal-backdrop { display: none !important; }
    .main-wrapper { margin-left: 0; }
    body { background: #fff; color: #000; }
    .card { border: 1px solid #ddd; box-shadow: none; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 150;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .content {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .modal { max-width: 100%; }

    .topbar-firma { display: none; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-value { font-size: 20px; }
}
