/* ============================================================
   Canjeame · Sistema de diseño (canjea-ds.css)
   Extraído del index.html del panel. Objetivo: que ninguna pantalla
   nueva necesite escribir un color a mano en un style="".
   Regla: si vas a escribir un #hex en el HTML, falta una clase acá.
   ============================================================ */

/* ── 1. Tokens ─────────────────────────────────────────────── */
:root {
  /* Marca */
  --brand:        #7F77DD;
  --brand-light:  #EEEDFE;
  --brand-dark:   #3C3489;
  --brand-lima:   #A8FF78;   /* solo el logo */

  /* Semánticos */
  --green:        #1D9E75;
  --green-light:  #E1F5EE;
  --green-dark:   #085041;
  --green-soft:   #9FE1CB;   /* bordes de tarjetas OK */
  --amber:        #EF9F27;
  --amber-light:  #FAEEDA;
  --amber-dark:   #633806;
  --red:          #E24B4A;
  --red-light:    #FCEBEB;
  --red-dark:     #E24B4A;
  --red-soft:     #F09595;
  --info:         #185FA5;   /* "manual", avisos neutros */
  --info-light:   #E6F1FB;
  --info-soft:    #B5D4F4;
  --exito:        #0F6E56;   /* ganancia, entregado (cambia en oscuro) */
  --exito-solido: #0F6E56;   /* fondo sólido con texto blanco: NO cambia */

  /* Superficies y texto */
  --bg:                 #F4F3F0;
  --surface:            #FFFFFF;
  --surface-2:          #F8F7F5;
  --surface-destacada:  #FFFBF4;   /* fila "más vendido" */
  --border:             rgba(0,0,0,.10);
  --border-md:          rgba(0,0,0,.18);
  --text:               #1A1A1A;
  --text-2:             #5A5A5A;
  --text-3:             #6B6B6B;   /* mínimo AA sobre blanco */
  --on-brand:           #FFFFFF;

  /* Niveles de distribuidor */
  --bronce-bg: #F3E3D3; --bronce-fg: #8B5A2B;
  --plata-bg:  #E8E9EA; --plata-fg:  #5A5C5E;
  --oro-bg:    #FFF3C4; --oro-fg:    #8A6D00;

  /* Forma y ritmo */
  --radius:     10px;
  --radius-sm:   6px;
  --radius-lg:  16px;
  --radius-pill: 999px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;

  /* Tipografía: fuente del sistema, 0 KB en 3G */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Courier New', ui-monospace, monospace;
  --fs-display: 24px;   /* monto entregado, montos grandes */
  --fs-h1:      18px;
  --fs-h2:      15px;
  --fs-body:    14px;
  --fs-sm:      13px;
  --fs-xs:      12px;
  --fs-micro:   11px;
  --fs-label:   10px;   /* solo mayúsculas con letter-spacing */
  --fs-input:   16px;   /* mínimo: menos que esto y iOS hace zoom */

  --tap: 44px;          /* área táctil mínima */
  --shadow-1: 0 1px 2px rgba(0,0,0,.05);
  --shadow-2: 0 4px 16px rgba(0,0,0,.08);
}

[data-tema="oscuro"] {
  --bg:        #0F0F0F;
  --surface:   #1A1A1A;
  --surface-2: #242424;
  --surface-destacada: #332616;
  --border:    rgba(255,255,255,.10);
  --border-md: rgba(255,255,255,.18);
  --text:      #F0F0F0;
  --text-2:    #A0A0A0;
  --text-3:    #9E9E9E;
  --brand-light: #2A2550;
  --green-light: #0D2E25;
  --amber-light: #2E1E08;
  --red-light:   #2E0F0F;
  --info-light:  #12243A;
  --brand-dark:  #A9A2F5;
  --green-dark:  #5DCAA5;
  --amber-dark:  #F0B357;
  --red-dark:    #F08A89;
  --info:        #8FC0F0;
  --info-soft:   #2A3F58;
  --exito:       #5DCAA5;
  --green-soft:  #2C6553;
  --red-soft:    #7A3A3A;
  --oro-bg: #3A2F00; --oro-fg: #F2D25C;
  --plata-bg: #2C2D2E; --plata-fg: #C9CBCD;
  --bronce-bg: #3A2A1B; --bronce-fg: #D9A46B;
}

