/* Crumbs - Modern Dark Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-alt: #212430;
  --card: #1e2130;
  --sidebar: #141620;
  --border: #2d3348;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --muted: #64748b;
  --primary: #6366f1;
  --primary-hover: #5457e5;
  --primary-subtle: rgba(99, 102, 241, 0.12);
  --success: #22c55e;
  --success-hover: #1db954;
  --success-subtle: rgba(34, 197, 94, 0.12);
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-subtle: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.12);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --sidebar-width: 260px;
  --sidebar-collapsed: 80px;
  --topbar-height: 60px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ==================== TOPBAR ==================== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.topbar-toggle:hover {
  background: var(--primary-subtle);
  color: var(--primary);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.topbar-brand .material-symbols-rounded {
  font-size: 28px;
  color: var(--primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.topbar-user .material-symbols-rounded {
  font-size: 22px;
}

.topbar-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  background: var(--danger-subtle);
  color: var(--danger);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}

.topbar-logout:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-section {
  padding: 8px 0 4px;
}

.sidebar-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0 12px 0px;
  white-space: nowrap;
  overflow: hidden;
  margin-top: 12px;
}

.collapsed .sidebar-label {
  opacity: 0;
  height: 0;
  padding: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}

.sidebar-link:hover {
  background: var(--primary-subtle);
  color: var(--text);
}

.sidebar-link.active {
  background: var(--primary);
  color: #fff;
}

.sidebar-link .material-symbols-rounded {
  font-size: 22px;
  flex-shrink: 0;
}

.sidebar-link span:not(.material-symbols-rounded) {
  overflow: hidden;
  transition: opacity var(--transition), width var(--transition);
}

.collapsed .sidebar-link span:not(.material-symbols-rounded) {
  opacity: 0;
  width: 0;
}

.collapsed .sidebar-link {
  justify-content: center;
  gap: 0;
  transition: gap var(--transition);
  transition: justify-content var(--transition);
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 1px 0;
  margin-top: 10px;
  margin-bottom: 10px;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 28px;
  min-height: calc(100vh - var(--topbar-height));
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.page-header-text h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 2px;
}

.page-header-text p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ==================== CARDS ==================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}

.card .meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
  color: #fff;
  background: var(--primary);
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn:active { transform: translateY(0); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn .material-symbols-rounded { font-size: 20px; }

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
}
.btn-secondary:hover {
  background: #2d3040;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn-success { background: var(--success); }
.btn-success:hover { background: var(--success-hover); box-shadow: 0 4px 12px rgba(34,197,94,0.3); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); box-shadow: 0 4px 12px rgba(239,68,68,0.3); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--text);
  box-shadow: none;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ==================== FORMS ==================== */
input,
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  appearance: none;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

input[type="checkbox"]::after {
  content: "";
  width: 10px;
  height: 6px;
  margin-bottom: 2px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) scale(0);
  transition: transform 0.12s ease-in-out;
}

input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

input[type="checkbox"]:checked::after {
  transform: rotate(-45deg) scale(1);
}

input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* Form layout */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

form table { width: 100%; border-collapse: collapse; }
form td { padding: 8px 6px; vertical-align: middle; }
form td:first-child { font-weight: 600; font-size: 14px; white-space: nowrap; width: 1%; }

/* ==================== TABLES ==================== */
.table { width: 100%; border-collapse: collapse; margin-top: 12px; }

.table caption {
  text-align: left;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 10px;
}

.table th,
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.table th {
  background: var(--surface);
  color: var(--primary);
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table tr:hover td { background: rgba(99, 102, 241, 0.04); }

/* ==================== ALERTS ==================== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin: 12px 0;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-error {
  background: var(--danger-subtle);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
  background: var(--warning-subtle);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-success {
  background: var(--success-subtle);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

/* ==================== PRODUCT GRID ==================== */
.product-container {
  display: flex;
  flex-direction: column;
  gap: 28px;
  width: 100%;
}

.category-container { width: 100%; }

.category-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.category-products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.product-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), 0 4px 16px rgba(99, 102, 241, 0.1);
}

.product-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius);
}

.product-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.product-description {
  min-height: 42px;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.product-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin: 4px 0;
}

/* ==================== ORDER STATUS ==================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  white-space: nowrap;
}

.status-pending {
  background: var(--warning-subtle);
  color: var(--warning);
}

.status-preparing {
  background: var(--primary-subtle);
  color: #818cf8;
}

.status-done {
  background: var(--success-subtle);
  color: var(--success);
}

.status-delivered {
  background: rgba(100, 116, 139, 0.12);
  color: var(--muted);
}

.status-select {
  width: auto;
  padding: 5px 10px;
  font-size: 13px;
  border-radius: var(--radius);
}

.status-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-btn {
  padding: 10px 16px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.status-btn:active {
  transform: scale(0.96);
}

.status-btn-pending.active {
  background: var(--warning-subtle);
  color: var(--warning);
  border-color: var(--warning);
}

.status-btn-preparing.active {
  background: var(--primary-subtle);
  color: #818cf8;
  border-color: #818cf8;
}

.status-btn-done.active {
  background: var(--success-subtle);
  color: var(--success);
  border-color: var(--success);
}

.status-btn-delivered.active {
  background: rgba(100, 116, 139, 0.12);
  color: var(--muted);
  border-color: var(--muted);
}

/* ==================== ORDER CARDS (compact admin) ==================== */
.order-card {
  margin-bottom: 12px;
  padding: 20px;
}

.order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.order-header h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.order-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

.order-status-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.order-items-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.order-item-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.order-item-chip .item-qty {
  color: var(--primary);
  font-weight: 700;
}

.order-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.order-instructions {
  font-size: 13px;
  color: var(--warning);
  font-style: italic;
}

.order-total {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

/* ==================== DASHBOARD GRID ==================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.dash-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color var(--transition), transform var(--transition);
}

.dash-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.dash-card-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--primary-subtle);
  color: var(--primary);
}

.dash-card h3 {
  font-size: 16px;
  font-weight: 600;
}

.dash-card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

/* ==================== AUTH PAGES ==================== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-header .material-symbols-rounded {
  font-size: 40px;
  color: var(--primary);
  margin-bottom: 12px;
}

.auth-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.auth-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ==================== MISC ==================== */
.muted { color: var(--muted); }
.meta { color: var(--text-secondary); font-size: 13px; }

.input-wrapper {
  position: relative;
  width: 100%;
}
.input-wrapper input { padding-right: 50px; }
.char-count {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
}

.signup {
  background: var(--surface-alt);
  color: var(--text);
}
.signup:hover {
  background: #2d3040;
  box-shadow: none;
}

.password { -webkit-text-security: disc; }
.password:active { -webkit-text-security: none; }

/* ==================== MOBILE OVERLAY ==================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 85;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
    z-index: 95;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: var(--sidebar-width);
    transform: translateX(-100%);
  }

  .sidebar.collapsed.mobile-open {
    transform: translateX(0);
  }

  .sidebar.mobile-open ~ .sidebar-overlay {
    display: block;
  }

  .main-content,
  .sidebar.collapsed ~ .main-content {
    margin-left: 0;
  }

  .main-content {
    padding: 20px 16px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .category-products {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .topbar-user span { display: none; }

  .order-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .table th, .table td {
    padding: 8px 10px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 16px 12px;
  }

  .card { padding: 16px; }

  .auth-card { padding: 24px; }

  .category-products {
    grid-template-columns: 1fr;
  }

  .btn { padding: 8px 14px; font-size: 13px; }

  .actions {
    width: 100%;
  }

  .actions .btn { flex: 1; }
}
