/* BAY-Food WWS – globale Styles */

:root {
  --color-brand: #638f1c;        /* Logo-Grün */
  --color-brand-dark: #4e7016;
  --color-brand-light: #eef5e2;
  --color-warn: #f59e0b;         /* nur für Warnungen, keine Markenfarbe */
  --color-dark: #143257;         /* Logo-Marineblau */
  --color-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-surface: #ffffff;
  --color-bg: #f8fafc;
  --color-sidebar: #122c4d;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --shadow-xl: 0 24px 60px rgba(0,0,0,0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-dark);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbars */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* Focus ring */
input:focus, select:focus, textarea:focus {
  outline: none !important;
  border-color: var(--color-brand) !important;
  box-shadow: 0 0 0 3px rgba(99,143,28,0.15) !important;
}

/* Table hover */
tbody tr { transition: background 0.1s; cursor: default; }
tbody tr:hover { background: #fafafa !important; }

/* Sticky table headers */
.sticky-head thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f9fafb;
  backdrop-filter: blur(8px);
}

/* Card */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }

/* Smooth animations */
button { transition: all 0.15s ease; }
button:active { transform: scale(0.97); }

/* Badge pill */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

/* Ladebalken des Splash-Screens */
@keyframes lb {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar { display: none !important; }
  .sidebar.open {
    display: flex !important;
    position: fixed !important;
    z-index: 5000 !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: 280px !important;
    box-shadow: var(--shadow-xl);
  }
  .sidebar-overlay {
    display: block !important;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 4999;
    backdrop-filter: blur(2px);
  }
  .mobile-header { display: flex !important; }
  .main-content { padding: 16px !important; padding-top: 72px !important; }
  .kpi-grid-4 { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .kpi-grid-3 { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .grid-2 { grid-template-columns: 1fr !important; }
  .dash-grid { grid-template-columns: 1fr !important; }
  .hide-mobile { display: none !important; }
  th, td { padding: 8px 10px !important; font-size: 12px !important; }
  h2 { font-size: 20px !important; }

  /* Auf dem Handy dürfen die Schaltflächen neben der Überschrift umbrechen.
     Ohne das laufen sie aus dem Bild und „Neue Bestellung" ist nicht erreichbar. */
  .view-head { flex-wrap: wrap !important; gap: 10px !important; align-items: flex-start !important; }
  .view-head > div { flex-wrap: wrap !important; }
  .view-head > div > button { flex: 1 1 auto; justify-content: center; }

  /* Die Plantafel der Abwesenheiten bleibt eng: 31 Tage nebeneinander. Die
     allgemeine Regel für Tabellen oben würde jede Zelle aufpolstern. */
  .abw-plan th, .abw-plan td { padding: 0 !important; font-size: 10.5px !important; }
  .abw-plan td:first-child, .abw-plan th:first-child { padding: 0 8px !important; font-size: 12px !important; min-width: 96px !important; max-width: 110px !important; }

  /* Nichts darf breiter sein als der Bildschirm – lange Nummern, IBAN, Adressen */
  .main-content { overflow-x: hidden !important; }
  .main-content input, .main-content select, .main-content textarea { max-width: 100% !important; }
}

/* ── Berichte: Liste der fertigen Berichte ────────────────────────────────
   Am Rechner links, auf schmalem Bildschirm oben als waagerechte Leiste. */
@media (max-width: 1000px) {
  .ber-raster { grid-template-columns: 1fr !important; }
  .ber-nav { position: static !important; max-height: 240px !important; }
}

/* ── Einstellungen: Bereichsleiste ─────────────────────────────────────────
   Am Rechner steht die Bereichsliste links und bleibt beim Scrollen stehen.
   Wird das Fenster schmal, legt sie sich als waagerechte Leiste darüber –
   sieben Bereiche untereinander würden sonst den halben Bildschirm füllen,
   bevor überhaupt etwas Einstellbares käme. */
@media (max-width: 1000px) {
  .einst-raster { grid-template-columns: 1fr !important; }
  .einst-nav {
    position: static !important;
    display: flex !important;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .einst-nav::-webkit-scrollbar { display: none; }
  .einst-nav button { width: auto !important; white-space: nowrap; margin-bottom: 0 !important; }
  /* Der senkrechte Streifen des aktiven Eintrags wird zum Unterstrich. */
  .einst-nav button > span {
    top: auto !important; bottom: 2px !important;
    left: 10px !important; right: 10px !important;
    transform: none !important;
    width: auto !important; height: 3px !important;
    border-radius: 3px 3px 0 0 !important;
  }
}

/* ── Buchhaltung ───────────────────────────────────────────────────────────
   Die Buchungsmaske steht am Rechner zweispaltig: links die Eingabe, rechts
   der Satz, der daraus entsteht. Auf schmalem Bildschirm rutscht der Satz
   unter die Eingabe – nebeneinander wäre beides zu schmal zum Lesen. */
@media (max-width: 1100px) {
  .bu-maske { grid-template-columns: 1fr !important; }
}

/* Der Umschalter zwischen den Bereichen. Zwei gleich breite Spalten; die
   Beschriftung darf nicht umbrechen, sonst wird die Leiste hoch und die
   beiden Knöpfe unterschiedlich groß. */
.bereichs-schalter button { line-height: 1.35; }
@media (max-width: 400px) {
  .bereichs-schalter button { font-size: 10px !important; padding: 7px 2px !important; }
}

/* ── Nachrichten-Fach ─────────────────────────────────────────────────────
   Am Rechner neben der Seitenleiste, auf dem Handy unter der Kopfleiste über
   die ganze Breite. Die Glocke in der Seitenleiste braucht es auf dem Handy
   nicht – dort sitzt sie in der Kopfleiste. */
.nachrichten-fach { top: 14px; left: 274px; width: 420px; max-width: calc(100vw - 290px); max-height: calc(100vh - 28px); max-height: calc(100dvh - 28px); }
@media (max-width: 768px) {
  .nachrichten-fach { top: 64px !important; left: 8px !important; right: 8px !important; width: auto !important; max-width: none !important; max-height: calc(100vh - 76px) !important; max-height: calc(100dvh - 76px) !important; }
  .glocke-seite { display: none !important; }
}

/* ── Artikelseite (js/views/Artikelseite.js) ───────────────────────────────
   Am breiten Bildschirm links der Artikel mit Reitern, rechts „Auf einen
   Blick" und die letzten Bewegungen; darunter einspaltig. */
.artikel-raster { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
@media (max-width: 1200px) {
  .artikel-raster { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
  .artikel-kacheln { grid-template-columns: 1fr 1fr !important; }
  .stammdaten-raster { grid-template-columns: 1fr !important; }
  .felder-3, .felder-2 { grid-template-columns: 1fr !important; gap: 0 !important; }
}

/* Foto vorbereiten (Artikel → Foto hochladen): auf schmalen Bildschirmen untereinander */
@media (max-width: 760px) { .foto-raster { grid-template-columns: 1fr !important; } }
