/* =========================================================
   Antojitos La Ceiba — estilos propios sobre Bootstrap 5.3
   Todo lo de marca vive en las variables de :root.
   ========================================================= */

:root {
  --ac-brand:        #c1440e;   /* terracota */
  --ac-brand-dark:   #8f3209;
  --ac-brand-soft:   #fdece5;
  --ac-accent:       #f2a007;   /* amarillo maíz */
  --ac-green:        #1f7a5a;
  --ac-red:          #b02a37;

  --ac-side-bg:      #241713;
  --ac-side-bg-2:    #32201a;
  --ac-side-text:    #e7d9d3;
  --ac-side-muted:   #a98c82;

  --ac-body-bg:      #f6f4f1;
  --ac-card-bg:      #ffffff;
  --ac-border:       #e6e1db;
  --ac-text:         #2b2320;
  --ac-muted:        #8a7d76;

  --ac-sidebar-w:    248px;
  --ac-radius:       14px;
  --ac-shadow:       0 1px 2px rgba(43,35,32,.06), 0 8px 24px rgba(43,35,32,.06);
}

/* ---------- base ---------- */
body {
  background: var(--ac-body-bg);
  color: var(--ac-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; }
.text-muted-2 { color: var(--ac-muted) !important; }
/* tabular-nums alinea las cifras; el nowrap evita que "$1,234.50" se parta en
   dos renglones cuando la columna se angosta en el teléfono. */
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- layout ---------- */
.ac-shell { display: flex; min-height: 100vh; }

.ac-sidebar {
  width: var(--ac-sidebar-w);
  flex: 0 0 var(--ac-sidebar-w);
  background: linear-gradient(180deg, var(--ac-side-bg) 0%, var(--ac-side-bg-2) 100%);
  color: var(--ac-side-text);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1045;
  display: flex;
  flex-direction: column;
  transition: transform .22s ease;
}
.ac-main {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: var(--ac-sidebar-w);
  display: flex;
  flex-direction: column;
}
.ac-content { padding: 22px 26px 48px; }

/* ---------- marca ---------- */
.ac-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.ac-brand-logo {
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--ac-brand) 0%, var(--ac-accent) 100%);
  display: grid; place-items: center;
  font-size: 1.35rem;
}
.ac-brand-name { font-weight: 700; line-height: 1.1; letter-spacing: .2px; }
.ac-brand-sub  { font-size: .72rem; color: var(--ac-side-muted); }

/* ---------- navegación ---------- */
.ac-nav { padding: 14px 10px; overflow-y: auto; flex: 1 1 auto; }
.ac-nav-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .9px;
  color: var(--ac-side-muted); padding: 14px 12px 6px; font-weight: 600;
}
.ac-nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin-bottom: 2px;
  border-radius: 10px;
  color: var(--ac-side-text);
  font-size: .925rem;
  transition: background .15s ease, color .15s ease;
}
.ac-nav-link i { font-size: 1.05rem; width: 20px; text-align: center; opacity: .85; }
.ac-nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.ac-nav-link.active {
  background: var(--ac-brand);
  color: #fff;
  box-shadow: 0 6px 16px rgba(193,68,14,.35);
}
.ac-nav-link.active i { opacity: 1; }
.ac-nav-badge { margin-left: auto; font-size: .7rem; }

.ac-side-foot {
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: .75rem; color: var(--ac-side-muted);
}

/* ---------- topbar ---------- */
.ac-topbar {
  position: sticky; top: 0; z-index: 1030;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--ac-border);
  padding: 12px 26px;
  display: flex; align-items: center; gap: 14px;
}
.ac-topbar h1 { font-size: 1.12rem; font-weight: 700; margin: 0; }
.ac-topbar .ac-sub { font-size: .78rem; color: var(--ac-muted); }
.ac-burger { display: none; }

/* ---------- tarjetas ---------- */
.card {
  border: 1px solid var(--ac-border);
  border-radius: var(--ac-radius);
  background: var(--ac-card-bg);
  box-shadow: var(--ac-shadow);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--ac-border);
  padding: 14px 18px;
  font-weight: 600;
}
.card-body { padding: 18px; }

