/* ─── Mealix Styles ──────────────────────────────────────── */
:root, [data-theme="light"] {
  --primary: #e85d26;
  --primary-dark: #c94d1e;
  --primary-light: #fff0eb;
  --secondary: #2d6a4f;
  --secondary-light: #eaf5f0;
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text: #212529;
  --text-light: #6c757d;
  --border: #dee2e6;
  --danger: #dc3545;
  --success: #28a745;
  --warning: #ffc107;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --sidebar-bg: #212529;
  --sidebar-text: rgba(255,255,255,0.7);
  --sidebar-border: rgba(255,255,255,0.1);
}

[data-theme="dark"] {
  --primary: #f47642;
  --primary-dark: #e85d26;
  --primary-light: #3d2218;
  --secondary: #52b788;
  --secondary-light: #1a3329;
  --bg: #1a1a2e;
  --card-bg: #16213e;
  --text: #e8e8e8;
  --text-light: #8892a4;
  --border: #2a2a4a;
  --danger: #e74c5e;
  --success: #3dd67c;
  --warning: #f0c040;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
  --sidebar-bg: #0f0f23;
  --sidebar-text: rgba(255,255,255,0.6);
  --sidebar-border: rgba(255,255,255,0.08);
}

@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --primary: #f47642;
    --primary-dark: #e85d26;
    --primary-light: #3d2218;
    --secondary: #52b788;
    --secondary-light: #1a3329;
    --bg: #1a1a2e;
    --card-bg: #16213e;
    --text: #e8e8e8;
    --text-light: #8892a4;
    --border: #2a2a4a;
    --danger: #e74c5e;
    --success: #3dd67c;
    --warning: #f0c040;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
    --sidebar-bg: #0f0f23;
    --sidebar-text: rgba(255,255,255,0.6);
    --sidebar-border: rgba(255,255,255,0.08);
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ─── Layout ─────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: #fff;
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 20px 24px;
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-nav {
  list-style: none;
  padding: 12px 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s;
}

.sidebar-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}

.sidebar-nav a.active {
  color: #fff;
  background: var(--primary);
}

.sidebar-nav .nav-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-nav .nav-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-nav-bottom {
  flex: 0 0 auto;
  padding-top: 8px;
  padding-bottom: 8px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-copyright {
  font-size: 10px; color: rgba(255,255,255,0.3); text-align: center;
  padding: 0 24px 12px; margin-top: -4px;
}

.theme-toggle {
  display: flex; gap: 2px; background: rgba(255,255,255,0.08); border-radius: 6px;
  padding: 2px; margin-bottom: 10px;
}
.theme-toggle button {
  flex: 1; padding: 5px 0; border: none; background: none; color: rgba(255,255,255,0.5);
  border-radius: 4px; cursor: pointer; font-size: 11px; transition: all 0.15s;
}
.theme-toggle button.active { background: var(--primary); color: #fff; }
.theme-toggle button:hover:not(.active) { color: #fff; }

.sidebar-footer button {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.6);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  width: 100%;
  transition: all 0.15s;
}

.sidebar-footer button:hover {
  color: #fff;
  border-color: rgba(255,255,255,0.5);
}

.main-content {
  margin-left: 240px;
  flex: 1;
  padding: 32px;
  max-width: 1200px;
}

/* ─── Page Header ────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 600;
}

/* ─── Cards ──────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.stat-card.green { border-left-color: var(--secondary); }
.stat-card.orange { border-left-color: var(--warning); }
.stat-card.red { border-left-color: var(--danger); }

.stat-card .stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
}

/* ─── Lucide Icons ───────────────────────────────────────── */
i[data-lucide] { width: 16px; height: 16px; vertical-align: middle; display: inline-block; }
.btn i[data-lucide] { width: 14px; height: 14px; }
.btn-sm i[data-lucide] { width: 13px; height: 13px; }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}

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

.btn-secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { opacity: 0.9; }

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

.btn-sm { padding: 4px 10px; font-size: 13px; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-light);
  font-size: 16px;
}
.btn-icon:hover { color: var(--text); }

/* ─── Table ──────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-body { padding: 20px; }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

tr:last-child td { border-bottom: none; }

tr:hover { background: var(--primary-light); }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-offen { background: #fff3cd; color: #856404; }
.badge-bezahlt { background: #d4edda; color: #155724; }
.badge-storniert { background: #f8d7da; color: #721c24; }
.badge-normal { background: var(--bg); color: var(--text); }
.badge-vegetarisch { background: #d4edda; color: #155724; }
.badge-vegan { background: #cce5ff; color: #004085; }
.badge-diaet { background: #fff3cd; color: #856404; }
.badge-pueriert { background: #e2d5f1; color: #4a2578; }
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
  background: var(--card-bg);
  color: var(--text);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232, 93, 38, 0.15);
}

select.form-control { cursor: pointer; }

/* Bare selects (without form-control) also respect dark mode */
select:not(.form-control):not([class]) {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 6px;
  font-size: 13px;
  font-family: inherit;
}
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ─── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: flex-start;
  padding-top: 80px;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 160px);
  overflow-y: auto;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 { font-size: 18px; }

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}

.modal-body { padding: 20px; }

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ─── Login ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-card {
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  text-align: center;
  margin-bottom: 8px;
  font-size: 28px;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 32px;
  font-size: 14px;
}

.login-card .brand-icon {
  text-align: center;
  font-size: 48px;
  margin-bottom: 16px;
}

.login-card .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  margin-top: 8px;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
  display: none;
}

/* ─── Utilities ──────────────────────────────────────────── */
.text-muted { color: var(--text-light); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-light);
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  width: 260px;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ─── Delivery checkmark ─────────────────────────────────── */
.delivery-check {
  width: 22px;
  height: 22px;
  cursor: pointer;
  accent-color: var(--success);
}

/* ─── Searchable Select ──────────────────────────────────── */
.ss-wrapper {
    position: relative;
}

.ss-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    min-height: 38px;
    transition: border-color 0.15s;
}

.ss-display:hover { border-color: var(--primary); }

.ss-chevron { flex-shrink: 0; color: var(--text-light); }

.ss-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.ss-dropdown {
    display: none;
    position: fixed;
    z-index: 9999;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    overflow: hidden;
}

.ss-dropdown.open { display: block; }

.ss-search {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
}

.ss-search:focus {
    background: var(--card-bg);
}

.ss-list {
    max-height: 200px;
    overflow-y: auto;
}

.ss-option {
    padding: 7px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.1s;
    background: var(--card-bg);
    color: var(--text);
}

.ss-option:hover { background: var(--bg); }
.ss-option.ss-active { background: var(--primary-light); color: var(--primary); font-weight: 500; }

.ss-empty {
    padding: 12px;
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
}

/* ─── Mobile Menu Toggle ─────────────────────────────────── */
.mobile-menu-btn {
  display: none;
  position: fixed; top: 12px; left: 12px; z-index: 201;
  width: 40px; height: 40px; border-radius: var(--radius);
  background: var(--sidebar-bg); color: #fff; border: none;
  font-size: 22px; cursor: pointer; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99;
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open {
    transform: translateX(0);
    z-index: 200;
  }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; padding: 16px; padding-top: 60px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
}
