/**
 * style.css
 * Basis-Layout & Theme. Es gibt zwei Themes, die der Benutzer über den
 * Button oben rechts (bzw. auf der Login-Seite) frei umschalten kann -
 * die Wahl wird im Browser gemerkt (localStorage). Ohne gespeicherte Wahl
 * wird die Systemeinstellung des Betriebssystems/Browsers übernommen.
 *
 * - Hell (Standard): laut Seitenaufbau_Sidebar.xlsx, Reiter "Basis"
 *   (Primärfarbe #f5f5f5, Akzent/Selektierbar #08110d)
 * - Dunkel: angelehnt an dispo.pappenheimer-trading.de (dunkles Grau/Schwarz
 *   mit grünem Akzent)
 *
 * Alle Farben liegen als CSS-Variablen vor - zum Anpassen nur die
 * Blöcke unten unter ":root" bzw. ':root[data-theme="dark"]' ändern.
 *
 * @version 0.5.0
 */

:root {
    /* Helles Theme (Standard) */
    --bg-app: #f5f5f5;
    --bg-content: #ffffff;
    --bg-sidebar: #1c1f1e;
    --bg-sidebar-active: #08110d;
    --bg-surface-muted: #f0f0ef;
    --text-body: #202322;
    --text-heading: #202322;
    --text-muted: #6b6f6d;
    --text-sidebar: #d6dad8;
    --text-sidebar-muted: #8a908d;
    --text-sidebar-active: #ffffff;
    --accent: #08110d;
    --accent-contrast: #ffffff;
    --border: #e3e3e3;
    --border-strong: #cfcfcf;
    --danger-bg: #fbe9e7;
    --danger-text: #b3261e;
    --danger-border: #f3c2bc;
    --success-bg: #e8f5e9;
    --success-text: #1e7d34;
    --success-border: #bfe3c4;

    --sidebar-width: 260px;
    --sidebar-width-collapsed: 64px;
    --font-base: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

/* Dunkles Theme - angelehnt an dispo.pappenheimer-trading.de */
:root[data-theme="dark"] {
    --bg-app: #0b0c0e;
    --bg-content: #0b0c0e;
    --bg-sidebar: #151719;
    --bg-sidebar-active: #21301f;
    --bg-surface-muted: #1b1e21;
    --text-body: #d7dad8;
    --text-heading: #f4f5f2;
    --text-muted: #9aa0a0;
    --text-sidebar: #b8bcc0;
    --text-sidebar-muted: #7c8280;
    --text-sidebar-active: #7adb5d;
    --accent: #7adb5d;
    --accent-contrast: #0b0c0e;
    --border: #2a2d30;
    --border-strong: #3a3e42;
    --danger-bg: #3a1f1c;
    --danger-text: #ff8a80;
    --danger-border: #5c2a25;
    --success-bg: #17301c;
    --success-text: #7adb5d;
    --success-border: #244a2b;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-base);
    background: var(--bg-app);
    color: var(--text-body);
}

a { color: inherit; }

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

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    transition: width 0.15s ease;
    overflow-x: hidden;
}

.app-shell.sidebar-collapsed .sidebar {
    width: var(--sidebar-width-collapsed);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    white-space: nowrap;
}

.sidebar__brand-text { display: flex; align-items: center; min-width: 0; }
.sidebar__logo { height: 32px; width: auto; max-width: 170px; object-fit: contain; }

.app-shell.sidebar-collapsed .sidebar__brand-text { display: none; }

.sidebar__toggle {
    background: transparent;
    border: none;
    color: var(--text-sidebar);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
}

.sidebar__menu, .sidebar__submenu {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Akkordeon: Unterkategorien sind standardmäßig zugeklappt und werden nur
   bei .is-expanded am jeweiligen <li> eingeblendet. */
.sidebar__submenu {
    max-height: 0;
    overflow: hidden;
}
.sidebar__item.is-expanded > .sidebar__submenu {
    max-height: none;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 16px;
    text-decoration: none;
    color: var(--text-sidebar);
    white-space: nowrap;
    background: transparent;
    border: none;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.sidebar__icon { display: inline-flex; flex-shrink: 0; }
.sidebar__icon-svg { width: 17px; height: 17px; display: block; }
.sidebar__label { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }

.sidebar__link--0 { font-weight: 600; font-size: 0.92em; }
.sidebar__link--1 { padding-left: 30px; font-size: 0.9em; color: var(--text-sidebar-muted); }
.sidebar__link--1 .sidebar__icon-svg { width: 15px; height: 15px; }
.sidebar__link--2 { padding-left: 46px; font-size: 0.88em; color: var(--text-sidebar-muted); }
.sidebar__link--2 .sidebar__icon-svg { width: 14px; height: 14px; }

.sidebar__link:hover {
    background: rgba(255,255,255,0.06);
}

.sidebar__link.is-active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
}

/* Pfeil/Chevron bei aufklappbaren Einträgen (reines CSS-Dreieck, dreht sich beim Aufklappen) */
.sidebar__chevron {
    flex-shrink: 0;
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 5px solid currentColor;
    opacity: 0.6;
    transition: transform 0.15s ease;
}
.sidebar__item.is-expanded > .sidebar__toggle-btn .sidebar__chevron {
    transform: rotate(90deg);
}

/* Sidebar komplett eingeklappt (Icon-Leiste): nur Icons zeigen, Akkordeon-
   Zustand spielt dann keine Rolle mehr. */
.app-shell.sidebar-collapsed .sidebar__label,
.app-shell.sidebar-collapsed .sidebar__chevron,
.app-shell.sidebar-collapsed .sidebar__submenu {
    display: none;
}
.app-shell.sidebar-collapsed .sidebar__link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--bg-content);
    border-bottom: 1px solid var(--border);
}

