/* ==========================================================================
   FFO Küchen-/Kassensystem – Basis-Stylesheet
   Design-Familie mit FFO_Homepage (siehe D:\KI\Server\INFRASTRUCTURE.md 13.8):
   reduziert, Apple-inspiriert, Feuerwehr-Rot als Akzent. Ergänzt um ein
   touch-taugliches Layout für Kasse/Küche-Terminals (iPad/Smartphone).
   ========================================================================== */

:root {
  --color-bg: #ffffff;
  --color-bg-alt: #f5f5f7;
  --color-text: #1d1d1f;
  --color-text-muted: #6e6e73;
  --color-border: #d2d2d7;
  --color-red: #af2b1e;
  --color-red-dark: #8f2118;
  --color-red-light: #c73427;
  --color-black: #0b0b0c;

  /* Status-/Signalfarben für Verkaufs-/Bestellstatus (Kasse, Küchenanzeige) */
  --color-green: #1f8a4c;
  --color-green-bg: rgba(31, 138, 76, 0.12);
  --color-orange: #b9770e;
  --color-orange-bg: rgba(185, 119, 14, 0.12);
  --color-blue: #2b6cb0;
  --color-blue-bg: rgba(43, 108, 176, 0.12);

  --nav-height: 64px;
  --max-width: 1400px;
  --radius: 18px;
  --radius-sm: 12px;

  /* Mindestgröße für tippbare Elemente an Kasse/Küche (Touch, Handschuhe etc.) */
  --touch-target-min: 56px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 12px);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  /* iOS: -webkit-tap-highlight entfernen, eigenes :active-Feedback nutzen */
  -webkit-tap-highlight-color: transparent;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: clamp(20px, 5vw, 48px);
}

/* ---------------------------------------------------------------- Typografie */

h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0;
}

h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); }
h2 { font-size: clamp(1.9rem, 4vw, 3rem); }
h3 { font-size: clamp(1.3rem, 2.4vw, 1.7rem); }

p {
  margin: 0;
  line-height: 1.6;
  color: var(--color-text-muted);
  font-size: clamp(1rem, 1.4vw, 1.15rem);
}

.eyebrow {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-red);
  margin-bottom: 12px;
}

/* -------------------------------------------------------------------- Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch-target-min);
  padding: 13px 26px;
  border: 1.5px solid transparent;
  border-radius: 980px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.25s var(--ease);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--color-red);
  color: #fff;
}

@media (hover: hover) {
  .btn--primary:hover {
    background: var(--color-red-dark);
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(175, 43, 30, 0.28);
  }
}

.btn--secondary {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}

@media (hover: hover) {
  .btn--secondary:hover {
    border-color: var(--color-text);
    transform: translateY(-2px);
  }
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
}

.btn--danger {
  background: #c0392b;
  color: #fff;
}

.btn--full { width: 100%; }

.btn--icon {
  min-height: 40px;
  min-width: 40px;
  padding: 8px;
  font-size: 1.1rem;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ---------------------------------------------------------------------- Cards */

.card {
  display: block;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: clamp(28px, 4vw, 40px);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

a.card {
  cursor: pointer;
}

@media (hover: hover) {
  a.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
  }
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.badge--warten { background: var(--color-orange-bg); color: var(--color-orange); }
.badge--laeuft { background: var(--color-blue-bg); color: var(--color-blue); }
.badge--fertig { background: var(--color-green-bg); color: var(--color-green); }
.badge--fehler { background: rgba(192, 57, 43, 0.12); color: #c0392b; }

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.field input,
.field select,
.field textarea {
  min-height: var(--touch-target-min);
  padding: 12px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--color-red);
  outline-offset: 1px;
}

/* ------------------------------------------------------------ Admin-Bereich */
/* Eigene Klassen für /admin/*, NICHT .container wiederverwenden (dessen
   max-width ist für Admin-Tabellen zu schmal), siehe INFRASTRUCTURE.md 13.7. */

.admin-page {
  padding-top: calc(var(--nav-height) + 32px);
  padding-bottom: 40px;
}

.admin-shell {
  display: flex;
  min-height: 100svh;
  min-height: 92vh;
}

.admin-sidebar {
  flex: 0 0 240px;
  border-right: 1px solid var(--color-border);
  padding: 24px 16px;
}

.admin-sidebar__group {
  margin-bottom: 20px;
}

.admin-sidebar__title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 0 12px 8px;
}

