/* ============================================
   SHARED.CSS — Kellner-System Foundation
   Modernes minimalistisches Restaurant-Design
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Base Colors */
  --color-bg: #ffffff;
  --color-bg-secondary: #f5f5f7;
  --color-bg-tertiary: #e8e8ed;
  --color-surface: #ffffff;
  --color-text: #1d1d1f;
  --color-text-secondary: #6e6e73;
  --color-text-tertiary: #aeaeb2;
  --color-border: #d2d2d7;
  --color-border-light: #e5e5ea;
  --color-divider: #f2f2f7;

  /* Brand / Action */
  --color-primary: #1d1d1f;
  --color-primary-hover: #333336;
  --color-primary-text: #ffffff;
  --color-danger: #ff3b30;
  --color-danger-hover: #d63029;
  --color-danger-text: #ffffff;
  --color-ghost-hover: rgba(0, 0, 0, 0.06);

  /* Status */
  --color-status-free: #34c759;
  --color-status-free-bg: rgba(52, 199, 89, 0.12);
  --color-status-occupied: #ff3b30;
  --color-status-occupied-bg: rgba(255, 59, 48, 0.12);
  --color-status-waiting: #ff9500;
  --color-status-waiting-bg: rgba(255, 149, 0, 0.12);
  --color-status-ready: #34c759;
  --color-status-ready-bg: rgba(52, 199, 89, 0.12);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-md: 15px;
  --font-size-lg: 17px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 28px;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;

  /* Touch targets */
  --tap-target: 48px;

  /* Header */
  --header-height: 56px;
}

/* --- Dark Mode --- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #000000;
    --color-bg-secondary: #1c1c1e;
    --color-bg-tertiary: #2c2c2e;
    --color-surface: #1c1c1e;
    --color-text: #f5f5f7;
    --color-text-secondary: #a1a1a6;
    --color-text-tertiary: #636366;
    --color-border: #38383a;
    --color-border-light: #2c2c2e;
    --color-divider: #1c1c1e;

    --color-primary: #f5f5f7;
    --color-primary-hover: #e5e5ea;
    --color-primary-text: #1d1d1f;
    --color-ghost-hover: rgba(255, 255, 255, 0.08);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-regular);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
}

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

button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
}

input {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  outline: none;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
}

ul, ol {
  list-style: none;
}

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

/* --- Screen System --- */
.screen {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--color-bg);
  z-index: 1;
  overflow-x: hidden;
  max-width: 100vw;
}

.screen.active {
  display: flex;
  flex-direction: column;
  z-index: 10;
}

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  min-height: var(--header-height);
  padding: max(env(safe-area-inset-top, 0px), 12px) var(--space-md) 0;
  padding-bottom: 12px;
  background-color: var(--color-bg);
  border-bottom: 1px solid var(--color-border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.header__back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-target);
  height: var(--tap-target);
  border-radius: var(--radius-full);
  transition: background-color var(--transition-fast);
  margin-right: var(--space-sm);
  flex-shrink: 0;
}

.header__back:active {
  background-color: var(--color-ghost-hover);
}

.header__back svg {
  width: 24px;
  height: 24px;
}

.header__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

/* --- Content Area --- */
.content {
  flex: 1;
  padding: var(--space-md);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.content--no-pad {
  padding: 0;
}

/* --- Card --- */
.card {
  background-color: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  overflow: hidden;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.card:active {
  transform: scale(0.98);
}

.card--flat {
  box-shadow: none;
}

.card--elevated {
  box-shadow: var(--shadow-md);
}

.card__body {
  padding: var(--space-md);
}

.card__header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-divider);
}

.card__footer {
  padding: var(--space-md);
  border-top: 1px solid var(--color-divider);
}

/* --- Grid Layouts --- */
.grid {
  display: grid;
  gap: var(--space-md);
}

.grid--3col {
  grid-template-columns: repeat(3, 1fr);
}

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

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

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: var(--tap-target);
  padding: 0 var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  transition: background-color var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

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

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.btn--primary {
  background-color: var(--color-primary);
  color: var(--color-primary-text);
}

.btn--primary:active {
  background-color: var(--color-primary-hover);
}

.btn--danger {
  background-color: var(--color-danger);
  color: var(--color-danger-text);
}

.btn--danger:active {
  background-color: var(--color-danger-hover);
}

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

.btn--ghost:active {
  background-color: var(--color-ghost-hover);
}

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

.btn--sm {
  min-height: 36px;
  padding: 0 var(--space-md);
  font-size: var(--font-size-sm);
  border-radius: var(--radius-sm);
}

.btn--lg {
  min-height: 56px;
  padding: 0 var(--space-xl);
  font-size: var(--font-size-lg);
  border-radius: var(--radius-lg);
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.4;
}

.badge--free {
  background-color: var(--color-status-free-bg);
  color: var(--color-status-free);
}

.badge--occupied {
  background-color: var(--color-status-occupied-bg);
  color: var(--color-status-occupied);
}

.badge--waiting {
  background-color: var(--color-status-waiting-bg);
  color: var(--color-status-waiting);
}

.badge--ready {
  background-color: var(--color-status-ready-bg);
  color: var(--color-status-ready);
}

/* --- Status Dot --- */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot--free {
  background-color: var(--color-status-free);
}

.status-dot--occupied {
  background-color: var(--color-status-occupied);
}

.status-dot--waiting {
  background-color: var(--color-status-waiting);
}

.status-dot--ready {
  background-color: var(--color-status-ready);
}

/* --- Toast / Notification --- */
.toast-container {
  position: fixed;
  top: 72px;
  right: var(--space-md);
  left: auto;
  transform: none;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  width: auto;
  max-width: 240px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background-color: var(--color-text);
  color: var(--color-bg);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: var(--font-weight-medium);
  line-height: 1.2;
  pointer-events: auto;
  animation: toast-in 180ms ease forwards;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast--success {
  background-color: var(--color-status-free);
  color: #ffffff;
}

.toast--error {
  background-color: var(--color-danger);
  color: #ffffff;
}

.toast--warning {
  background-color: var(--color-status-waiting);
  color: #1d1d1f;
}

.toast.leaving {
  animation: toast-out 250ms ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-12px) scale(0.95);
  }
}

/* --- Section --- */
.section-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--space-sm) 0;
}

/* --- Divider --- */
.divider {
  height: 1px;
  background-color: var(--color-divider);
  margin: var(--space-md) 0;
}

/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
  color: var(--color-text-tertiary);
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.empty-state__text {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
}

/* --- Loading Spinner --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border-light);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.spinner--lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

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

/* --- Overlay / Backdrop --- */
.overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 500;
  animation: fade-in 200ms ease forwards;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Utility --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.text-center { text-align: center; }
.text-secondary { color: var(--color-text-secondary); }
.text-danger { color: var(--color-danger); }
.text-sm { font-size: var(--font-size-sm); }
.text-lg { font-size: var(--font-size-lg); }
.text-bold { font-weight: var(--font-weight-bold); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
