/* ============================================
   BUFET ESCOLAR — Sistema GI Design
   ============================================ */

:root {
  --gi-blue-dark: #1a2744;
  --gi-blue:      #2563eb;
  --gi-green:     #16a34a;
  --gi-red:       #dc2626;
  --gi-orange:    #ea580c;
  --gi-border:    #e2e8f0;
  --gi-bg:        #f1f5f9;
  --gi-light:     #ffffff;
  --gi-text:      #0f172a;
  --gi-text2:     #475569;
  --gi-text3:     #94a3b8;

  --sidebar-w: 240px;
  --header-h: 56px;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,.10);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
}

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

html, body {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  background: var(--gi-bg);
  color: var(--gi-text);
  height: 100%;
}

a { color: var(--gi-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================
   LAYOUT
   ============================================ */
.gi-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.gi-sidebar {
  width: var(--sidebar-w);
  background: var(--gi-blue-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .25s ease;
}

.gi-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .02em;
}

.gi-sidebar-logo .logo-icon {
  width: 34px; height: 34px;
  background: var(--gi-blue);
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 18px; flex-shrink: 0;
}

.gi-sidebar-logo .logo-sub {
  font-size: 10px;
  font-weight: 400;
  color: rgba(255,255,255,.55);
  display: block;
  letter-spacing: .03em;
}

/* Acordeón de navegación */
.gi-nav { flex: 1; overflow-y: auto; padding: 8px 0; }

.gi-nav-group { border-bottom: 1px solid rgba(255,255,255,.06); }

.gi-nav-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.45);
  cursor: pointer;
  user-select: none;
  transition: color .2s;
}
.gi-nav-group-title:hover { color: rgba(255,255,255,.75); }
.gi-nav-group-title .arrow {
  font-size: 10px;
  transition: transform .25s;
}
.gi-nav-group.open .arrow { transform: rotate(90deg); }

.gi-nav-items { display: none; }
.gi-nav-group.open .gi-nav-items { display: block; }

.gi-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px 9px 26px;
  color: rgba(255,255,255,.75);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.gi-nav-item:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}
.gi-nav-item.active {
  background: rgba(37,99,235,.25);
  color: #fff;
  border-left-color: var(--gi-blue);
}
.gi-nav-item .nav-icon { font-size: 15px; width: 18px; text-align: center; }

/* ---- MAIN ---- */
.gi-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.gi-topbar {
  height: var(--header-h);
  background: var(--gi-light);
  border-bottom: 1px solid var(--gi-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.gi-topbar-title {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
}

.gi-topbar .burger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  color: var(--gi-text);
  padding: 4px;
}

.gi-content {
  padding: 24px;
  flex: 1;
}

/* ============================================
   CARDS
   ============================================ */
.gi-card {
  background: var(--gi-light);
  border: 1px solid var(--gi-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.gi-card-title {
  font-size: 15px;
  font-weight: 700;
}

.gi-card-body { padding: 20px; }

/* ============================================
   TABLAS
   ============================================ */
.gi-table-wrap { overflow-x: auto; }

.gi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.gi-table th {
  background: var(--gi-bg);
  color: var(--gi-text2);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--gi-border);
  white-space: nowrap;
}

.gi-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gi-border);
  vertical-align: middle;
}

.gi-table tr:last-child td { border-bottom: none; }
.gi-table tbody tr:hover { background: #f8fafc; }

/* ============================================
   BOTONES
   ============================================ */
.gi-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
  text-decoration: none;
}
.gi-btn:hover { opacity: .88; text-decoration: none; }
.gi-btn:active { transform: scale(.97); }

