/* ============================================================================
   VIG Comercial — hoja de estilos base
   Identidad "vidrio esmerilado sobre fondo" — mismo lenguaje que ya usa
   Productos PVC en producción: una imagen de fondo fija detrás de toda la
   app, con topbar/tabbar/tarjetas en superficies traslúcidas con blur, y
   los campos de formulario sólidos y claros para que escribir siga siendo
   fácil de leer. Paleta: navy/acero oscuro + acento cobre (mismos tonos
   que el ícono y el logotipo).
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@600;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --paper: #0E1822;          /* color de respaldo detrás de la imagen de fondo, por si tarda en cargar */
  --surface: rgba(22, 31, 41, 0.62);   /* superficie de vidrio principal (tarjetas, topbar, tabbar) */
  --surface-2: rgba(255, 255, 255, 0.07); /* superficie de vidrio secundaria (chips, miniaturas) */
  --ink: #ECE7DA;
  --ink-soft: #A9B0B8;
  --ink-faint: #78828C;
  --line: rgba(255, 255, 255, 0.14);
  --copper: #E2884F;
  --copper-soft: rgba(226, 136, 79, 0.18);
  --volt: #6FA6E0;
  --volt-soft: rgba(111, 166, 224, 0.18);
  --ok: #57B486;
  --ok-soft: rgba(87, 180, 134, 0.18);
  --warn: #D8B24A;
  --warn-soft: rgba(216, 178, 74, 0.18);
  --crit: #E28273;
  --crit-soft: rgba(226, 130, 115, 0.18);
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --blur: 16px;
  --radius: 13px;
  --tabbar-h: 62px;
  --topbar-h: 58px;
  /* campos de formulario: sólidos y claros a propósito, para que escribir
     sobre una foto de fondo siga siendo fácil de leer (mismo criterio que
     Productos PVC) */
  --input-bg: #CBCFD4;
  --input-ink: #14181C;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background-color: var(--paper);
  background-image: url('../img/fondo-app.jpg');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3 { font-family: 'Archivo', system-ui, sans-serif; margin: 0; line-height: 1.2; }
p { margin: 0; }
a { color: var(--volt); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }
code, .mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

/* ---- shell ---- */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: transparent; /* deja ver el fondo fijo de <body> */
  position: relative;
}
@media (min-width: 720px) {
  #app { max-width: 560px; box-shadow: var(--shadow); }
}
#app[hidden] { display: none; }

main.view {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--tabbar-h) + 14px);
}
.view[hidden] { display: none !important; }

/* ---- vidrio: mixin repetido en topbar/tabbar/tarjetas/diálogos ---- */
.topbar, .tabbar, .card, .product-card, .search-box, .pill, .brand-chip .badge,
.brand-hero, .tabs-row, .callout, dialog, .product-card .add-btn, .secondary-btn {
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
}

/* ---- topbar ---- */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .mark {
  width: 30px; height: 30px; border-radius: 9px; overflow: hidden;
  background: var(--ink); display: flex; align-items: center; justify-content: center; flex: none;
}
.topbar .titles { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.topbar .titles .name { font-family: 'Archivo'; font-weight: 800; font-size: 16px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .titles .sub { font-family: 'IBM Plex Mono'; font-size: 10px; color: var(--ink-soft); }
.topbar .spacer { flex: 1; }
.topbar .icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2); border: none;
  display: flex; align-items: center; justify-content: center; flex: none;
  color: var(--ink);
}
.topbar .icon-btn:active { background: var(--line); }
.topbar h1 { font-family: 'Archivo'; font-weight: 700; font-size: 15px; color: var(--ink); }
.topbar .back-btn { border: none; background: none; padding: 4px; display: flex; color: var(--ink); flex: none; }

