/* ============================================================
   Imker-Tool – Design 2.0
   Sidebar-Layout, Mobile-First, Dark Mode via prefers-color-scheme
   ============================================================ */

:root {
    --color-accent: #e8a917;
    --color-accent-dark: #c78d0a;
    --color-accent-soft: #fdf3dd;
    --color-bg: #f6f4ef;
    --color-surface: #ffffff;
    --color-surface-2: #faf8f4;
    --color-text: #262319;
    --color-text-muted: #7d7668;
    --color-border: #e8e3d7;
    --color-success: #2e7d32;
    --color-success-bg: #e8f5e9;
    --color-warn: #c77700;
    --color-warn-bg: #fff4e0;
    --color-error: #b3261e;
    --color-error-bg: #fdecea;
    --color-info: #2b5fa5;
    --color-info-bg: #e9f0fa;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(30, 25, 10, 0.06);
    --shadow-md: 0 4px 16px rgba(30, 25, 10, 0.08);
    --sidebar-w: 230px;
}

/* Dunkles Schema: automatisch nach Systemeinstellung ... */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="hell"]) {
        --color-accent: #f0b429;
        --color-accent-dark: #d99e13;
        --color-accent-soft: #3a3220;
        --color-bg: #17150f;
        --color-surface: #211e16;
        --color-surface-2: #2a261c;
        --color-text: #ece7db;
        --color-text-muted: #a49b88;
        --color-border: #383325;
        --color-success: #7bc67e;
        --color-success-bg: #1e3320;
        --color-warn: #f0b429;
        --color-warn-bg: #38300f;
        --color-error: #f2857c;
        --color-error-bg: #3c1f1c;
        --color-info: #8ab4f8;
        --color-info-bg: #1c2a3d;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    }
}

/* ... oder fest gewaehlt in den persoenlichen Einstellungen */
:root[data-theme="dunkel"] {
    --color-accent: #f0b429;
    --color-accent-dark: #d99e13;
    --color-accent-soft: #3a3220;
    --color-bg: #17150f;
    --color-surface: #211e16;
    --color-surface-2: #2a261c;
    --color-text: #ece7db;
    --color-text-muted: #a49b88;
    --color-border: #383325;
    --color-success: #7bc67e;
    --color-success-bg: #1e3320;
    --color-warn: #f0b429;
    --color-warn-bg: #38300f;
    --color-error: #f2857c;
    --color-error-bg: #3c1f1c;
    --color-info: #8ab4f8;
    --color-info-bg: #1c2a3d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
}

:root[data-theme="hell"] { color-scheme: light; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    font-size: 15px;
}

a { color: var(--color-accent-dark); }

h1, h2, h3 { line-height: 1.25; margin-top: 0; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }

/* ---------- App-Grundgeruest: Sidebar + Inhalt ---------- */

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

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 50;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 14px;
    font-weight: 700;
    font-size: 16px;
    color: var(--color-accent-dark);
}
.sidebar__brand .logo {
    width: 34px; height: 34px;
    background: var(--color-accent);
    color: #fff;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}

.sidebar__nav { flex: 1; overflow-y: auto; padding: 6px 10px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--color-text);
    font-size: 14.5px;
    transition: background 0.12s ease;
}
.nav-link:hover { background: var(--color-surface-2); }
.nav-link.is-active {
    background: var(--color-accent-soft);
    color: var(--color-accent-dark);
    font-weight: 600;
}
.nav-link .icon { width: 22px; text-align: center; flex-shrink: 0; }

.sidebar__footer {
    padding: 12px 14px;
    border-top: 1px solid var(--color-border);
    font-size: 13px;
}
.sidebar__user { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar__user .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content {
    flex: 1;
    min-width: 0;
    padding: 26px clamp(16px, 4vw, 40px) 60px;
    max-width: 1080px;
}

/* Mobile: Sidebar wird zum Overlay */
.menu-toggle { display: none; }

@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: var(--shadow-md);
        height: 100dvh;
    }
    .sidebar.is-open { transform: translateX(0); }

    .menu-toggle {
        display: flex;
        align-items: center;
        gap: 10px;
        position: sticky;
        top: 0;
        z-index: 40;
        background: color-mix(in srgb, var(--color-bg) 88%, transparent);
        backdrop-filter: blur(8px);
        padding: 12px 16px;
        margin: -26px calc(-1 * clamp(16px, 4vw, 40px)) 18px;
        border-bottom: 1px solid var(--color-border);
        font-weight: 700;
        color: var(--color-accent-dark);
    }
    .menu-toggle button {
        background: none; border: none; font-size: 22px; cursor: pointer;
        color: var(--color-text); padding: 4px 8px;
    }
    .sidebar-backdrop {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.35);
        z-index: 45;
    }
    .sidebar-backdrop.is-open { display: block; }
}