/* ── 2. Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-variant-numeric: tabular-nums;   /* montos que no bailan */
  background: var(--bg);
  color: var(--text);
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { color: var(--brand); text-decoration: underline; }

/* ── 3. Tipografía ─────────────────────────────────────────── */
.t-display { font-size: var(--fs-display); font-weight: 700; letter-spacing: -.5px; }
.t-h1      { font-size: var(--fs-h1); font-weight: 700; }
.t-h2      { font-size: var(--fs-h2); font-weight: 600; }
.t-body    { font-size: var(--fs-body); font-weight: 400; color: var(--text); }
.t-sm      { font-size: var(--fs-sm); color: var(--text-2); }
.t-xs      { font-size: var(--fs-xs); color: var(--text-2); }
.t-label   { font-size: var(--fs-label); font-weight: 600; color: var(--text-3);
             text-transform: uppercase; letter-spacing: .06em; }
.t-money   { font-weight: 700; font-variant-numeric: tabular-nums; }
.t-gain    { color: var(--exito); font-weight: 600; }
.t-id      { font-family: var(--font-mono); letter-spacing: 1px; }
.t-mute    { color: var(--text-3); }

/* ── 4. Botones ────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
       min-height: var(--tap); padding: 12px 18px; border-radius: var(--radius);
       font-family: inherit; font-size: var(--fs-h2); font-weight: 600;
       border: 1px solid transparent; cursor: pointer; transition: filter .15s, background .15s; }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 56px; font-size: 17px; }      /* acción principal en mostrador */
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: var(--fs-xs); }
.btn:disabled { cursor: not-allowed; }

.btn-primary   { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-primary:disabled { background: var(--surface-2); color: var(--text-3); }
.btn-secondary { background: transparent; color: var(--text-2); border-color: var(--border-md); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-success   { background: var(--exito-solido); color: #fff; }
.btn-danger    { background: transparent; color: var(--red); border-color: var(--red); }
.btn-ghost     { background: none; border: none; color: var(--text-2); min-height: auto; padding: 8px; }

button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

/* ── 5. Campos ─────────────────────────────────────────────── */
.field-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); margin-bottom: 6px; display: block; }
.input { width: 100%; font-family: inherit; font-size: var(--fs-input); padding: 12px 14px;
         border-radius: var(--radius); border: 1.5px solid var(--border-md);
         background: var(--surface); color: var(--text); outline: none; transition: box-shadow .15s, border-color .15s; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(127,119,221,.15); }
.input-id { font-family: var(--font-mono); font-size: 22px; font-weight: 600; letter-spacing: 2px; }
.input.is-valid   { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,158,117,.12); }
.input.is-invalid { border-color: var(--red);   box-shadow: 0 0 0 3px rgba(226,75,74,.12); }
.hint      { font-size: var(--fs-xs); color: var(--text-3); }
.hint.ok   { color: var(--exito); }
.hint.err  { color: var(--red-dark); }
.hint.warn { color: var(--amber-dark); }

/* ── 6. Tarjetas ───────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-2 { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: var(--s3) 14px; }

/* Tarjeta de juego (lista de catálogo) */
.game-card { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
             background: var(--surface); border: 1.5px solid var(--border);
             border-radius: var(--radius); padding: 13px 14px; cursor: pointer; transition: all .15s; }
.game-card:hover { border-color: var(--border-md); }
.game-card.is-hot { border: 2px solid var(--amber); background: var(--surface-destacada); }
.game-card.is-selected { border-color: var(--brand); background: var(--brand-light); }
.game-card.is-off { opacity: .4; cursor: not-allowed; }
.game-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--amber-light);
             display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.game-name { font-size: var(--fs-h2); font-weight: 600; color: var(--text); }
