/* ── TOKENS ─────────────────────────────────────────────── */
:root {
  --bg:     #0B0D14;
  --s1:     #111420;
  --s2:     #181B28;
  --s3:     #21253A;
  --border: #2A2E45;
  --accent: #FF6B2B;
  --green:  #22C55E;
  --red:    #EF4444;
  --yellow: #F59E0B;
  --blue:   #3B82F6;
  --purple: #A855F7;
  --text:   #F1F5F9;
  --muted:  #8B9AB3;
  --dim:    #4B5775;
}

/* ── RESET / BASE ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { background: var(--bg); color: var(--text); font-family: 'Space Grotesk', system-ui, sans-serif; margin: 0; }

/* ── LAYOUT ─────────────────────────────────────────────── */
.pos-wrap    { height: 100vh; overflow: hidden; }
.pos-sidebar { width: 220px; height: 100vh; background: var(--s1); border-right: 1px solid var(--border); flex-shrink: 0; }
/* El <nav> de enlaces toma el espacio disponible y hace scroll propio si el
   menú no cabe; así el logo (arriba) y la sección de usuario (abajo) quedan fijos.
   min-height:0 es imprescindible para que un hijo flex pueda encoger y desbordar. */
.pos-sidebar > nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
/* Scrollbar discreta dentro de la barra lateral */
.pos-sidebar > nav::-webkit-scrollbar { width: 6px; }
.pos-sidebar > nav::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text) 18%, transparent); border-radius: 3px; }
.pos-sidebar > nav { scrollbar-width: thin; }
.pos-main    { overflow: hidden; }

/* Área de contenido clara (sidebar sigue con el tema oscuro).
   Se activa por página con ViewData["Light"]="1" en la vista.
   Redefine las variables solo dentro de .pos-main, así todo lo que
   use var(--...) (header, cards, tablas) se aclara automáticamente. */
.pos-main.light-area {
  --s1:#ffffff; --s2:#f7f8fa; --s3:#eef0f4;
  --border:#e4e7ec; --text:#1f2733; --muted:#6b7280; --dim:#9aa1ad;
  --blue:#3B82F6; --green:#22C55E; --red:#EF4444; --yellow:#F59E0B;
  background: var(--content, #f6f7f9);   /* fondo del panel de contenido, configurable en Apariencia */
  color:var(--text);
}
/* En área clara los modales quedan blancos: el título de cabecera (que usa
   .text-white) debe pasar a texto oscuro para que se lea. */
.light-area .pos-modal-header .text-white,
.light-area .pos-modal-header h5 { color: var(--text) !important; }

/* ── SIDEBAR ────────────────────────────────────────────── */
.pos-brand    { border-bottom: 1px solid var(--border); }
.brand-icon   { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; font-size: 14px; flex-shrink: 0; }
.brand-name   { font-weight: 700; font-size: 14px; color: var(--text); line-height: 1.2; }
.brand-sub    { font-size: 9px; color: var(--muted); letter-spacing: .08em; }

.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 7px; color: color-mix(in srgb, var(--text) 75%, transparent); text-decoration: none; font-size: 13px; font-weight: 400; margin-bottom: 2px; transition: all .15s; }
.nav-link i  { width: 16px; text-align: center; font-size: 14px; }
.nav-link:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--text); }
.nav-link.active { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font-weight: 600; }

/* ── HEADER ─────────────────────────────────────────────── */
.pos-header  { background: var(--s1); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.page-title  { font-size: 19px; font-weight: 700; color: var(--text); }
.page-sub    { font-size: 11px; color: var(--muted); }
.pos-clock   { background: var(--s2); border: 1px solid var(--border); border-radius: 7px; padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--text); }
.user-avatar { width: 34px; height: 34px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 13px; }
.badge-pending { background: rgba(245,158,11,.15); border: 1px solid rgba(245,158,11,.35); border-radius: 18px; padding: 4px 12px; font-size: 11px; color: var(--yellow); font-weight: 600; }