/* ---------- KPI ---------- */
.kpi { display: flex; gap: 14px; align-items: flex-start; }
.kpi-icon {
  width: 46px; height: 46px; flex: 0 0 46px;
  border-radius: 12px; display: grid; place-items: center;
  font-size: 1.25rem;
}
.kpi-label { font-size: .78rem; color: var(--ac-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.15; }
.kpi-foot  { font-size: .78rem; color: var(--ac-muted); }

.bg-brand-soft { background: var(--ac-brand-soft); color: var(--ac-brand); }
.bg-green-soft { background: #e4f3ed; color: var(--ac-green); }
.bg-amber-soft { background: #fdf2dc; color: #a56a04; }
.bg-red-soft   { background: #fbe6e8; color: var(--ac-red); }
.bg-blue-soft  { background: #e6eefb; color: #14548f; }

/* ---------- tablas ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .5px;
  color: var(--ac-muted); font-weight: 700;
  border-bottom: 1px solid var(--ac-border);
  padding: 10px 14px; white-space: nowrap;
}
.table > tbody td { padding: 11px 14px; vertical-align: middle; border-color: #f0ece7; }
.table-hover > tbody > tr:hover > * { background: #faf8f6; }
.table-wrap { overflow-x: auto; }
/* Listas tipo Odoo: un renglón por registro, más apretado, y el renglón
   entero se puede tocar para abrirlo. */
.tabla-lista > tbody td { padding-top: 8px; padding-bottom: 8px; white-space: nowrap; }
.tabla-lista > tbody td:first-child { white-space: normal; }
.tabla-lista .fila-clic { cursor: pointer; }
/* El menú de columnas vive dentro del encabezado: que no herede sus mayúsculas. */
.tabla-lista thead .dropdown-menu {
  text-transform: none; letter-spacing: normal; font-weight: 400;
  font-size: .875rem; color: var(--bs-body-color);
}

/* ---------- botones ---------- */
.btn { border-radius: 10px; font-weight: 500; }
.btn-brand { background: var(--ac-brand); border-color: var(--ac-brand); color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: var(--ac-brand-dark); border-color: var(--ac-brand-dark); color: #fff; }
.btn-outline-brand { border-color: var(--ac-brand); color: var(--ac-brand); }
.btn-outline-brand:hover { background: var(--ac-brand); color: #fff; }

.badge-soft-green { background: #e4f3ed; color: var(--ac-green); }
.badge-soft-red   { background: #fbe6e8; color: var(--ac-red); }
.badge-soft-amber { background: #fdf2dc; color: #a56a04; }
.badge-soft-gray  { background: #efebe7; color: #6b5f59; }

/* ---------- POS ---------- */
.pos-grid { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
.pos-cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pos-cat {
  border: 1px solid var(--ac-border); background: #fff;
  border-radius: 999px; padding: 6px 14px; font-size: .86rem; cursor: pointer;
  transition: all .15s ease;
}
.pos-cat.active { background: var(--ac-brand); border-color: var(--ac-brand); color: #fff; }

.pos-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.pos-item {
  background: #fff; border: 1px solid var(--ac-border); border-radius: var(--ac-radius);
  padding: 14px 12px; cursor: pointer; text-align: left;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.pos-item:hover { transform: translateY(-2px); box-shadow: var(--ac-shadow); border-color: var(--ac-brand); }
.pos-item:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.pos-item-emoji { font-size: 1.7rem; line-height: 1; }
.pos-item-name  { font-weight: 600; font-size: .9rem; margin-top: 8px; }
.pos-item-price { color: var(--ac-brand); font-weight: 700; }
.pos-item-stock { font-size: .72rem; color: var(--ac-muted); }

.pos-ticket { position: sticky; top: 84px; display: flex; flex-direction: column; max-height: calc(100vh - 110px); }
.pos-lines { overflow-y: auto; flex: 1 1 auto; min-height: 120px; }
.pos-line { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px dashed #eee6df; }
.pos-line:last-child { border-bottom: 0; }
.pos-line-name { font-size: .88rem; font-weight: 600; line-height: 1.2; }
.pos-line-unit { font-size: .74rem; color: var(--ac-muted); }
.pos-qty { display: flex; align-items: center; gap: 4px; }
.pos-qty button {
  width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--ac-border);
  background: #fff; line-height: 1; display: grid; place-items: center;
}
.pos-qty span { min-width: 26px; text-align: center; font-weight: 600; }
.pos-empty { text-align: center; color: var(--ac-muted); padding: 34px 10px; }

/* ---------- utilidades ---------- */
.stock-bar { height: 5px; border-radius: 999px; background: #efebe7; overflow: hidden; }
.stock-bar > span { display: block; height: 100%; border-radius: 999px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Un hijo de flex no baja de su contenido a menos que se le diga; sin esto,
   text-truncate no recorta nada dentro de una tarjeta o un renglón. */
.min-w-0 { min-width: 0; }

.empty-state { text-align: center; padding: 46px 20px; color: var(--ac-muted); }
.empty-state i { font-size: 2.4rem; opacity: .35; display: block; margin-bottom: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .pos-grid { grid-template-columns: 1fr 330px; }
}
@media (max-width: 991.98px) {
  .ac-sidebar { transform: translateX(-100%); }
  .ac-sidebar.open { transform: translateX(0); box-shadow: 0 0 0 100vw rgba(0,0,0,.4); }
  .ac-main { margin-left: 0; }
  .ac-burger { display: inline-flex; }
  .pos-grid { grid-template-columns: 1fr; }
  .pos-ticket { position: static; max-height: none; }
}
@media (max-width: 575.98px) {
  .ac-content { padding: 16px 16px 40px; }
  .ac-topbar { padding: 10px 16px; }
  .kpi-value { font-size: 1.35rem; }

  /* La cabecera de una tarjeta trae título y filtros en el mismo renglón. En
     una pantalla angosta no caben, y sin esto se salen de la tarjeta en vez de
     acomodarse: el filtro se va debajo del título. */
  .card-header.d-flex { flex-wrap: wrap; gap: 8px; }
  .card-header .form-select,
  .card-header .form-control { max-width: 100%; }

  /* Lo mismo para el pie de una tabla, donde conviven el conteo y el paginador. */
  .card-body.d-flex { flex-wrap: wrap; gap: 8px; }

  /* Un aviso largo no debe rebasar el ancho de la pantalla. */
  .toast-container { max-width: calc(100vw - 24px); }

  /* Los botones de acción de cada renglón se quedan juntos aunque la tabla
     ruede de lado. */
  .table td .btn-sm { padding: .25rem .5rem; }

  /* El modal ocupa el ancho disponible, con su margen. */
  .modal-dialog { margin: .5rem; }

  /* Si el título es largo, el botón de acción se iría fuera de la pantalla.
     Que baje a su propio renglón. */
  .ac-topbar { flex-wrap: wrap; row-gap: 8px; }

  /* En dos columnas de teléfono, el icono de 46px se come el ancho que
     necesita la cifra y el monto se sale de la tarjeta. Pasa arriba, y el
     número se queda con la tarjeta completa. */
  .kpi { flex-direction: column; gap: 8px; }
  .kpi-icon { width: 38px; height: 38px; flex: 0 0 38px; font-size: 1.05rem; }
  .kpi > div:last-child { min-width: 0; width: 100%; }
}

/* ---------- impresión de ticket ---------- */
@media print {
  .ac-sidebar, .ac-topbar, .no-print { display: none !important; }
  .ac-main { margin-left: 0; }
  body { background: #fff; }
}

/* ---------- pantalla de acceso ---------- */
.pantalla-acceso {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(193,68,14,.10), transparent 60%),
    var(--ac-body-bg);
}
.acceso-caja {
  width: 100%;
  max-width: 400px;
  background: var(--ac-card-bg);
  border: 1px solid var(--ac-border);
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(43,35,32,.06), 0 20px 50px rgba(43,35,32,.10);
  padding: 34px 30px;
}
.acceso-logo {
  width: 64px; height: 64px; margin: 0 auto;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--ac-brand) 0%, var(--ac-accent) 100%);
  display: grid; place-items: center;
  font-size: 2rem;
  box-shadow: 0 10px 24px rgba(193,68,14,.28);
}
.pantalla-acceso .form-control:focus,
.pantalla-acceso .btn-brand:focus {
  border-color: var(--ac-brand);
  box-shadow: 0 0 0 .2rem rgba(193,68,14,.18);
}

/* ---------- quién está usando el sistema ---------- */
.ac-avatar {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 50%;
  background: var(--ac-brand);
  color: #fff;
  display: grid; place-items: center;
  font-size: .82rem; font-weight: 700;
}

/* ---------- lista del mandado ---------- */
tr.comprado td { opacity: .45; text-decoration: line-through; }
tr.comprado td:first-child { opacity: 1; text-decoration: none; }

@media print {
  /* al imprimir solo interesa la lista, no el tablero completo */
  .ac-content > .row,
  .ac-content > .card:not(#lista-compras),
  .ac-content > .mb-3:not(#lista-compras) { display: none !important; }
  #lista-compras { border: 0; box-shadow: none; }
  #lista-compras .card-header { border-bottom: 1px solid #ddd; }
}

/* ---------- fotos de producto ---------- */
.foto-producto {
  width: 72px; height: 72px; flex: 0 0 72px;
  border-radius: 14px;
  border: 1px dashed var(--ac-border);
  background: #faf8f6;
  display: grid; place-items: center;
  overflow: hidden;
  font-size: 1.9rem;
}
.foto-producto img { width: 100%; height: 100%; object-fit: cover; }

.mini-producto {
  width: 30px; height: 30px;
  border-radius: 8px;
  object-fit: cover;
  vertical-align: middle;
}

.pos-item-foto {
  width: 100%; height: 66px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  margin-bottom: 6px;
}
.pos-item-alcanza { font-size: .72rem; color: var(--ac-muted); }

/* ---------- lector de código de barras ---------- */
.lector-activo { border-color: var(--ac-brand) !important; box-shadow: 0 0 0 .2rem rgba(193,68,14,.15); }

/* ---------- elegir rol ---------- */
.rol-opciones { display: grid; gap: 10px; }
.rol-opcion {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--ac-border); border-radius: 12px;
  padding: 12px 14px; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.rol-opcion:hover { border-color: var(--ac-brand); }
.rol-opcion:has(input:checked) { border-color: var(--ac-brand); background: var(--ac-brand-soft); }
.rol-opcion input { margin-top: 3px; accent-color: var(--ac-brand); }

/* ---------- mientras cargan las tablas ---------- */
.barra-fantasma {
  display: block;
  height: 11px;
  border-radius: 999px;
  background: linear-gradient(90deg, #efebe7 0%, #f8f5f2 50%, #efebe7 100%);
  background-size: 200% 100%;
  animation: fantasma 1.3s ease-in-out infinite;
}
@keyframes fantasma {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.cargando-fila td { padding-top: 15px; padding-bottom: 15px; }

/* el letrero junto al título de cada tabla */
.estado-carga {
  display: inline-flex; align-items: center;
  font-size: .75rem; font-weight: 500;
  padding: 3px 10px; border-radius: 999px;
  margin-left: 8px; vertical-align: middle;
}
.estado-carga .spinner-border { width: .7rem; height: .7rem; border-width: .13em; }
.es-cargando { background: #efebe7; color: var(--ac-muted); }
.es-ok       { background: #e4f3ed; color: var(--ac-green); }
.es-error    { background: #fbe6e8; color: var(--ac-red); }

/* que no se note el salto al cambiar de estado */
@media (prefers-reduced-motion: reduce) {
  .barra-fantasma { animation: none; }
}

/* ---------- el menú del punto de venta mientras carga ---------- */
.pos-cargando {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  color: var(--ac-muted);
}
.pos-cargando .spinner-border { color: var(--ac-brand); width: 2rem; height: 2rem; }

/* ---------- códigos de barras de un producto ---------- */
.codigos-lista { display: flex; flex-wrap: wrap; gap: 6px; }
.codigo-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f3efec; border: 1px solid var(--ac-border);
  border-radius: 999px; padding: 4px 6px 4px 12px;
  font-size: .82rem; font-variant-numeric: tabular-nums;
}
.codigo-chip button {
  border: 0; background: none; line-height: 1;
  color: var(--ac-muted); padding: 2px 4px; border-radius: 50%;
}
.codigo-chip button:hover { color: var(--ac-red); background: #fbe6e8; }
.codigos-vacio { font-size: .82rem; color: var(--ac-muted); font-style: italic; }

/* ---------- logo del negocio ---------- */
.ac-brand-logo.con-logo, .acceso-logo.con-logo { background: #fff; padding: 0; overflow: hidden; }
.ac-brand-logo img, .acceso-logo img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- ficha de producto ----------
   El formulario de producto con la forma de una ficha de Odoo: nombre
   grande, casillas debajo, foto a la derecha y grupos de etiqueta | campo.
   Los campos van con solo la línea de abajo, que se pinta con la marca al
   enfocarlos. */
.ficha { padding: 20px 28px; }
.ficha-cabecera { display: flex; gap: 24px; align-items: flex-start; }
.ficha-rotulo { font-size: .78rem; color: var(--ac-muted); font-weight: 600; margin-bottom: 2px; }
.ficha .ficha-titulo {
  font-size: 1.7rem; font-weight: 700; padding: 2px 0;
}
.ficha-casillas { display: flex; flex-wrap: wrap; gap: 6px 28px; margin-top: 10px; }
.ficha-casillas .form-check-label { font-weight: 600; }
.ficha-foto { width: 120px; flex: 0 0 120px; text-align: center; }
.ficha-foto .foto-producto { width: 120px; height: 120px; }
.ficha-grupo {
  font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--ac-muted); border-bottom: 1px solid var(--ac-border);
  padding-bottom: 6px; margin-bottom: 10px;
}
.ficha-fila {
  display: grid; grid-template-columns: 38% 1fr; gap: 12px; align-items: start;
  padding: 5px 0;
}
.ficha-etiqueta { font-weight: 600; font-size: .9rem; padding-top: 7px; margin: 0; }
.ficha .form-control, .ficha .form-select {
  border: 0; border-bottom: 1px solid var(--ac-border); border-radius: 0;
  background-color: transparent; box-shadow: none; padding-left: 2px;
}
.ficha .form-control:focus, .ficha .form-select:focus {
  border-bottom-color: var(--ac-brand); box-shadow: none;
}
.ficha .form-control[readonly] { color: var(--ac-muted); }
.ficha .input-group-text {
  border: 0; border-bottom: 1px solid var(--ac-border); border-radius: 0;
  background: transparent; color: var(--ac-muted); padding-left: 0;
}
.ficha .input-group .btn { border-radius: 8px !important; }
@media (max-width: 575.98px) {
  .ficha { padding: 16px; }
  .ficha-cabecera { flex-direction: column-reverse; gap: 12px; }
  .ficha-foto { width: 100%; flex: none; display: flex; gap: 12px; align-items: center; text-align: left; }
  .ficha-foto .foto-producto { width: 72px; height: 72px; }
  .ficha-fila { grid-template-columns: 1fr; gap: 2px; }
  .ficha-etiqueta { padding-top: 0; }
}

/* ---------- buscador en los select (Tom Select) ----------
   La lista cuelga del <body>, así que tiene que quedar por encima de los
   modales (1055 y los que se apilan). */
.ts-dropdown { z-index: 1100; }
.ts-wrapper.form-select-sm .ts-control, .ts-wrapper.form-select-sm.single .ts-control { min-height: 31px; padding-top: 3px; padding-bottom: 3px; }

/* La casilla de selección de las listas, como en Odoo: angosta y a la izquierda. */
.col-sel { width: 1%; padding-right: 0 !important; }
