/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --gold:      #e6a800;
  --gold-lt:   #ffc107;
  --green:     #1a7a4a;
  --green-lt:  #25a163;
  --navy:      #0f2a4a;
  --bg:        #f4f6f9;
  --bg-card:   #ffffff;
  --border:    #e0e4ea;
  --text:      #1a1a2e;
  --muted:     #6b7280;
}

/* ── Base ────────────────────────────────────────────────────────────────── */
body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', sans-serif; }
a { text-decoration: none; }

/* ── Navbar ──────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--navy) !important;
  border-bottom: 3px solid var(--gold);
  padding: .6rem 0;
}
.navbar-brand { font-size: 1.3rem; color: #fff !important; letter-spacing: .02em; }
.navbar-brand i { color: var(--gold-lt); }
.navbar-toggler { background: transparent !important; border: none !important; }
.navbar-toggler-icon { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23ffffff' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e"); }
.nav-link { color: rgba(255,255,255,.75) !important; font-size: .9rem; transition: color .2s; }
.nav-link:hover, .nav-link.active { color: var(--gold-lt) !important; }
.navbar-search input {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  border-radius: 2rem 0 0 2rem;
  font-size: .85rem;
  width: 180px;
}
.navbar-search input::placeholder { color: rgba(255,255,255,.5); }
.navbar-search input:focus { background: rgba(255,255,255,.2); outline: none; box-shadow: none; border-color: var(--gold-lt); }
.navbar-search .btn {
  border-radius: 0 2rem 2rem 0;
  background: var(--gold);
  border: none;
  color: #111;
  font-size: .85rem;
  padding: .375rem .75rem;
}

/* ── Hero sorteos recientes ──────────────────────────────────────────────── */
.sorteo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 4px solid var(--green);
  border-radius: .75rem;
  padding: 1.2rem;
  transition: box-shadow .2s, transform .2s;
}
.sorteo-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,.1); transform: translateY(-2px); }
.sorteo-billete-img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: .5rem;
  display: block;
}
.sorteo-card.mayor    { border-top-color: #e63946; background-color: rgba(230, 57, 70, .05); }
.sorteo-card.superior { border-top-color: #3a86ff; background-color: rgba(58, 134, 255, .05); }
.sorteo-card.especial { border-top-color: #2a9d8f; background-color: rgba(42, 157, 143, .05); }
.sorteo-card.magno    { border-top-color: var(--gold); background-color: rgba(212, 175, 55, .06); }

body.dark-mode .sorteo-card.mayor    { background-color: rgba(230, 57, 70, .08); }
body.dark-mode .sorteo-card.superior { background-color: rgba(58, 134, 255, .08); }
body.dark-mode .sorteo-card.especial { background-color: rgba(42, 157, 143, .08); }
body.dark-mode .sorteo-card.magno    { background-color: rgba(212, 175, 55, .1); }
.sorteo-num {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: .1em;
  font-family: monospace;
  color: var(--navy);
  line-height: 1;
}
.sorteo-premio { color: var(--green); font-weight: 700; font-size: 1.1rem; }
.sorteo-label  { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* ── Cards genéricas ─────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: .75rem !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  color: var(--text) !important;
}
.card-header {
  background: #f8fafc !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: .75rem .75rem 0 0 !important;
  font-size: .88rem;
  font-weight: 600;
  color: var(--navy) !important;
}

/* ── Stat boxes ──────────────────────────────────────────────────────────── */
.stat-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: .75rem;
  padding: 1.2rem;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
}
.stat-num { font-size: 2rem; font-weight: 800; color: var(--navy); }
.stat-lbl { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table { color: var(--text); }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-color: var(--border) !important; background: #f8fafc; }
.table td { border-color: #f0f2f5 !important; vertical-align: middle; font-size: .9rem; }
.table-hover tbody tr:hover { background: #f0f7ff !important; }

/* ── Badges tipo ─────────────────────────────────────────────────────────── */
.badge-mayor    { background: #e63946; color: #fff; padding: .3em .65em; border-radius: .4em; font-size:.75rem; }
.badge-superior { background: #3a86ff; color: #fff; padding: .3em .65em; border-radius: .4em; font-size:.75rem; }
.badge-especial { background: #2a9d8f; color: #fff; padding: .3em .65em; border-radius: .4em; font-size:.75rem; }
.badge-magno    { background: var(--gold); color: #111; padding: .3em .65em; border-radius: .4em; font-size:.75rem; }

/* ── Premios ─────────────────────────────────────────────────────────────── */
.premio-monto  { color: var(--green); font-weight: 600; }
.primer-premio { color: var(--gold); font-weight: 700; }
.num-billete   { color: var(--navy); font-family: monospace; font-weight: 700; }

/* ── Botones ─────────────────────────────────────────────────────────────── */
.btn-primary-lote {
  background: var(--green); border: none; color: #fff; font-weight: 600;
  border-radius: .5rem; padding: .6rem 1.5rem; transition: background .2s;
}
.btn-primary-lote:hover { background: var(--green-lt); color: #fff; }
.btn-gold {
  background: var(--gold); border: none; color: #111; font-weight: 700;
  border-radius: .5rem; padding: .6rem 1.5rem; transition: background .2s;
}
.btn-gold:hover { background: var(--gold-lt); color: #111; }
.btn-outline-lote {
  border: 2px solid var(--green); color: var(--green); background: transparent;
  font-weight: 600; border-radius: .5rem; padding: .55rem 1.5rem; transition: all .2s;
}
.btn-outline-lote:hover { background: var(--green); color: #fff; }

/* ── Inputs ──────────────────────────────────────────────────────────────── */
.form-control, .form-select {
  border: 1px solid var(--border);
  border-radius: .5rem;
  color: var(--text);
  background: #fff;
}
.form-control:focus, .form-select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26,122,74,.12);
}

/* ── Result cards (buscar) ───────────────────────────────────────────────── */
.result-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: .75rem;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
}
.result-card .rc-val { font-size: 1.4rem; font-weight: 700; color: var(--navy); }
.result-card .rc-lbl { font-size: .75rem; color: var(--muted); margin-top: .2rem; }

/* ── Cachito box ─────────────────────────────────────────────────────────── */
.cachito-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid var(--gold);
  border-radius: .75rem;
  padding: 1.2rem 1.5rem;
}

/* ── Heatmap ─────────────────────────────────────────────────────────────── */
.heatmap-grid { display: grid; grid-template-columns: repeat(10,1fr); gap: 3px; }
.hm-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 700; color: #fff;
  cursor: default; transition: transform .15s;
  background: #e5e7eb;
  color: #6b7280;
}
.hm-cell:hover { transform: scale(1.15); z-index: 2; }
.hm-cell.lvl-0 { background: #e5e7eb; color: #9ca3af; }
.hm-cell.lvl-1 { background: #bbf7d0; color: #166534; }
.hm-cell.lvl-2 { background: #4ade80; color: #14532d; }
.hm-cell.lvl-3 { background: #16a34a; color: #fff; }
.hm-cell.lvl-4 { background: #166534; color: #fff; }
.hm-legend { display:flex; gap:.5rem; align-items:center; font-size:.75rem; color:var(--muted); }
.hm-legend span { width:14px;height:14px;border-radius:3px;display:inline-block; }

/* ── Ad blocks ───────────────────────────────────────────────────────────── */
.ad-block {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: .5rem;
  display: flex; align-items: center; justify-content: center;
  color: #94a3b8; font-size: .75rem;
  text-transform: uppercase; letter-spacing: .06em;
}
.ad-banner { height: 90px; width: 100%; }
.ad-rect   { height: 250px; width: 100%; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer { background: var(--navy) !important; color: rgba(255,255,255,.5) !important; border-top: 3px solid var(--gold); }

/* MODO OSCURO */
body.dark-mode {
  --bg:        #1a1a2e;
  --bg-card:   #252c42;
  --border:    #404560;
  --text:      #e0e4ea;
  --muted:     #a0a8b8;
}

body.dark-mode .navbar { background: #0f1420 !important; }
body.dark-mode .nav-link { color: rgba(255,255,255,.6) !important; }
body.dark-mode .nav-link:hover, body.dark-mode .nav-link.active { color: var(--gold-lt) !important; }

body.dark-mode .card { background: var(--bg-card); border-color: var(--border); color: var(--text); }
body.dark-mode .card-header { background: #1f2a3d; border-color: var(--border); color: var(--text); }
body.dark-mode .table { color: var(--text); }
body.dark-mode .table thead th { border-color: var(--border); background: #1f2a3d; }
body.dark-mode .table tbody tr { border-color: var(--border); }
body.dark-mode .table tbody tr:hover { background: #2a3450; }

body.dark-mode .form-control, body.dark-mode .form-select {
  background: #1f2a3d;
  border-color: var(--border);
  color: var(--text);
}
body.dark-mode .form-control::placeholder { color: var(--muted); }
body.dark-mode .form-control:focus { background: #252c42; border-color: var(--gold-lt); }

body.dark-mode .badge { background: #404560; color: var(--text); }
body.dark-mode .alert { background: #2a3450; border-color: var(--border); color: var(--text); }

body.dark-mode .btn-outline-secondary { color: var(--text); border-color: var(--border); }
body.dark-mode .btn-outline-secondary:hover { background: var(--border); color: var(--text); }

body.dark-mode .modal-content { background: var(--bg-card); color: var(--text); }
body.dark-mode .modal-header { border-color: var(--border); background: #1f2a3d; }
body.dark-mode .modal-footer { border-color: var(--border); background: #1f2a3d; }

body.dark-mode .text-muted { color: var(--muted) !important; }
body.dark-mode .ad-block { background: #1f2a3d; border-color: var(--border); color: var(--muted); }

body.dark-mode .spinner-border { border-color: rgba(255,255,255,.1); border-right-color: var(--gold-lt); }

body.dark-mode .dark-mode-toggle { color: var(--gold-lt); }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* RESPONSIVE MOBILE - <768px */
/* ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* ── Base ───────────────────────────────────────────────────────────────── */
  body { font-size: 14px; }
  h1 { font-size: 24px !important; }
  h2 { font-size: 20px !important; }
  h3 { font-size: 18px !important; }
  h4 { font-size: 16px !important; }
  h5 { font-size: 14px !important; }
  p { font-size: 14px; line-height: 1.6; }

  /* ── Navbar ─────────────────────────────────────────────────────────────── */
  .navbar {
    padding: 0.5rem 0 !important;
  }
  .navbar-brand {
    font-size: 1.1rem;
  }
  .nav-link {
    font-size: 0.85rem;
    padding: 0.5rem 0.5rem !important;
  }
  .navbar-search {
    display: none; /* Ocultar búsqueda en navbar, usar modal */
  }
  .navbar-toggler {
    padding: 0.25rem 0.5rem;
  }

  /* ── Containers ─────────────────────────────────────────────────────────── */
  .container, .container-fluid {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* ── Cards ──────────────────────────────────────────────────────────────── */
  .card {
    border-radius: 0.5rem !important;
    margin-bottom: 1rem;
  }
  .sorteo-card {
    padding: 0.8rem;
    border-radius: 0.5rem;
  }
  .sorteo-billete-img {
    height: 60px;
  }
  .sorteo-num {
    font-size: 1.8rem;
  }

  /* ── Stat boxes ─────────────────────────────────────────────────────────── */
  .stat-box {
    padding: 0.8rem;
    margin-bottom: 0.75rem;
  }
  .stat-num {
    font-size: 1.5rem;
  }
  .stat-lbl {
    font-size: 0.7rem;
  }

  /* ── Grids ──────────────────────────────────────────────────────────────── */
  .row > [class*='col-'] {
    margin-bottom: 0.75rem;
  }

  /* ── Tablas - SCROLL HORIZONTAL ─────────────────────────────────────────── */
  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scroll iOS */
    border-radius: 0.5rem;
  }
  .table {
    font-size: 0.85rem;
    min-width: 600px; /* Fuerza scroll si es necesario */
  }
  .table th {
    font-size: 0.7rem;
    padding: 0.4rem 0.5rem !important;
  }
  .table td {
    padding: 0.5rem !important;
    font-size: 0.85rem;
  }
  .table-sm {
    font-size: 0.8rem;
  }
  .table-sm th,
  .table-sm td {
    padding: 0.3rem !important;
  }

  /* ── Modales ────────────────────────────────────────────────────────────── */
  .modal-dialog {
    margin: 0.5rem !important;
    max-width: 95vw !important;
  }
  .modal-content {
    border-radius: 0.5rem;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
  }
  .modal-header {
    padding: 0.75rem;
    flex-shrink: 0;
  }
  .modal-body {
    padding: 0.75rem;
    overflow-y: auto;
    flex: 1;
  }
  .modal-footer {
    padding: 0.75rem;
    flex-shrink: 0;
    gap: 0.5rem;
  }
  .modal-title {
    font-size: 1.1rem;
  }

  /* ── Botones ────────────────────────────────────────────────────────────── */
  .btn {
    min-height: 44px; /* Apple standard */
    padding: 0.5rem 1rem !important;
    font-size: 0.9rem;
    border-radius: 0.4rem;
  }
  .btn-sm {
    min-height: 36px;
    padding: 0.4rem 0.75rem !important;
    font-size: 0.8rem;
  }
  .btn-group-vertical .btn {
    border-radius: 0.4rem;
    margin-bottom: 0.5rem;
  }

  /* ── Inputs ─────────────────────────────────────────────────────────────── */
  .form-control, .form-select {
    min-height: 44px;
    font-size: 16px; /* Prevenir zoom en iOS */
    border-radius: 0.4rem;
    padding: 0.5rem 0.75rem;
  }
  .form-label {
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
  }

  /* ── Badges ─────────────────────────────────────────────────────────────── */
  .badge {
    font-size: 0.7rem;
    padding: 0.3em 0.5em;
  }

  /* ── Alerts ─────────────────────────────────────────────────────────────── */
  .alert {
    padding: 0.75rem;
    font-size: 0.9rem;
    border-radius: 0.4rem;
    margin-bottom: 0.75rem;
  }

  /* ── Heatmap - AJUSTAR A MOBILE ─────────────────────────────────────────── */
  .heatmap-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
  }
  .hm-cell {
    font-size: 0.6rem;
  }

  /* ── Cachito box ────────────────────────────────────────────────────────── */
  .cachito-box {
    padding: 0.8rem 1rem;
    border-radius: 0.4rem;
  }

  /* ── Result cards (búsqueda) ────────────────────────────────────────────── */
  .result-card {
    padding: 0.75rem;
    border-radius: 0.4rem;
  }
  .result-card .rc-val {
    font-size: 1.2rem;
  }
  .result-card .rc-lbl {
    font-size: 0.7rem;
  }

  /* ── Espaciado ──────────────────────────────────────────────────────────── */
  .mt-md-5 { margin-top: 1rem !important; }
  .mb-md-5 { margin-bottom: 1rem !important; }
  .p-md-4 { padding: 0.75rem !important; }

  /* ── Flex utilities ─────────────────────────────────────────────────────── */
  .flex-column-mobile {
    flex-direction: column;
  }

  /* ── Display utilities ──────────────────────────────────────────────────── */
  .d-none-mobile {
    display: none !important;
  }

  /* ── Ad blocks ──────────────────────────────────────────────────────────── */
  .ad-banner {
    height: 60px;
  }
  .ad-rect {
    height: 200px;
  }

  /* ── Dark mode en mobile ────────────────────────────────────────────────── */
  body.dark-mode .modal-content {
    max-height: 90vh;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* EXTRA SMALL - <576px (TELÉFONOS) */
/* ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 576px) {
  /* ── Typography ─────────────────────────────────────────────────────────── */
  h1 { font-size: 20px !important; }
  h2 { font-size: 18px !important; }
  h3 { font-size: 16px !important; }
  body { font-size: 13px; }

  /* ── Navbar ─────────────────────────────────────────────────────────────── */
  .navbar-brand {
    font-size: 1rem;
  }
  .nav-link {
    font-size: 0.8rem;
    padding: 0.4rem 0.4rem !important;
  }

  /* ── Containers ─────────────────────────────────────────────────────────── */
  .container, .container-fluid {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  /* ── Cards ──────────────────────────────────────────────────────────────── */
  .sorteo-num {
    font-size: 1.5rem;
    letter-spacing: 0;
  }
  .sorteo-card {
    padding: 0.6rem;
  }

  /* ── Stat boxes ─────────────────────────────────────────────────────────── */
  .stat-box {
    padding: 0.6rem;
  }
  .stat-num {
    font-size: 1.3rem;
  }

  /* ── Tablas ─────────────────────────────────────────────────────────────── */
  .table {
    font-size: 0.8rem;
    min-width: 500px;
  }
  .table th {
    font-size: 0.65rem;
    padding: 0.3rem 0.25rem !important;
  }
  .table td {
    padding: 0.3rem 0.25rem !important;
    font-size: 0.8rem;
  }

  /* ── Modales ────────────────────────────────────────────────────────────── */
  .modal-dialog {
    margin: 0.25rem !important;
    max-width: 98vw !important;
  }
  .modal-header {
    padding: 0.5rem;
  }
  .modal-body {
    padding: 0.5rem;
  }
  .modal-title {
    font-size: 1rem;
  }

  /* ── Botones ────────────────────────────────────────────────────────────── */
  .btn {
    padding: 0.4rem 0.8rem !important;
    font-size: 0.85rem;
  }
  .btn-group {
    gap: 0.4rem;
  }

  /* ── Espaciado ──────────────────────────────────────────────────────────── */
  .row {
    margin: 0 -4px;
  }
  .row > [class*='col-'] {
    padding: 0 4px;
    margin-bottom: 0.5rem;
  }

  /* ── Heatmap ────────────────────────────────────────────────────────────── */
  .heatmap-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 1px;
  }
  .hm-cell {
    font-size: 0.55rem;
  }

  /* ── Márgenes ───────────────────────────────────────────────────────────── */
  .mt-3, .mt-md-3 { margin-top: 0.5rem !important; }
  .mb-3, .mb-md-3 { margin-bottom: 0.5rem !important; }
  .mt-4, .mt-md-4 { margin-top: 0.75rem !important; }
  .mb-4, .mb-md-4 { margin-bottom: 0.75rem !important; }
}