.admin-sidebar a {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--color-text);
}

@media (hover: hover) {
  .admin-sidebar a:hover { background: var(--color-bg-alt); }
}

.admin-sidebar a.is-active {
  background: var(--color-bg-alt);
  color: var(--color-red);
}

.admin-main {
  flex: 1 1 auto;
  padding: 28px clamp(16px, 3vw, 40px);
  max-width: 1200px;
}

.admin-page__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* Eigener, kompakter Überschrift-Maßstab fürs Admin-Dashboard, analog zur
   .legal-Skalierung oben — die Basis-h1 ist auf Marketing-Seitengröße
   (bis 4.5rem) ausgelegt, das wäre in einer Dashboard-Kopfzeile zu groß. */
.admin-page__header h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.admin-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
}

.admin-table th {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-notice {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.admin-notice--error {
  background: rgba(192, 57, 43, 0.08);
  border-color: rgba(192, 57, 43, 0.3);
  color: #c0392b;
}

.admin-notice--success {
  background: var(--color-green-bg);
  border-color: rgba(31, 138, 76, 0.3);
  color: var(--color-green);
}

@media (max-width: 900px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { flex: none; border-right: none; border-bottom: 1px solid var(--color-border); }
}

/* -------------------------------------------------------- PIN-Bestätigung */

.pin-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 24px;
  background: var(--color-bg);
  color: var(--color-text);
  max-width: 320px;
  width: calc(100% - 32px);
}

.pin-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

/* --------------------------------------------------------- Theme-Umschalter */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-bg-alt);
  cursor: pointer;
}

.theme-toggle svg { width: 20px; height: 20px; }

/* -------------------------------------------------------------------- Utility */

.muted { color: var(--color-text-muted); }

/* ------------------------------------------------------------------- Navigation */

.nav {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-height);
  z-index: 1000;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

html[data-theme="dark"] .nav {
  background: rgba(0, 0, 0, 0.72);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.nav__inner {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: clamp(20px, 5vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.nav__brand-mark {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ---------------------------------------------------------------------- Footer */

.footer {
  padding: 40px 0 28px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-alt);
}

.footer__top {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
  margin-bottom: 24px;
}

.footer__brand { max-width: 360px; }
.footer__brand .nav__brand { margin-bottom: 10px; }
.footer__brand p { font-size: 0.88rem; }

.footer__col ul li { margin-bottom: 8px; }

.footer__col h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.footer__col a {
  font-size: 0.9rem;
  color: var(--color-text);
  opacity: 0.85;
}

.footer__bottom {
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

/* ------------------------------------------------------------------------ Legal */

.legal {
  padding-top: calc(var(--nav-height) + 48px);
  padding-bottom: 80px;
}

.legal .container { max-width: 820px; }

.legal h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  margin-bottom: 40px;
}

.legal h2 {
  font-size: clamp(1.3rem, 2.4vw, 1.6rem);
  margin-top: 44px;
  margin-bottom: 14px;
}

.legal p, .legal li { color: var(--color-text); font-size: 1rem; margin-bottom: 10px; }
.legal a:not(.btn) { color: var(--color-red); text-decoration: underline; }

/* -------------------------------------------------------------- Breakpoints */

@media (max-width: 720px) {
  .container { padding-inline: 16px; }
}

/* ------------------------------------------------------------------ Terminal
 * Chromloses Vollbild-Layout für Kasse/Küche/Kundenmonitor (kein .nav/.footer),
 * siehe includes/header.php Docblock. Eigener schmaler Topbar-Streifen statt
 * der öffentlichen Navigation.
 */

.terminal-shell {
  min-height: 100svh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.terminal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px clamp(16px, 3vw, 28px);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-alt);
  flex-shrink: 0;
}

.terminal-topbar__title { font-weight: 700; }

.kasse-layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 0;
}

.kasse-main {
  overflow-y: auto;
  padding: 20px clamp(16px, 2.5vw, 28px);
}

.kasse-kategorie h3 {
  margin: 20px 0 12px;
}

.kasse-artikel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.kasse-artikel-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 76px;
  padding: 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
}