/* ---------- Bausteine ---------- */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 18px;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat .label { color: var(--color-text-muted); font-size: 13px; margin-top: 2px; }

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 14px;
    border: 1px solid transparent;
}
.flash--success { background: var(--color-success-bg); color: var(--color-success); }
.flash--error { background: var(--color-error-bg); color: var(--color-error); }
.flash--info { background: var(--color-info-bg); color: var(--color-info); }
.flash--warn { background: var(--color-warn-bg); color: var(--color-warn); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: 10px;
    border: none;
    background: var(--color-accent);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    font-size: 14.5px;
    font-weight: 600;
    transition: background 0.12s ease, transform 0.05s ease;
    min-height: 42px;
}
.btn:hover { background: var(--color-accent-dark); }
.btn:active { transform: scale(0.98); }
.btn--ghost {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    font-weight: 500;
}
.btn--ghost:hover { background: var(--color-surface-2); }
.btn--danger { background: var(--color-error); }
.btn--danger:hover { background: #8f1d17; }
.btn--sm { padding: 6px 12px; font-size: 13px; min-height: 34px; }

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

.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
th { color: var(--color-text-muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:hover { background: var(--color-surface-2); }
tbody tr:last-child td { border-bottom: none; }

/* ---------- Formulare ---------- */

.form-group { margin-bottom: 15px; }
label { display: block; font-size: 13px; font-weight: 550; color: var(--color-text-muted); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=file], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--color-surface);
    color: var(--color-text);
    min-height: 42px;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 22%, transparent);
}
textarea { resize: vertical; min-height: 84px; }

.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 170px; }

.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    white-space: nowrap;
}
.badge--hoch { background: var(--color-error-bg); color: var(--color-error); border-color: transparent; }
.badge--mittel { background: var(--color-warn-bg); color: var(--color-warn); border-color: transparent; }
.badge--niedrig { background: var(--color-success-bg); color: var(--color-success); border-color: transparent; }

/* ---------- Leerer Zustand ---------- */

.empty {
    text-align: center;
    padding: 36px 20px;
    color: var(--color-text-muted);
}
.empty .big { font-size: 40px; margin-bottom: 10px; }
.empty p { margin: 0 0 16px; }

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

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--color-accent) 14%, transparent), transparent 45%),
        var(--color-bg);
    padding: 20px;
}
.login-card { width: 100%; max-width: 380px; padding: 30px; }
.login-card h1 { text-align: center; margin-bottom: 22px; }

/* ---------- Modals ---------- */

.modal-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    align-items: center; justify-content: center;
    z-index: 100;
    padding: 16px;
}
.modal-backdrop.is-open { display: flex; }
.modal-box {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 460px;
    width: 100%;
    box-shadow: var(--shadow-md);
    animation: modal-in 0.18s ease;
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

/* ---------- Volk-Kacheln (Schnellerfassung) ---------- */

.volk-kachel-leiste {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 2px 2px 12px;
    margin-bottom: 14px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}
.volk-kachel {
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: 12px 20px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    text-decoration: none;
    color: var(--color-text);
    white-space: nowrap;
    font-size: 14.5px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.12s ease, transform 0.08s ease;
}
.volk-kachel:hover { border-color: var(--color-accent); }
.volk-kachel:active { transform: scale(0.97); }
.volk-kachel.is-aktiv {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent-dark);
    font-weight: 650;
}
.volk-kachel__stand { display: block; font-size: 11px; opacity: 0.8; font-weight: 400; }

/* ---------- Regler / Segmented Control ---------- */

.regler-gruppe { margin-bottom: 20px; }
.regler-gruppe > label { font-weight: 650; color: var(--color-text); margin-bottom: 9px; font-size: 14px; }
.segmented { display: flex; flex-wrap: wrap; gap: 8px; }
.segmented input[type=radio] {
    position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none;
}
.segmented label {
    padding: 11px 18px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    cursor: pointer;
    font-size: 14.5px;
    background: var(--color-surface);
    color: var(--color-text);
    margin: 0;
    user-select: none;
    font-weight: 500;
    transition: all 0.1s ease;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
}
.segmented label:active { transform: scale(0.96); }
.segmented input[type=radio]:checked + label {
    background: var(--color-accent);
    border-color: var(--color-accent-dark);
    color: #fff;
    font-weight: 650;
}
.segmented input[type=radio]:focus-visible + label {
    outline: 2px solid var(--color-accent-dark);
    outline-offset: 2px;
}

/* ---------- Karte (Beecomm) ---------- */

#beecomm-karte {
    height: 480px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    z-index: 1;
}
@media (max-width: 860px) { #beecomm-karte { height: 380px; } }
.beecomm-symbol { background: none; border: none; }
.plz-karte-legende { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; }
.plz-karte-legende__punkt { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ---------- Balkendiagramm (Ertrag-Statistik, reines CSS) ---------- */

.balken-chart { display: flex; flex-direction: column; gap: 8px; }
.balken-zeile { display: grid; grid-template-columns: 110px 1fr 70px; align-items: center; gap: 10px; font-size: 13.5px; }
.balken-spur { background: var(--color-surface-2); border-radius: 6px; height: 22px; overflow: hidden; }
.balken {
    height: 100%;
    background: linear-gradient(90deg, var(--color-accent), var(--color-accent-dark));
    border-radius: 6px;
    min-width: 3px;
    transition: width 0.4s ease;
}
.balken-wert { text-align: right; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

/* ---------- Drucken (Bestandsbuch) ---------- */

@media print {
    .sidebar, .menu-toggle, .sidebar-backdrop, .no-print, .btn { display: none !important; }
    .content { padding: 0; max-width: none; }
    body { background: #fff; color: #000; font-size: 12px; }
    .card { border: none; box-shadow: none; padding: 0; }
    th, td { padding: 6px 8px; }
}

.text-muted { color: var(--color-text-muted); font-size: 13px; }
.thumb { width: 90px; height: 90px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--color-border); }
