:root {
  --bg-dark: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-light: #232636;
  --surface: #2a2d3e;
  --primary: #ff6b35;
  --primary-dark: #e55a25;
  --primary-light: #ff8c5a;
  --secondary: #2ec4b6;
  --accent: #ffd700;
  --text-primary: #ffffff;
  --text-secondary: #b0b3c1;
  --text-muted: #6b7280;
  --estado-recibido: #6b7280;
  --estado-preparacion: #ff6b35;
  --estado-listo: #2ec4b6;
  --estado-entregado: #22c55e;
  --estado-cancelado: #ef4444;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

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

body {
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--surface); border-radius: 3px; }

/* ── App Shell ─────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--surface);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(10px);
}
.topbar-brand {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
}
.topbar-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 16px rgba(255,107,53,0.4);
}
.topbar-logo svg { width: 20px; height: 20px; fill: white; }
.topbar-title {
  font-size: 20px; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.nav-btn {
  background: none; border: none; color: var(--text-secondary);
  padding: 6px 14px; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 500; transition: var(--transition);
}
.nav-btn:hover { background: var(--surface); color: var(--text-primary); }
.nav-btn.active { background: rgba(255,107,53,0.15); color: var(--primary); }
#btn-logout {
  background: rgba(239,68,68,0.1); color: var(--estado-cancelado);
  border: 1px solid rgba(239,68,68,0.3); padding: 6px 14px;
  border-radius: 8px; cursor: pointer; font-size: 13px; transition: var(--transition);
}
#btn-logout:hover { background: rgba(239,68,68,0.2); }

/* ── Main Content ──────────────────────────────────────────── */
#main-content { flex: 1; padding: 28px 24px; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition);
}
.card:hover { border-color: rgba(255,107,53,0.2); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 600; border: none;
  cursor: pointer; transition: var(--transition); text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(255,107,53,0.35); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #25a89f; }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--estado-cancelado); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-ghost { background: var(--surface); color: var(--text-primary); }
.btn-ghost:hover { background: var(--bg-card-light); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── Form Elements ─────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.form-input, .form-select, .form-textarea {
  background: var(--bg-card-light);
  border: 1px solid var(--surface);
  border-radius: 10px; color: var(--text-primary);
  padding: 10px 14px; font-size: 14px; font-family: inherit;
  transition: var(--transition); outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,107,53,0.12);
}
.form-select option { background: var(--bg-card); }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
}
.badge-recibido { background: rgba(107,114,128,0.15); color: var(--estado-recibido); }
.badge-preparacion { background: rgba(255,107,53,0.15); color: var(--estado-preparacion); }
.badge-listo { background: rgba(46,196,182,0.15); color: var(--estado-listo); }
.badge-entregado { background: rgba(34,197,94,0.15); color: var(--estado-entregado); }
.badge-cancelado { background: rgba(239,68,68,0.15); color: var(--estado-cancelado); }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--surface); color: var(--text-secondary);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 10px 14px; text-align: left;
}
tbody tr { border-bottom: 1px solid var(--surface); transition: var(--transition); }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody td { padding: 12px 14px; font-size: 14px; color: var(--text-primary); }

/* ── Login Screen ──────────────────────────────────────────── */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 30% 50%, rgba(255,107,53,0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 50%, rgba(46,196,182,0.06) 0%, transparent 60%),
              var(--bg-dark);
}
.login-box {
  width: 100%; max-width: 420px; padding: 24px;
}
.login-logo-wrap {
  text-align: center; margin-bottom: 32px;
}
.login-logo {
  width: 72px; height: 72px; border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 32px rgba(255,107,53,0.4);
  margin-bottom: 16px;
}
.login-logo svg { width: 36px; height: 36px; fill: white; }
.login-title {
  font-size: 32px; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.login-card {
  background: var(--bg-card); border: 1px solid var(--surface);
  border-radius: 24px; padding: 32px;
}
.login-card h2 { font-size: 18px; font-weight: 600; margin-bottom: 24px; text-align: center; }
#login-error {
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
  border-radius: 8px; padding: 10px 14px; color: var(--estado-cancelado);
  font-size: 13px; margin-bottom: 16px; display: none;
}
.login-card .btn-primary { width: 100%; justify-content: center; padding: 14px; font-size: 15px; }
.login-divider { text-align: center; color: var(--text-muted); font-size: 13px; margin: 16px 0; }
.qr-hint { text-align: center; color: var(--secondary); font-size: 13px; cursor: pointer; }
.qr-hint:hover { text-decoration: underline; }

/* ── Dashboard Grid ────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--surface);
  border-radius: var(--radius-lg); padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  flex-shrink: 0;
}
.stat-value { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Menu Grid ─────────────────────────────────────────────── */
.menu-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-chip {
  padding: 6px 16px; border-radius: 20px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--surface); background: var(--bg-card);
  color: var(--text-secondary); cursor: pointer; transition: var(--transition);
}
.filter-chip.active, .filter-chip:hover { background: rgba(255,107,53,0.15); border-color: var(--primary); color: var(--primary); }