.gi-btn-primary { background: var(--gi-blue);    color: #fff; }
.gi-btn-success { background: var(--gi-green);   color: #fff; }
.gi-btn-danger  { background: var(--gi-red);     color: #fff; }
.gi-btn-warning { background: var(--gi-orange);  color: #fff; }
.gi-btn-ghost   { background: transparent; color: var(--gi-text2); border: 1px solid var(--gi-border); }
.gi-btn-sm      { padding: 5px 10px; font-size: 12px; }
.gi-btn-lg      { padding: 12px 24px; font-size: 15px; }
.gi-btn-block   { width: 100%; justify-content: center; }

/* ============================================
   BADGES / PILLS
   ============================================ */
.gi-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.gi-badge-green  { background: #dcfce7; color: #15803d; }
.gi-badge-red    { background: #fee2e2; color: #b91c1c; }
.gi-badge-blue   { background: #dbeafe; color: #1d4ed8; }
.gi-badge-orange { background: #ffedd5; color: #c2410c; }
.gi-badge-gray   { background: #f1f5f9; color: #64748b; }

/* ============================================
   FORMULARIOS
   ============================================ */
.gi-form-group { margin-bottom: 16px; }

.gi-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--gi-text2);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.gi-input, .gi-select, .gi-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gi-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--gi-text);
  background: var(--gi-light);
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
}
.gi-input:focus, .gi-select:focus, .gi-textarea:focus {
  outline: none;
  border-color: var(--gi-blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.gi-textarea { resize: vertical; min-height: 80px; }

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

/* ============================================
   MODALES
   ============================================ */
.gi-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.gi-modal-overlay.open { display: flex; }

.gi-modal {
  background: var(--gi-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
}
.gi-modal-lg { max-width: 760px; }
.gi-modal-xl { max-width: 960px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-16px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.gi-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gi-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.gi-modal-title { font-size: 15px; font-weight: 700; }
.gi-modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--gi-text3); line-height: 1;
  padding: 4px;
}
.gi-modal-close:hover { color: var(--gi-red); }

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

/* ============================================
   STATS / KPI CARDS
   ============================================ */
.gi-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.gi-stat-card {
  background: var(--gi-light);
  border: 1px solid var(--gi-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.gi-stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--gi-text3);
  margin-bottom: 6px;
}

.gi-stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.gi-stat-value.green { color: var(--gi-green); }
.gi-stat-value.red   { color: var(--gi-red);   }
.gi-stat-value.blue  { color: var(--gi-blue);  }

/* ============================================
   ALERTAS
   ============================================ */
.gi-alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.gi-alert-success { background: #dcfce7; border: 1px solid #86efac; color: #15803d; }
.gi-alert-danger  { background: #fee2e2; border: 1px solid #fca5a5; color: #b91c1c; }
.gi-alert-info    { background: #dbeafe; border: 1px solid #93c5fd; color: #1d4ed8; }
.gi-alert-warning { background: #ffedd5; border: 1px solid #fdba74; color: #c2410c; }

/* ============================================
   SEARCH BOX
   ============================================ */
.gi-search {
  position: relative;
}
.gi-search input {
  padding-left: 34px;
}
.gi-search::before {
  content: "🔍";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  pointer-events: none;
}

/* ============================================
   AUTOCOMPLETE
   ============================================ */
.gi-autocomplete {
  position: relative;
}
.gi-autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--gi-light);
  border: 1px solid var(--gi-border);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  z-index: 300;
  max-height: 220px;
  overflow-y: auto;
  display: none;
}
.gi-autocomplete-list.open { display: block; }
.gi-autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: background .12s;
}
.gi-autocomplete-item:hover,
.gi-autocomplete-item.selected { background: #eff6ff; }
.gi-autocomplete-item .item-sub {
  font-size: 11px;
  color: var(--gi-text3);
}

/* ============================================
   POS - CARGA DE PEDIDOS
   ============================================ */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

.pos-productos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.pos-producto-btn {
  background: var(--gi-light);
  border: 1px solid var(--gi-border);
  border-radius: var(--radius);
  padding: 14px 10px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  transition: border-color .15s, background .15s, transform .1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.pos-producto-btn:hover {
  border-color: var(--gi-blue);
  background: #eff6ff;
}
.pos-producto-btn:active { transform: scale(.96); }
.pos-producto-btn .prod-emoji { font-size: 24px; }
.pos-producto-btn .prod-precio {
  color: var(--gi-green);
  font-size: 13px;
  font-weight: 700;
}

.pos-cart {
  position: sticky;
  top: calc(var(--header-h) + 16px);
}

.pos-cart-items { max-height: 320px; overflow-y: auto; }

.pos-cart-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--gi-border);
  font-size: 13px;
}
.pos-cart-item:last-child { border-bottom: none; }
.pos-cart-item .item-name { flex: 1; }
.pos-cart-item .item-qty {
  display: flex; align-items: center; gap: 4px;
}
.pos-cart-item .qty-btn {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--gi-border);
  background: var(--gi-bg);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  display: grid; place-items: center;
  transition: background .12s;
}
.pos-cart-item .qty-btn:hover { background: var(--gi-border); }
.pos-cart-item .qty-num { min-width: 22px; text-align: center; font-weight: 700; }
.pos-cart-item .item-sub { min-width: 70px; text-align: right; font-weight: 700; color: var(--gi-green); }
.pos-cart-item .remove-btn {
  background: none; border: none; cursor: pointer;
  color: var(--gi-text3); font-size: 16px; padding: 2px;
  transition: color .12s;
}
.pos-cart-item .remove-btn:hover { color: var(--gi-red); }

.pos-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-top: 2px solid var(--gi-border);
  font-size: 16px;
  font-weight: 700;
}
.pos-total .total-amt { color: var(--gi-green); font-size: 20px; }

.pos-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--gi-text3);
  font-size: 13px;
}
.pos-empty .empty-icon { font-size: 36px; margin-bottom: 8px; }

/* Filtros de categoría POS */
.pos-cat-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.pos-cat-btn {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--gi-border);
  background: var(--gi-light);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.pos-cat-btn:hover { border-color: var(--gi-blue); }
.pos-cat-btn.active { background: var(--gi-blue); color: #fff; border-color: var(--gi-blue); }

/* ============================================
   CUENTA CORRIENTE
   ============================================ */
.cc-movimiento {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--gi-border);
  font-size: 13px;
}
.cc-movimiento:last-child { border-bottom: none; }
.cc-movimiento .mov-icon { font-size: 18px; }
.cc-movimiento .mov-desc { flex: 1; }
.cc-movimiento .mov-fecha { color: var(--gi-text3); font-size: 12px; }
.cc-movimiento .mov-monto {
  font-weight: 700;
  font-size: 14px;
  min-width: 90px;
  text-align: right;
}
.cc-movimiento.cargo .mov-monto { color: var(--gi-red); }
.cc-movimiento.pago  .mov-monto { color: var(--gi-green); }

/* ============================================
   ESTADO DE CUENTA / REPORTE
   ============================================ */
.reporte-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 24px;
}
.reporte-header h1 { font-size: 20px; }
.reporte-header p { color: var(--gi-text2); font-size: 13px; }

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
#gi-toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gi-toast {
  background: #1e293b;
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn .2s ease;
  max-width: 320px;
}
.gi-toast.success { border-left: 4px solid var(--gi-green); }
.gi-toast.error   { border-left: 4px solid var(--gi-red);   }
.gi-toast.info    { border-left: 4px solid var(--gi-blue);  }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: none; }
}

/* ============================================
   PRINT
   ============================================ */
@media print {
  .gi-sidebar, .gi-topbar, .no-print { display: none !important; }
  .gi-main { margin-left: 0 !important; }
  .gi-content { padding: 0 !important; }
  .gi-card { box-shadow: none !important; border: 1px solid #ccc; }
  .gi-btn { display: none !important; }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .gi-sidebar {
    width: 240px;
    transform: translateX(-100%);
  }
  .gi-sidebar.open { transform: translateX(0); }

  .gi-main { margin-left: 0; }

  .gi-topbar .burger { display: block; }

  .gi-content { padding: 14px; }

  .gi-stats { grid-template-columns: 1fr 1fr; }

  .pos-layout {
    grid-template-columns: 1fr;
  }
  .pos-cart { position: static; }
  .pos-productos-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }

  .gi-form-row-2,
  .gi-form-row-3 { grid-template-columns: 1fr; }

  .gi-modal { margin: 8px; }
}

@media (max-width: 480px) {
  .gi-stats { grid-template-columns: 1fr; }
  .pos-productos-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Overlay para cerrar sidebar en mobile */
.gi-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 199;
}
.gi-overlay.open { display: block; }