.topbar__title { margin: 0; font-size: 1.25rem; color: var(--text-heading); }

.topbar__user { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }
.topbar__link { text-decoration: underline; }

.content {
    padding: 24px;
    background: var(--bg-content);
    color: var(--text-body);
    flex: 1;
}

.content h2, .content h3 { color: var(--text-heading); }

/* ---------- Theme-Umschalter ---------- */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-surface-muted);
    color: var(--text-body);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0;
}
.theme-toggle:hover { border-color: var(--border-strong); }

.theme-toggle__icon--moon { display: none; }
:root[data-theme="dark"] .theme-toggle__icon--sun { display: none; }
:root[data-theme="dark"] .theme-toggle__icon--moon { display: inline; }

.theme-toggle--login {
    position: absolute;
    top: 16px;
    right: 16px;
}

/* ---------- Formulare & Tabellen (für Benutzerverwaltung etc.) ---------- */
.form-field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; max-width: 420px; }
.form-field label { font-weight: 600; font-size: 0.9rem; color: var(--text-body); }
.form-field input, .form-field select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    background: var(--bg-content);
    color: var(--text-body);
}

.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

.btn {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 999px;
    border: none;
    background: var(--accent);
    color: var(--accent-contrast);
    cursor: pointer;
    font-size: 0.95rem;
    text-decoration: none;
    font-weight: 600;
}
.btn:hover { opacity: 0.9; }
.btn--secondary { background: var(--bg-surface-muted); color: var(--text-body); border: 1px solid var(--border-strong); }

.data-table { border-collapse: collapse; width: 100%; margin-top: 12px; }
.data-table th, .data-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}
.data-table th { background: var(--bg-surface-muted); color: var(--text-heading); }

.alert { padding: 10px 14px; border-radius: 4px; margin-bottom: 16px; font-size: 0.92rem; }
.alert--error { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }
.alert--success { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }

.placeholder-box {
    border: 1px dashed var(--border);
    border-radius: 6px;
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
}

/* ---------- Filterleisten & Datentabellen mit vielen Spalten ---------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
    margin-bottom: 12px;
}
.filter-bar .form-field { margin-bottom: 0; }
.filter-bar .checkbox-row { margin-bottom: 0; }

.muted-note { color: var(--text-muted); font-size: 0.85rem; }

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

/* Umrahmter Block für eine Such-/Filterleiste inkl. Überschrift (z.B.
   "Artikel suchen"), damit sie sich optisch von der Ergebnistabelle
   darunter abhebt. */
.search-panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px 20px;
    margin-bottom: 16px;
}
.search-panel h2 { margin-top: 0; }
.search-panel .filter-bar { margin-bottom: 0; }

/* Kompaktere Variante von .data-table (eine Schriftgröße kleiner, Kopf- und
   Datenzeilen) - für Listen mit vielen Spalten wie Artikeldaten. */
.data-table--compact th,
.data-table--compact td {
    font-size: 0.8rem;
    padding: 6px 8px;
}

.data-table th.col-checkbox,
.data-table td.col-checkbox {
    width: 28px;
    text-align: center;
}

/* ---------- Badges (u.a. Beschaffung > Preischeck, seit v0.5.0) ---------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.78rem;
    background: var(--bg-surface-muted);
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
}
.badge--success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.badge--danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }

/* ---------- Login ---------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-sidebar);
}
.login-box {
    position: relative;
    background: var(--bg-content);
    padding: 32px;
    border-radius: 8px;
    width: 100%;
    max-width: 360px;
}
.login-box__logo { display: block; height: 40px; width: auto; margin: 0 auto 20px; }