.kasse-artikel-btn:active { transform: scale(0.97); }
.kasse-artikel-btn__name { font-weight: 700; }
.kasse-artikel-btn__preis { color: var(--color-text-muted); font-size: 0.9rem; }

.kasse-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  background: var(--color-red);
  color: #fff;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 500;
}

.kasse-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.kasse-cart {
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--color-bg-alt);
}

.kasse-cart-items {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
}

.kasse-cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.kasse-cart-item__qty {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kasse-cart-item__qty button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  font-weight: 700;
  cursor: pointer;
}

.kasse-cart-footer {
  padding: 16px;
  border-top: 1px solid var(--color-border);
}

.kasse-cart-total {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 12px;
}

.kasse-schwund-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}

.kasse-schwund-row--aktiv {
  background: rgba(175, 43, 30, 0.08);
}

.kasse-schwund-row__stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.kasse-schwund-row__stepper button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.kasse-schwund-row__count {
  width: 44px;
  min-height: auto;
  padding: 6px 2px;
  text-align: center;
  font-weight: 700;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
}

.kasse-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.kasse-modal {
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 440px;
  width: 100%;
  max-height: 90svh;
  max-height: 90vh;
  overflow-y: auto;
}

@media (max-width: 900px) {
  .kasse-layout { grid-template-columns: 1fr; }
  .kasse-cart { border-left: none; border-top: 1px solid var(--color-border); max-height: 40vh; }
}

/* --------------------------------------------------------------- Küchenanzeige */

.kueche-board {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 20px clamp(16px, 2.5vw, 28px);
  overflow-x: auto;
  min-height: 0;
}

.kueche-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--color-bg-alt);
  border-radius: var(--radius);
  padding: 12px;
}

.kueche-column__title {
  font-weight: 700;
  padding: 4px 8px 12px;
  flex-shrink: 0;
}

.kueche-column__cards {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kueche-order-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.kueche-order-card__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.kueche-order-card__bnr { font-weight: 800; font-size: 1.1rem; }
.kueche-order-card__items { font-size: 0.9rem; margin-bottom: 10px; }
.kueche-order-card__items div { margin-bottom: 2px; }

@media (max-width: 900px) {
  .kueche-board { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------- Dark-Mode
 * Doppelt abgesichert: @media (prefers-color-scheme) folgt der OS-Einstellung
 * (gated durch :not([data-theme="light"])), zusätzlich zwingt ein expliziter
 * html[data-theme="dark"]-Override das Theme unabhängig vom OS, sobald der
 * Schalter benutzt wurde. Siehe main.js für den Schalter selbst.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #000000;
    --color-bg-alt: #111113;
    --color-text: #f5f5f7;
    --color-text-muted: #a1a1a6;
    --color-border: #2c2c2e;
    --color-black: #f5f5f7;
  }

  html:not([data-theme="light"]) .nav {
    background: rgba(0, 0, 0, 0.72);
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }
}

html[data-theme="dark"] {
  --color-bg: #000000;
  --color-bg-alt: #111113;
  --color-text: #f5f5f7;
  --color-text-muted: #a1a1a6;
  --color-border: #2c2c2e;
  --color-black: #f5f5f7;
}

/* ---------------------------------------------------------------- Rechnung */

.rechnung-kopf {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}

.rechnung-summe td {
  border-top: 2px solid var(--color-text);
  border-bottom: none;
  font-weight: 800;
  font-size: 1.1rem;
}

@media print {
  .nav, .footer, .theme-toggle { display: none !important; }
  body { background: #fff; color: #000; }
  .legal { padding-top: 0; }
}