.game-sub  { font-size: var(--fs-xs); color: var(--text-2); margin-top: 2px; }

/* Tarjeta de producto / paquete */
.pkg { position: relative; background: var(--surface); border: 1.5px solid var(--border);
       border-radius: var(--radius); padding: 12px 10px; cursor: pointer; text-align: left; transition: all .12s; }
.pkg:hover { border-color: var(--border-md); }
.pkg.is-popular { border-color: var(--amber); }
.pkg.is-selected { border-color: var(--brand); background: var(--brand-light); }
.pkg.is-selected .pkg-title, .pkg.is-selected .pkg-price { color: var(--brand-dark); }
.pkg.is-editing { border-color: var(--amber-dark); border-style: dashed; background: var(--amber-light); }
.pkg.is-empty { opacity: .45; cursor: not-allowed; filter: grayscale(.6); }
.pkg-title { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.25; }
.pkg-label { font-size: var(--fs-micro); color: var(--text-3); margin: 6px 0; }
.pkg-price { font-size: var(--fs-h2); font-weight: 700; color: var(--text); }
.pkg-gain  { font-size: var(--fs-micro); color: var(--exito); }
.pkg-grid  { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--s2); }

/* ── 7. Chips y badges ─────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs);
        font-weight: 600; padding: 4px 10px; border-radius: var(--radius-pill); }
.chip-saldo  { background: var(--green-light); color: var(--green-dark); }
.chip-brand  { background: var(--brand-light); color: var(--brand-dark); }
.chip-warn   { background: var(--amber-light); color: var(--amber-dark); }
.chip-danger { background: var(--red-light);   color: var(--red-dark); }
.chip-info   { background: var(--info-light);  color: var(--info); }
.chip-nivel  { font-size: var(--fs-micro); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.chip-nivel.oro    { background: var(--oro-bg);    color: var(--oro-fg); }
.chip-nivel.plata  { background: var(--plata-bg);  color: var(--plata-fg); }
.chip-nivel.bronce { background: var(--bronce-bg); color: var(--bronce-fg); }
.badge-sm { font-size: var(--fs-label); font-weight: 600; padding: 2px 7px; border-radius: var(--radius-pill); }
.badge-count { background: var(--red); color: #fff; border-radius: var(--radius-pill);
               min-width: 16px; padding: 0 4px; font-size: 9px; font-weight: 700;
               display: inline-flex; align-items: center; justify-content: center; }

/* ── 8. Avisos ─────────────────────────────────────────────── */
.notice { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px;
          border-radius: var(--radius-sm); font-size: var(--fs-xs); }
.notice-warn { background: var(--amber-light); color: var(--amber-dark); }
.notice-err  { background: var(--red-light); color: var(--red-dark); border: 1px solid var(--red-soft); }
.notice-ok   { background: var(--green-light); color: var(--exito); border: 1px solid var(--green-soft); }
.notice-info { background: var(--info-light); color: var(--info); border: 1px solid var(--info-soft); }

/* ── 9. Filas de recibo / listas ───────────────────────────── */
.rows { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.row  { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; font-size: var(--fs-sm); }
.row + .row { border-top: 1px solid var(--border); }
.row-key { color: var(--text-2); }
.row-val { color: var(--text); font-weight: 600; }
.row.is-total { background: var(--surface-2); font-weight: 600; font-size: var(--fs-body); }
.row.is-gain  { background: var(--green-light); }
.row.is-gain .row-val, .row.is-gain .row-key { color: var(--green-dark); }

/* ── 10. Estado de red / 3G ────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
            background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--brand);
           border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.net-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px;
           font-size: var(--fs-xs); font-weight: 600; border-radius: var(--radius-sm); }
.net-bar.offline { background: #1A1A1A; color: #fff; }
.net-bar.slow    { background: var(--amber-light); color: var(--amber-dark); }
.net-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