/* ---- tabbar ---- */
.tabbar {
  flex: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 8px 4px calc(env(safe-area-inset-bottom, 0px) + 8px);
  z-index: 20;
}
@media (min-width: 720px) { .tabbar { max-width: 560px; } }
.tab-btn {
  flex: 1; border: none; background: none;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--ink-faint); padding: 4px 2px;
}
.tab-btn svg { width: 20px; height: 20px; }
.tab-btn span { font-size: 9.5px; }
.tab-btn.active { color: var(--copper); }
.tab-btn.active span { font-weight: 600; }

/* ---- search ---- */
.search-box {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  padding: 10px 13px; margin: 14px 16px 4px;
  color: var(--ink-faint);
}
.search-box svg { flex: none; width: 17px; height: 17px; }
.search-box input {
  border: none; outline: none; background: none; flex: 1;
  font-size: 13.5px; color: var(--ink);
}
.search-box input::placeholder { color: var(--ink-faint); }

/* ---- section header ---- */
.section-hd {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 16px 10px;
}
.section-hd .t { font-family: 'Archivo'; font-weight: 700; font-size: 14px; color: var(--ink); }
.section-hd .a { font-family: 'IBM Plex Mono'; font-size: 10.5px; color: var(--volt); border: none; background: none; }

/* ---- brand carousel ---- */
.brand-row {
  display: flex; gap: 12px; overflow-x: auto; padding: 0 16px 6px;
}
.brand-chip {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 60px;
  border: none; background: none;
}
.brand-chip .badge {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Archivo'; font-weight: 800; font-size: 14px; color: var(--copper);
  overflow: hidden;
}
.brand-chip .badge img { width: 100%; height: 100%; object-fit: contain; }
.brand-chip.active .badge { border-color: var(--copper); border-width: 2px; }
.brand-chip span.label { font-size: 9.5px; text-align: center; color: var(--ink-soft); line-height: 1.2; }

/* ---- category pills ---- */
.pill-row { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px 4px; }
.pill {
  flex: none; padding: 7px 14px; border-radius: 100px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-soft);
  font-size: 12px;
}
.pill.active { background: var(--copper); border-color: var(--copper); color: #1B1310; font-weight: 600; }

/* ---- product grid / cards ---- */
.product-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px;
  padding: 14px 16px 4px;
}
.product-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; text-align: left;
}
.product-card .thumb {
  height: 88px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
}
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-card .thumb svg { color: var(--ink-faint); }
.product-card .body { padding: 9px 10px 11px; display: flex; flex-direction: column; gap: 5px; }
.product-card .desc { font-size: 11.5px; line-height: 1.3; max-height: 29px; overflow: hidden; color: var(--ink); }
.product-card .meta { font-family: 'IBM Plex Mono'; font-size: 9.5px; color: var(--ink-faint); }
.product-card .price { font-family: 'IBM Plex Mono'; font-weight: 600; font-size: 13.5px; color: var(--copper); }
.product-card .add-btn {
  margin-top: 4px; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 8px; padding: 6px; font-size: 11px; font-weight: 600; color: var(--ink);
}
.product-card .add-btn:active { background: var(--line); }

/* ---- generic card ---- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px; color: var(--ink);
}
.stack { display: flex; flex-direction: column; gap: 10px; }
.list-pad { padding: 0 16px; }

/* ---- badges / status ---- */
.badge {
  display: inline-flex; align-self: flex-start; padding: 2px 9px; border-radius: 100px;
  font-size: 10px; font-weight: 600;
}
.badge.copper { background: var(--copper-soft); color: var(--copper); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.crit { background: var(--crit-soft); color: var(--crit); }
.badge.neutral { background: var(--surface-2); color: var(--ink-soft); }

/* ---- buttons ---- */
.primary-btn {
  border: none; background: var(--copper); color: #1B1310;
  font-weight: 700; font-size: 14px; padding: 13px; border-radius: 11px;
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.primary-btn:active { background: #c76f3c; }
.primary-btn:disabled { opacity: .45; }
.secondary-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 11px; padding: 10px;
  font-size: 12.5px; color: var(--ink); background: var(--surface);
}
.secondary-btn:active { background: var(--surface-2); }
.icon-only-btn { border: none; background: none; color: var(--ink-soft); padding: 6px; display: flex; }

/* ---- forms: sólidos y claros a propósito, ver nota junto a --input-bg ---- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  border: none; border-radius: 10px; padding: 10px 12px;
  background: var(--input-bg); color: var(--input-ink); font-size: 14px;
}
.field input::placeholder, .field textarea::placeholder { color: #5B6167; }
.field textarea { resize: vertical; min-height: 60px; }

/* ---- totales box ---- */
.totales {
  display: flex; flex-direction: column; gap: 7px;
}
.totales .row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-soft); }
.totales .hr { height: 1px; background: var(--line); margin: 2px 0; }
.totales .total { display: flex; justify-content: space-between; font-family: 'Archivo'; font-weight: 700; font-size: 15px; color: var(--ink); }

