/* ════════════════════════════════════════════════════════════
   Posfy — hoja de estilos base (POS/ERP · República Dominicana)
   Complementa a Tailwind CDN: aquí viven las clases compuestas
   que se repiten en todas las páginas (nav, tablas, badges, modales).
   ════════════════════════════════════════════════════════════ */

:root {
  --brand-50:  #f0fdfa;
  --brand-100: #ccfbf1;
  --brand-200: #99f6e4;
  --brand-500: #14b8a6;
  --brand-600: #0d9488;
  --brand-700: #0f766e;
  --brand-800: #115e59;
  --ink:       #334155;
  --ink-soft:  #64748b;
  --line:      #eef2f7;
}

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  color: var(--ink);
}

/* Titulares y logotipo en Outfit; el cuerpo sigue en Inter. Si la fuente no carga
   (sin internet, que en un colmado pasa), cae en Inter y la página no se descuadra. */
.font-display, .font-logo {
  font-family: 'Outfit', 'Inter', -apple-system, system-ui, sans-serif;
  letter-spacing: -.015em;
}

/* ───────── Topbar ───────── */
.topbar {
  background: linear-gradient(90deg, var(--brand-800) 0%, var(--brand-700) 60%, var(--brand-600) 100%);
  color: #fff;
}
.topbar-select {
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: .55rem;
  padding: .4rem 1.9rem .4rem .7rem;
  font-size: .8rem;
  max-width: 15rem;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .5rem center;
  background-size: 1rem;
}
.topbar-select:focus { outline: none; box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); }
.topbar-select option { color: #0f172a; background: #fff; }

/* ───────── Sidebar ───────── */
.nav-group {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: .5rem .75rem; border-radius: .625rem; color: #475569;
  transition: background .12s, color .12s;
}
.nav-group:hover { background: #f4f8f8; color: #0f172a; }
.nav-group-label { font-size: .82rem; font-weight: 700; letter-spacing: .01em; }
.nav-group-active { background: var(--brand-50); color: var(--brand-800); }
/* `flex` y no `block`: el elemento lleva icono + texto en la misma línea.
   Lo ponía el `flex` de Tailwind en el marcado, pero app.css se carga DESPUÉS
   y, a igual especificidad, gana el último: `display:block` pisaba a
   `display:flex` y el icono caía encima del texto. Mientras el CDN de Tailwind
   inyectaba su <style> al final del <head> ganaba el otro, así que el fallo
   apareció justo al compilar el CSS. Lo que el elemento ES no se deja en manos
   del orden de carga. */
.nav-item {
  display: flex; align-items: center; gap: .625rem;
  padding: .4rem .75rem; border-radius: .55rem;
  font-size: .82rem; color: var(--ink-soft);
  transition: background .12s, color .12s;
}
.nav-item:hover { background: #f4f8f8; color: #0f172a; }
.nav-item-active {
  background: var(--brand-600); color: #fff !important; font-weight: 600;
  box-shadow: 0 1px 2px rgba(13, 148, 136, .3);
}
.nav-item-active:hover { background: var(--brand-700); color: #fff !important; }
.nav-section {
  font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  color: #94a3b8; text-transform: uppercase;
}
.nav-icon { width: 1rem; height: 1rem; flex: none; color: var(--brand-600); }

/* ───────── Tarjetas ───────── */
.card {
  background: #fff; border: 1px solid var(--line);
  border-radius: .85rem; box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.card-hover { transition: box-shadow .15s, transform .15s; }
.card-hover:hover { box-shadow: 0 6px 18px rgba(15, 23, 42, .08); transform: translateY(-1px); }

/* KPI */
/* Solo la tarjeta que lleva una cifra se convierte en contenedor de medida
   (ver .kpi-value). Ponerlo en TODA `.card` haría que un `.modal-overlay`
   anidado —que es `position: fixed`— se anclara a la tarjeta en vez de a la
   ventana: el modal saldría dentro de la tarjeta, encogido. */
.card:has(.kpi-value) { container-type: inline-size; }
.kpi-label { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #94a3b8; }
/* El tamaño baja con el ancho disponible: «RD$12,764,685.40» a 1.5rem se salía
   de la tarjeta y quedaba cortado a media cifra, que en dinero es peor que no
   mostrar nada. `clamp` lo encoge hasta donde quepa sin tocar las cifras cortas;
   el recorte con puntos suspensivos es la última red, no el comportamiento
   normal: una cifra a medias no se puede leer de ninguna manera. */
.kpi-value {
  /* Fallback por viewport para navegadores sin container queries… */
  font-size: clamp(.85rem, .78vw + .58rem, 1.5rem);
  /* …y la medida buena: el tamaño depende del ancho de SU tarjeta, no del de la
     pantalla. Con cinco tarjetas en fila, la pantalla es ancha y la tarjeta no. */
  font-size: clamp(.9rem, 9.6cqi, 1.5rem);
  font-weight: 700; color: #0f172a;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-hint  { font-size: .72rem; color: #94a3b8; }

/* ───────── Tablas ───────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .82rem; }
.tbl thead th {
  padding: .6rem .85rem; text-align: left; font-size: .68rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: #94a3b8;
  background: #fcfdfe; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl thead th:last-child { text-align: right; }
.tbl tbody td { padding: .6rem .85rem; border-bottom: 1px solid #f3f6fa; color: var(--ink); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover td { background: #f8fafc; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-empty { padding: 2.25rem; text-align: center; color: #94a3b8; font-size: .82rem; }

/* ───────── Estado vacío (empty state con CTA) ───────── */
.empty-state { padding: 3rem 1.5rem; text-align: center; }
.empty-icon {
  width: 3.5rem; height: 3.5rem; margin: 0 auto 1rem; border-radius: 9999px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-50); color: var(--brand-600);
}
.empty-title { font-size: 1rem; font-weight: 700; color: #1e293b; }
.empty-text  { font-size: .85rem; color: var(--ink-soft); margin: .35rem auto 1.25rem; max-width: 30rem; }

/* ───────── Badges de estado ───────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .12rem .55rem; border-radius: 9999px;
  font-size: .68rem; font-weight: 600; line-height: 1.5;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 9999px; background: currentColor; }
.badge-plain::before { display: none; }
.badge-green  { background: #ecfdf5; color: #059669; }
.badge-gray   { background: #f1f5f9; color: #64748b; }
.badge-red    { background: #fef2f2; color: #dc2626; }
.badge-blue   { background: #eff6ff; color: #2563eb; }
.badge-amber  { background: #fffbeb; color: #d97706; }
.badge-teal   { background: #f0fdfa; color: #0d9488; }
.badge-violet { background: #f5f3ff; color: #7c3aed; }

/* ───────── Formularios ───────── */
.input, .select, .textarea {
  width: 100%; border: 1px solid #e2e8f0; border-radius: .55rem;
  padding: .5rem .75rem; font-size: .82rem; background: #fff; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
.input::placeholder, .textarea::placeholder { color: #9aa7b8; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 3px rgba(13, 148, 136, .14);
}
.input:disabled, .select:disabled { background: #f8fafc; color: #94a3b8; }
.label { display: block; font-size: .72rem; color: var(--ink-soft); margin-bottom: .25rem; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--ink); cursor: pointer; user-select: none; }
.field-hint { font-size: .68rem; color: #94a3b8; margin-top: .25rem; display: block; }

/* ───────── Botones ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: .55rem; font-size: .82rem; font-weight: 500;
  transition: background .12s, color .12s, border-color .12s; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); }
.btn-ghost { border: 1px solid #e2e8f0; color: var(--ink-soft); background: #fff; }
.btn-ghost:hover:not(:disabled) { background: #f8fafc; color: #0f172a; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

/* Acciones en fila de tabla */
.act { font-size: .8rem; font-weight: 500; background: none; }
.act-edit { color: var(--brand-700); }
.act-edit:hover { text-decoration: underline; }
.act-del { color: #dc2626; }
.act-del:hover { text-decoration: underline; }

.pager-btn { padding: .25rem .6rem; border: 1px solid #e2e8f0; border-radius: .55rem; }
.pager-btn:disabled { opacity: .4; }
.pager-btn:not(:disabled):hover { background: #f8fafc; }

/* ───────── Modales ───────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, .45); padding: 1rem;
  transition: opacity .15s;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: #fff; border-radius: .9rem; width: 100%;
  box-shadow: 0 20px 45px rgba(15, 23, 42, .25);
  max-height: 92vh; display: flex; flex-direction: column; overflow: hidden;
  transition: transform .15s;
}
.modal-head { padding: 1rem 1.5rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1.1rem; font-weight: 700; color: #0f172a; }
.modal-body { padding: 1.5rem; overflow-y: auto; }
.modal-foot { padding: .85rem 1.5rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: .5rem; background: #fcfdfe; }

/* ───────── Toasts ───────── */
.toast {
  position: fixed; top: 1rem; right: 1rem; z-index: 9999; max-width: 22rem;
  padding: .75rem 1rem; border-radius: .6rem; color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); font-size: .85rem;
  opacity: 0; transform: translateY(-10px);
  transition: opacity .2s, transform .2s;
}
.toast.show    { opacity: 1; transform: translateY(0); }
.toast.success { background: #059669; }
.toast.error   { background: #dc2626; }
.toast.warn    { background: #d97706; }
.toast.info    { background: var(--brand-700); }

/* ───────── Impresión ───────── */
@media print {
  .topbar, #sidebar, #navOverlay, .no-print, footer { display: none !important; }
  .app-main { padding: 0 !important; }
  body { background: #fff; }
}

/* ─────────────────────────────────────────────────────────────
   MiniMapa (assets/js/minimap.js)

   El mapa de una ruta de entrega. Sin librería: la rejilla de tiles, las
   chinchetas y la línea son elementos normales colocados en absoluto sobre
   un contenedor con `overflow:hidden`.
   ───────────────────────────────────────────────────────────── */
.minimapa {
  position: relative; overflow: hidden; border-radius: .75rem;
  background: #e8eef2;                     /* el gris del mar mientras cargan los tiles */
  border: 1px solid var(--line); height: 340px; touch-action: none;
}
.mm-lienzo { position: absolute; inset: 0; cursor: grab; }
.mm-lienzo:active { cursor: grabbing; }

.mm-tiles img {
  position: absolute; width: 256px; height: 256px;
  user-select: none; -webkit-user-drag: none;
}
.mm-lineas { position: absolute; inset: 0; pointer-events: none; }
.mm-pines  { position: absolute; inset: 0; }

/* La chincheta se ancla por su punta, no por su centro: por eso el -100% de Y
   más el ratito del pico. Si se centrara, el punto marcado quedaría medio
   círculo más arriba del sitio real. */
.mm-pin {
  position: absolute; transform: translate(-50%, -100%);
  min-width: 1.6rem; height: 1.6rem; padding: 0 .35rem;
  border: 2px solid #fff; border-radius: 999px;
  color: #fff; font-size: .72rem; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .35); cursor: pointer;
}
.mm-pin::after {
  content: ''; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%);
  border: .34rem solid transparent; border-top-color: #fff; margin-top: -1px;
}
.mm-pin:hover { filter: brightness(1.08); }

.mm-zoom { position: absolute; top: .5rem; right: .5rem; display: flex; flex-direction: column; gap: .25rem; }
.mm-btn {
  width: 1.9rem; height: 1.9rem; border-radius: .45rem; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: .95rem; line-height: 1; cursor: pointer;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .18);
}
.mm-btn:hover { background: #f8fafc; }

.mm-credito {
  position: absolute; bottom: 0; right: 0; z-index: 2;
  background: rgba(255, 255, 255, .82); color: #475569;
  font-size: .62rem; padding: .1rem .35rem; border-top-left-radius: .35rem; text-decoration: none;
}
.mm-credito:hover { text-decoration: underline; }

.mm-vacio {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 1.5rem; color: #64748b; font-size: .82rem; background: #f8fafc;
}
