/* =========================================================
   MATE — Design System
   ========================================================= */
:root {
  --verde-900: #17402a;
  --verde-700: #2f7a4f;
  --verde-600: #38946099;
  --verde-500: #3d9c63;
  --verde-100: #e6f4ec;
  --verde-50: #f3faf6;
  --amarillo: #d9a441;
  --naranja: #e0803c;
  --rojo: #d1483f;
  --azul: #3a7bd5;
  --gris-900: #1c211f;
  --gris-700: #4b544f;
  --gris-500: #7c8781;
  --gris-300: #d7ded9;
  --gris-100: #f0f3f1;
  --blanco: #ffffff;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(23, 64, 42, 0.08);
  --shadow-lg: 0 8px 30px rgba(23, 64, 42, 0.14);
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --bottomnav-h: 64px;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--gris-100);
  color: var(--gris-900);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; }
p { margin: 0 0 8px; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- Layout shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--verde-900), var(--verde-700));
  color: var(--blanco);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
  transition: transform .25s ease;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  font-weight: 700;
  font-size: 1.25rem;
}
.brand-icon { font-size: 1.6rem; }
.nav-links { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; flex: 1; overflow-y: auto; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.85);
  font-weight: 500;
  font-size: 0.95rem;
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.16); color: #fff; }
.nav-icon { font-size: 1.15rem; width: 22px; text-align: center; }
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.12); }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--amarillo); color: #3a2a06;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; text-transform: uppercase;
}
.user-name { font-size: 0.9rem; font-weight: 600; }
.user-role { font-size: 0.75rem; color: rgba(255,255,255,0.7); }
.logout-link {
  display: block; text-align: center; padding: 8px;
  background: rgba(255,255,255,0.1); border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.logout-link:hover { background: rgba(255,255,255,0.2); }

.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-w));
}
.topbar {
  height: var(--topbar-h);
  background: var(--blanco);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 1.15rem; font-weight: 700; color: var(--verde-900); }
.menu-toggle { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--verde-900); }
.topbar-spacer { flex: 1; }
.content { padding: 20px; flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; }

.bottom-nav { display: none; }

/* ---------- Login / plain pages ---------- */
.content-plain {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, var(--verde-100), var(--gris-100) 70%);
  padding: 20px;
}

/* ---------- Cards, grids ---------- */
.card {
  background: var(--blanco);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.stat-card {
  background: var(--blanco);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 4px solid var(--verde-500);
}
.stat-label { font-size: 0.8rem; color: var(--gris-500); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: 1.7rem; font-weight: 800; color: var(--verde-900); }
.stat-sub { font-size: 0.8rem; color: var(--gris-500); }
.stat-card.amarillo { border-left-color: var(--amarillo); }
.stat-card.rojo { border-left-color: var(--rojo); }
.stat-card.azul { border-left-color: var(--azul); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .15s ease;
  background: var(--verde-600);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--verde-700); color: #fff; }
.btn-primary:hover { background: var(--verde-900); }
.btn-secondary { background: var(--gris-100); color: var(--gris-900); }
.btn-secondary:hover { background: var(--gris-300); }
.btn-danger { background: var(--rojo); color: #fff; }
.btn-warning { background: var(--amarillo); color: #3a2a06; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; border-radius: 50%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; color: var(--gris-700); }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--gris-300);
  font-size: 0.95rem;
  background: var(--blanco);
  color: var(--gris-900);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--verde-500); box-shadow: 0 0 0 3px var(--verde-100); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 140px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--blanco); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td { padding: 12px 14px; text-align: left; font-size: 0.9rem; border-bottom: 1px solid var(--gris-100); }
th { color: var(--gris-500); font-size: 0.75rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--verde-50); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; }
.badge-pendiente { background: #fdf0da; color: #a3690a; }
.badge-preparacion { background: #dcecfb; color: #1f5f9c; }
.badge-listo { background: #ddf3e4; color: #1c7a3f; }
.badge-entregado { background: #e5e7ec; color: #444d58; }
.badge-cancelado { background: #fbe1df; color: #a3312a; }

/* ---------- Misc ---------- */
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.muted { color: var(--gris-500); }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--gris-500); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 10px; }
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--gris-900); color: #fff; padding: 10px 20px; border-radius: 30px;
  font-size: 0.85rem; z-index: 100; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.toast.show { opacity: 1; }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,30,25,0.5);
  display: none; align-items: flex-end; justify-content: center; z-index: 80;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 18px 18px 0 0; padding: 20px;
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: var(--radius); }
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Responsive: mobile-first collapse ---------- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
    box-shadow: var(--shadow-lg);
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .main-area { margin-left: 0; width: 100%; }
  .menu-toggle { display: block; }
  .content { padding: 14px 14px calc(var(--bottomnav-h) + 20px); }
  .bottom-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--bottomnav-h);
    background: #fff;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    z-index: 30;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-link {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; font-size: 0.65rem; color: var(--gris-500); font-weight: 600;
  }
  .bottom-link.active { color: var(--verde-700); }
  .bottom-link .nav-icon { font-size: 1.3rem; }
}

/* Login card */
.login-card {
  background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg);
  padding: 36px 30px; width: 100%; max-width: 380px; text-align: center;
}
.login-card .brand-icon { font-size: 3rem; }
.login-card h1 { color: var(--verde-900); font-size: 1.5rem; margin-top: 4px; }
.login-card .subtitle { color: var(--gris-500); font-size: 0.9rem; margin-bottom: 24px; }
.error-msg { background: #fbe1df; color: #a3312a; padding: 10px 14px; border-radius: 10px; font-size: 0.85rem; margin-bottom: 14px; }

/* Product picker (ventas) */
.product-tile {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; cursor: pointer; transition: box-shadow .15s ease, transform .1s ease;
  border: 2px solid transparent;
}
.product-tile:hover { box-shadow: var(--shadow-lg); }
.product-tile:active { transform: scale(0.98); }
.product-tile.selected { border-color: var(--verde-500); }
.product-tile .name { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.product-tile .price { color: var(--verde-700); font-weight: 700; }
.qty-control { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.qty-control button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--gris-300); background: var(--gris-100); font-weight: 700; cursor: pointer; }
.qty-control .qty-val { min-width: 24px; text-align: center; font-weight: 700; }

.cart-panel {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; position: sticky; top: 76px;
}
.cart-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--gris-100); font-size: 0.88rem; }
.cart-total { display: flex; justify-content: space-between; font-weight: 800; font-size: 1.1rem; margin-top: 10px; color: var(--verde-900); }