.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.product-card {
  background: var(--bg-card); border: 1px solid var(--surface);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  transition: var(--transition);
}
.product-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(255,107,53,0.15); }
.product-img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  background: var(--surface); display: flex; align-items: center; justify-content: center;
  font-size: 32px;
}
.product-img.placeholder { display: flex; }
.product-info { padding: 12px; }
.product-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; line-height: 1.3; }
.product-price { color: var(--primary); font-weight: 700; font-size: 15px; }
.product-card .btn { width: 100%; justify-content: center; margin-top: 10px; font-size: 12px; padding: 7px; }

/* ── Cola Cocina ───────────────────────────────────────────── */
.cocina-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.pedido-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  border: 2px solid transparent; overflow: hidden; transition: var(--transition);
}
.pedido-card.recibido { border-color: rgba(107,114,128,0.3); }
.pedido-card.en_preparacion { border-color: rgba(255,107,53,0.4); box-shadow: 0 0 20px rgba(255,107,53,0.1); }
.pedido-card.listo { border-color: rgba(46,196,182,0.4); box-shadow: 0 0 20px rgba(46,196,182,0.1); }
.pedido-header {
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
}
.pedido-header.recibido { background: rgba(107,114,128,0.08); }
.pedido-header.en_preparacion { background: rgba(255,107,53,0.08); }
.pedido-header.listo { background: rgba(46,196,182,0.08); }
.pedido-mesa { font-size: 15px; font-weight: 700; }
.pedido-time { font-size: 12px; color: var(--text-muted); }
.pedido-body { padding: 16px 18px; }
.pedido-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.pedido-item:last-child { border-bottom: none; }
.item-qty {
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(255,107,53,0.15); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.item-name { font-size: 13px; font-weight: 500; flex: 1; }
.item-obs { font-size: 11px; color: var(--accent); display: block; margin-top: 2px; }
.pedido-actions { padding: 0 18px 16px; display: flex; gap: 8px; }

/* ── Live indicator ─────────────────────────────────────────── */
.live-dot {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(46,196,182,0.12); border-radius: 20px; padding: 3px 10px;
  font-size: 11px; font-weight: 700; color: var(--secondary);
}
.live-dot::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--secondary); animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ── Toast ─────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-card); border: 1px solid var(--surface);
  border-radius: 12px; padding: 12px 20px; font-size: 13px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px;
  animation: slideIn 0.3s ease; min-width: 260px;
}
.toast.success { border-left: 3px solid var(--estado-entregado); }
.toast.error { border-left: 3px solid var(--estado-cancelado); }
.toast.info { border-left: 3px solid var(--secondary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card); border: 1px solid var(--surface);
  border-radius: 24px; padding: 28px; max-width: 480px; width: 100%;
  transform: scale(0.95); transition: var(--transition);
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; }
.modal-close:hover { color: var(--text-primary); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ── Sidebar ───────────────────────────────────────────────── */
.layout { display: flex; gap: 0; }
.sidebar {
  width: 220px; min-height: calc(100vh - 60px);
  background: var(--bg-card); border-right: 1px solid var(--surface);
  padding: 20px 12px; flex-shrink: 0;
}
.sidebar-section { margin-bottom: 4px; }
.sidebar-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); padding: 0 10px; margin-bottom: 4px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--text-secondary); text-decoration: none; font-size: 14px;
  transition: var(--transition); cursor: pointer;
}
.sidebar-link:hover { background: var(--surface); color: var(--text-primary); }
.sidebar-link.active { background: rgba(255,107,53,0.12); color: var(--primary); font-weight: 600; }
.sidebar-link .icon { font-size: 16px; width: 20px; text-align: center; }
.content-area { flex: 1; padding: 28px 24px; overflow: auto; }

/* ── User info bar ──────────────────────────────────────────── */
.user-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-radius: 20px; padding: 5px 12px 5px 5px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.user-name { font-size: 13px; font-weight: 500; }
.user-rol { font-size: 11px; color: var(--text-muted); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .products-grid { grid-template-columns: repeat(2, 1fr); }
  .cocina-grid { grid-template-columns: 1fr; }
  #main-content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* ── Skeleton loader ────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--bg-card-light) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Fade in ─────────────────────────────────────────────────── */
.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted); font-size: 15px;
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; display: block; }

/* ── Switch ──────────────────────────────────────────────────── */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--surface); border-radius: 22px; transition: var(--transition);
}
.slider::before {
  position: absolute; content: ''; height: 16px; width: 16px;
  left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: var(--transition);
}
input:checked + .slider { background: var(--primary); }
input:checked + .slider::before { transform: translateX(18px); }

/* ── Progress bar ───────────────────────────────────────────── */
.progress-bar { height: 6px; border-radius: 3px; background: var(--surface); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