/* ---- empty / loading states ---- */
.empty-state, .loading-state {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 48px 24px; text-align: center; color: var(--ink-soft);
}
.empty-state svg { width: 34px; height: 34px; opacity: .7; }
.empty-state p { font-size: 13px; max-width: 32ch; }

/* ---- auth gate ---- */
.auth-screen {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 32px 24px; gap: 22px;
  background: transparent; /* deja ver el fondo fijo de <body> */
}
.auth-screen .mark-lg { width: 56px; height: 56px; border-radius: 16px; overflow: hidden; background: var(--ink); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.mark img, .mark-lg img { width: 100%; height: 100%; object-fit: cover; }
.auth-screen h1 { color: var(--ink); }
.auth-screen form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; }
.auth-screen .err { color: var(--crit); font-size: 12.5px; }
.auth-screen .hint { color: var(--ink-soft); font-size: 11.5px; text-align: center; max-width: 320px; }

/* ---- toast ---- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px); transform: translateX(-50%);
  background: rgba(10, 14, 18, 0.92); color: #ECE7DA; padding: 10px 18px; border-radius: 100px;
  font-size: 12.5px; z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s;
  max-width: 88%; text-align: center; -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur));
}
#toast.show { opacity: 1; }

/* ---- ficha marca ---- */
.brand-hero {
  padding: 22px 16px 18px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand-hero .badge-lg {
  width: 72px; height: 72px; border-radius: 20px; background: var(--copper-soft);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Archivo'; font-weight: 800; font-size: 22px; color: var(--copper);
  overflow: hidden;
}
.brand-hero .badge-lg img { width: 100%; height: 100%; object-fit: contain; }
.brand-hero .name { font-family: 'Archivo'; font-weight: 800; font-size: 19px; color: var(--ink); }
.brand-hero .desc { font-size: 11.5px; color: var(--ink-soft); text-align: center; max-width: 280px; line-height: 1.4; }
.brand-hero .pending { font-family: 'IBM Plex Mono'; font-size: 9.5px; color: var(--ink-faint); background: var(--surface-2); padding: 3px 10px; border-radius: 100px; margin-top: 2px; }

.tabs-row { display: flex; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tabs-row .tab { padding: 13px 4px; margin-right: 22px; font-size: 13px; color: var(--ink-faint); border-bottom: 2px solid transparent; background: none; border-left: none; border-right: none; border-top: none; }
.tabs-row .tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--copper); }

.callout { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 15px; }
.callout.warn { border-left: 3px solid var(--warn); }
.callout .hd { display: flex; align-items: center; gap: 7px; font-family: 'Archivo'; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink); }
.callout .hd.warn-c { color: var(--warn); }
.callout p { margin-top: 8px; font-size: 12.5px; line-height: 1.55; color: var(--ink-soft); }
.eyebrow { font-family: 'Archivo'; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); }

/* ---- <dialog> (selector de cliente, alta de cliente/producto) ---- */
dialog {
  color: var(--ink);
}
dialog::backdrop {
  background: rgba(6, 10, 14, 0.55);
}