/* ── CARDS / PANELS ─────────────────────────────────────── */
.pos-card { background: var(--s2); border: 1px solid var(--border); border-radius: 11px; }
.pos-card-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text); }
.kpi-card { background: var(--s2); border: 1px solid var(--border); border-radius: 11px; padding: 17px; }
.kpi-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--text); }
.kpi-icon  { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; }

/* ── MESAS ──────────────────────────────────────────────── */
.table-btn { width: 92px; height: 92px; border-radius: 10px; border: 2px solid; background: var(--s2); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; position: relative; transition: all .15s; }
.table-btn:hover { filter: brightness(1.15); }
.table-num  { font-size: 21px; font-weight: 700; }
.table-cap  { font-size: 10px; color: var(--muted); }
.table-lbl  { font-size: 9px; font-weight: 600; text-transform: uppercase; }
.table-dot  { position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.zone-title { font-size: 11px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }

/* ── STATUS BADGES ──────────────────────────────────────── */
.badge-estado { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; border: 1px solid; }

/* ── MENU ITEMS ─────────────────────────────────────────── */
.menu-card    { background: var(--s2); border: 1px solid var(--border); border-radius: 11px; padding: 15px; transition: opacity .2s; }
.menu-card.inactive { opacity: .55; }
.toggle-sw    { width: 36px; height: 20px; border-radius: 10px; border: none; cursor: pointer; position: relative; transition: background .2s; flex-shrink: 0; }
.toggle-sw .knob { width: 14px; height: 14px; border-radius: 50%; background: #fff; position: absolute; top: 3px; transition: left .2s; }

/* ── ORDERS ─────────────────────────────────────────────── */
.order-card { background: var(--s2); border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.order-head { padding: 11px 15px; border-bottom: 1px solid var(--border); }
.order-body { padding: 10px 15px; }
.order-foot { padding: 9px 15px; border-top: 1px solid var(--border); }
.order-item-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12px; border-bottom: 1px solid rgba(42,46,69,.4); }
.order-item-row:last-child { border-bottom: none; }

/* ── KITCHEN TICKETS ────────────────────────────────────── */
.kitchen-ticket { background: var(--s2); border-radius: 11px; overflow: hidden; border: 2px solid; }
.ticket-head    { padding: 9px 14px; display: flex; justify-content: space-between; align-items: center; }
.ticket-status  { padding: 5px 14px; font-size: 11px; font-weight: 600; border-bottom: 1px solid var(--border); }
.ticket-body    { padding: 12px 14px; }
.ticket-item    { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; border-bottom: 1px solid rgba(42,46,69,.4); }
.ticket-item:last-child { border-bottom: none; }
.ticket-qty     { font-size: 18px; font-weight: 800; color: var(--accent); min-width: 24px; }
.ticket-foot    { padding: 9px 14px; border-top: 1px solid var(--border); }

/* ── FILTER TABS ─────────────────────────────────────────── */
.filter-tab { padding: 5px 14px; border-radius: 18px; border: 1px solid var(--border); background: transparent; color: var(--muted); font-family: inherit; font-size: 12px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; transition: all .15s; }
.filter-tab.active, .filter-tab:hover { border-color: currentColor; }
.tab-cnt { border-radius: 8px; padding: 0 6px; font-size: 10px; font-weight: 700; }

/* ── POS MODAL ───────────────────────────────────────────── */
.pos-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 1050; padding: 1rem; }
.pos-modal { background: var(--s1); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 870px; max-height: 90vh; display: flex; flex-direction: column; }
.pos-modal-header { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.pos-modal-body   { display: flex; flex: 1; overflow: hidden; }
.pos-item-grid    { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.pos-cat-tabs     { display: flex; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.pos-items        { flex: 1; overflow: auto; padding: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(175px,1fr)); gap: 10px; align-content: start; }
.pos-item-btn     { background: var(--s2); border: 1px solid var(--border); border-radius: 9px; padding: 12px; text-align: left; cursor: pointer; font-family: inherit; transition: all .15s; }
.pos-item-btn.in-cart { background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: var(--accent); }
.pos-cart         { width: 265px; border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.pos-cart-head    { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600; color: var(--text); }
.pos-cart-items   { flex: 1; overflow: auto; padding: 10px; }
.pos-cart-item    { background: var(--s2); border: 1px solid var(--border); border-radius: 7px; padding: 9px 10px; margin-bottom: 7px; }
.pos-cart-foot    { padding: 14px; border-top: 1px solid var(--border); }
.qty-btn          { width: 24px; height: 24px; border-radius: 5px; border: 1px solid var(--border); background: var(--s3); color: var(--text); cursor: pointer; font-size: 16px; display: grid; place-items: center; }

/* ── FORMS ──────────────────────────────────────────────── */
.pos-input  { background: var(--s2); border: 1px solid var(--border); border-radius: 7px; color: var(--text); font-family: inherit; font-size: 13px; padding: 8px 11px; width: 100%; outline: none; transition: border-color .15s; }
.pos-input:focus { border-color: var(--accent); }
.pos-select { background: var(--s2); border: 1px solid var(--border); border-radius: 7px; color: var(--text); font-family: inherit; font-size: 13px; padding: 8px 11px; width: 100%; outline: none; }
.pos-label  { font-size: 12px; color: var(--muted); display: block; margin-bottom: 5px; }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn-accent  { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 9px 16px; font-family: inherit; font-weight: 600; font-size: 13px; cursor: pointer; transition: opacity .15s; }
.btn-accent:hover { opacity: .9; }
.btn-accent:disabled { background: var(--dim); cursor: not-allowed; }
.btn-green   { background: var(--green); color: #fff; border: none; border-radius: 7px; padding: 7px 14px; font-family: inherit; font-weight: 600; font-size: 12px; cursor: pointer; }
.btn-ghost   { background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 7px; padding: 7px 14px; font-family: inherit; font-size: 12px; cursor: pointer; }
.btn-icon    { background: none; border: none; color: var(--muted); cursor: pointer; padding: 3px; }
.btn-icon:hover { color: var(--red); }

/* ── TABLE ──────────────────────────────────────────────── */
.pos-table { width: 100%; border-collapse: collapse; }
.pos-table th { text-align: left; padding: 6px 10px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--border); font-weight: 500; }
.pos-table td { padding: 9px 10px; font-size: 12px; border-bottom: 1px solid rgba(42,46,69,.3); }

/* ── MISC ───────────────────────────────────────────────── */
.text-accent { color: var(--accent); }
.text-green  { color: var(--green);  }
.text-yellow { color: var(--yellow); }
.text-muted-pos { color: var(--muted); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state i { font-size: 40px; opacity: .3; margin-bottom: 10px; }
.spinner { display: flex; align-items: center; justify-content: center; height: 200px; color: var(--muted); font-size: 13px; gap: 8px; }


/* ════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (≤ 1024px) y Mobile (≤ 768px)
   La app web está optimizada para desktop y tablet.
   Para teléfonos, usa la app Flutter.
   ════════════════════════════════════════════════════════════ */

/* ── Tablet: 768px – 1024px ────────────────────────────────── */
@media (max-width: 1024px) {

  /* Sidebar: compacto por defecto en tablet */
  .pos-sidebar {
    width: 62px !important;
    transition: width 0.25s ease;
  }
  .pos-sidebar .brand-name,
  .pos-sidebar .brand-sub,
  .pos-sidebar .nav-link span,
  .pos-sidebar #headerUserName,
  .pos-sidebar #headerUserRole { display: none !important; }

  /* Botón hamburger visible */
  #menuToggle { display: flex !important; }

  /* Sidebar expandido al hacer clic */
  .pos-sidebar.expanded {
    width: 218px !important;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1040;
    box-shadow: 4px 0 24px rgba(0,0,0,.6);
  }
  .pos-sidebar.expanded .brand-name,
  .pos-sidebar.expanded .brand-sub,
  .pos-sidebar.expanded .nav-link span,
  .pos-sidebar.expanded #headerUserName,
  .pos-sidebar.expanded #headerUserRole { display: block !important; }
  .pos-sidebar.expanded #headerUserName,
  .pos-sidebar.expanded #headerUserRole { display: block !important; }

  /* Overlay oscuro cuando sidebar expandido */
  #sidebarOverlay { display: none; }
  .sidebar-open #sidebarOverlay {
    display: block !important;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 1039;
  }

  /* Header: título más pequeño */
  .page-title { font-size: 16px !important; }

  /* KPI cards: 2 columnas en tablet */
  .row.g-3 > .col-3 { flex: 0 0 50%; max-width: 50%; }
  .row.g-3 > .col-4 { flex: 0 0 50%; max-width: 50%; }

  /* Gráficos: full width */
  .row.g-3 > .col-8,
  .row.g-3 > .col-6,
  .row.g-3 > .col-5,
  .row.g-3 > .col-7 { flex: 0 0 100%; max-width: 100%; }

  /* POS modal: casi full screen */
  .pos-modal { max-width: 98vw !important; max-height: 96vh !important; }
  .pos-cart  { width: 220px !important; }

  /* Mesas: botones un poco más pequeños */
  .table-btn { width: 78px !important; height: 78px !important; }

  /* Kitchen tickets: 2 columnas */
  .kitchen-ticket { min-width: 0; }

  /* Tablas: scroll horizontal */
  .pos-card table,
  .pos-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ── Mobile: ≤ 767px ─────────────────────────────────────────
   Nota: usa la app Flutter para operación diaria en teléfono.
   Esta vista es solo para consultas de emergencia.
   ──────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  /* KPI cards: 1 columna */
  .row.g-3 > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }

  /* Header compacto */
  .pos-header { padding: 8px 14px !important; }
  .page-title { font-size: 15px !important; }
  .page-sub   { display: none; }

  /* Ocultar reloj en móvil muy pequeño */
  .pos-clock  { display: none; }

  /* Main content: padding reducido */
  main.p-4 { padding: 12px !important; }

  /* POS modal: full screen */
  .pos-modal { max-width: 100vw !important; max-height: 100vh !important; border-radius: 0 !important; }
  .pos-modal-body { flex-direction: column !important; }
  .pos-cart  { width: 100% !important; border-left: none !important; border-top: 1px solid var(--border); max-height: 280px; }

  /* Mesas: botones más pequeños */
  .table-btn { width: 68px !important; height: 68px !important; }
  .table-num { font-size: 18px !important; }

  /* Panel detail en mesas: full width */
  .pos-main > .d-flex > div:last-child { width: 100% !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 500; border-radius: 16px 16px 0 0; }

  /* Formularios: inputs full width */
  .pos-input, .pos-select { width: 100% !important; }

  /* Ocultar columnas no esenciales en tablas */
  .pos-table th:nth-child(4),
  .pos-table td:nth-child(4) { display: none; }

  /* Filtros: wrap en columnas */
  .d-flex.gap-2.align-items-end { flex-direction: column !important; align-items: stretch !important; }
  .d-flex.gap-2.align-items-end > * { width: 100% !important; }
}

/* ── Touch targets ──────────────────────────────────────────── */
@media (pointer: coarse) {
  /* Botones más fáciles de tocar */
  .nav-link   { padding: 11px 10px !important; }
  .filter-tab { padding: 8px 14px !important; }
  .metodo-btn { padding: 10px 4px !important; }
  .qty-btn    { width: 32px !important; height: 32px !important; }
  .btn-accent, .btn-green, .btn-ghost { min-height: 40px; }
  input[type="number"], input[type="text"],
  input[type="password"], input[type="date"],
  input[type="time"], select { min-height: 42px; font-size: 16px !important; /* evita zoom en iOS */ }
}

/* ── Cocina: pantalla full en tablet ─────────────────────────── */
@media (max-width: 1024px) {
  .kitchen-ticket { font-size: 15px; }
  .ticket-qty     { font-size: 20px !important; }
  .ticket-head div b { font-size: 18px !important; }
}

/* ── Print styles (para tickets físicos) ────────────────────── */
@media print {
  .pos-sidebar, .pos-header, #toastWrap { display: none !important; }
  .pos-main { margin: 0; padding: 0; }
  main { padding: 0 !important; }
}
