/* ============================================================
   DRAWR — style.css
   Bolillero Digital
   ============================================================ */

/* ---- CSS Custom Properties (design tokens) ---- */
:root {
  /* Colors */
  --color-bg:           #0b0b1a;
  --color-bg-card:      #12122a;
  --color-bg-drum:      #080817;
  --color-accent:       #f5c842;
  --color-accent-dim:   rgba(245, 200, 66, 0.20);
  --color-accent-glow:  rgba(245, 200, 66, 0.35);
  --color-border:       rgba(245, 200, 66, 0.22);
  --color-text:         #e8e8f0;
  --color-text-muted:   #7070a0;

  /* Typography */
  --font-main:  'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:  'Courier New', Courier, monospace;

  /* Shapes */
  --radius-card: 14px;
  --radius-drum: 24px;

  /* Timing constants (match the values in main.js PHASE_TIMINGS) */
  --duration-spin:    7000ms;
  --duration-slow:    3000ms;
  --duration-reveal:  600ms;

  /* Shadows */
  --shadow-card: 0 6px 32px rgba(0, 0, 0, 0.45);
  --shadow-drum: inset 0 0 80px rgba(0, 0, 0, 0.70),
                 0 0 60px rgba(245, 200, 66, 0.06);
}

/* ---- Reset & base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================================
   HEADER
   ============================================================ */

header {
  border-bottom: 1px solid var(--color-border);
  padding: 36px 24px 28px;
  text-align: center;
}

.header-inner h1 {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--color-accent);
  text-shadow: 0 0 40px var(--color-accent-glow);
}

.header-inner .subtitle {
  margin-top: 4px;
  font-size: 0.8rem;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 20px 100px;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

/* Shared section header row */
.section-header {
  margin-bottom: 16px;
}

h2 {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 6px;
}

/* ============================================================
   SETUP SECTION
   ============================================================ */

.setup-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 36px 32px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Individual field block */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-group > label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* Text hint below each field */
.field-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.field-hint code {
  background: var(--color-accent-dim);
  color: var(--color-accent);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* --- File upload row --- */
.file-upload-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

#csv-input {
  font-size: 0.875rem;
  color: var(--color-text);
  cursor: pointer;
}

#csv-input::file-selector-button {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-accent);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-main);
  padding: 7px 16px;
  margin-right: 10px;
  transition: background 0.18s;
}

#csv-input::file-selector-button:hover {
  background: var(--color-accent-dim);
}

#file-name-label {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  font-style: italic;
}

/* --- Select and number input shared styles --- */
.field-group select,
.field-group input[type="number"] {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  font-family: var(--font-main);
  font-size: 0.95rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.18s;
}

.field-group select:focus,
.field-group input[type="number"]:focus {
  border-color: var(--color-accent);
}

.field-group select {
  max-width: 460px;
  cursor: pointer;
  /* Remove default arrow on some browsers for cleaner look */
  appearance: auto;
}

.field-group input[type="number"] {
  max-width: 110px;
}

/* --- Draw button --- */
#draw-button {
  align-self: flex-start;
  background: var(--color-accent);
  border: none;
  border-radius: 10px;
  color: #0a0a16;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 3px;
  padding: 14px 40px;
  text-transform: uppercase;
  box-shadow: 0 4px 24px rgba(245, 200, 66, 0.28);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.2s;
}

#draw-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(245, 200, 66, 0.45);
}

#draw-button:active:not(:disabled) {
  transform: translateY(0);
}

#draw-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ============================================================
   PARTICIPANTS TABLE
   ============================================================ */

.stats-line {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

/* Scrollable container — shows all rows, no pagination */
.table-wrapper {
  max-height: 520px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 10px;
}

/* Thin custom scrollbar */
.table-wrapper::-webkit-scrollbar        { width: 5px; }
.table-wrapper::-webkit-scrollbar-track  { background: var(--color-bg); }
.table-wrapper::-webkit-scrollbar-thumb  {
  background: var(--color-border);
  border-radius: 3px;
}

#participants-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

/* Sticky header stays visible while scrolling */
#participants-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--color-bg-card);
}

#participants-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
}

#participants-table td {
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

#participants-table tbody tr:last-child td {
  border-bottom: none;
}

#participants-table tbody tr:hover {
  background: rgba(245, 200, 66, 0.04);
}

/* Column widths */
.col-rownum   { width: 56px; }
.col-nickname { }
.col-numero   { width: 110px; }

/* Cell styles */
.cell-rownum {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.cell-nickname {
  font-weight: 500;
}

.cell-numero {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--color-accent);
  font-size: 0.9rem;
}

/* ============================================================
   BOLILLERO SECTION
   ============================================================ */

/* Small text label showing current animation phase */
.phase-label {
  font-size: 0.82rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  min-height: 1.2em;
}

/* Center the drum horizontally */
#bolillero-drum-wrapper {
  display: flex;
  justify-content: center;
}

/* The lottery machine drum */
#bolillero-drum {
  width: 100%;
  max-width: 760px;
  height: 400px;
  border-radius: var(--radius-drum);
  background: var(--color-bg-drum);
  border: 2px solid var(--color-border);
  box-shadow: var(--shadow-drum);
  position: relative;
  overflow: hidden; /* balls stay inside the drum */
}

/* ---- Individual Ball ---- */
/*
 * Each ball is absolutely positioned inside the drum.
 * JS updates `left` and `top` every animation frame.
 * --ball-color is set as an inline CSS custom property per ball.
 */
.ball {
  position: absolute;

  /* Shape */
  border-radius: 50%;

  /* 3D ball effect: bright highlight at top-left, dark at bottom */
  background: radial-gradient(
    circle at 35% 30%,
    rgba(255, 255, 255, 0.55),
    var(--ball-color) 60%,
    rgba(0, 0, 0, 0.25)
  );

  /* Depth shadow */
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.55),
    inset 0 -5px 10px rgba(0, 0, 0, 0.30),
    inset 0 3px 5px rgba(255, 255, 255, 0.20);

  /* Number text centered */
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-main);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.80);

  cursor: default;
  user-select: none;

  /* Smooth transitions for state changes (winner highlight, elimination) */
  transition: opacity 0.55s ease, transform 0.45s ease;

  /* Hint to GPU for smoother animation */
  will-change: left, top;
}

/* Winner ball — glows and scales up */
.ball.is-winner {
  box-shadow:
    0 0 28px 10px var(--ball-color),
    0 4px 12px rgba(0, 0, 0, 0.55),
    inset 0 -5px 10px rgba(0, 0, 0, 0.30);
  transform: scale(1.28) !important;
  z-index: 10;
}

/* Eliminated (non-winner) ball — fades out and shrinks */
.ball.is-eliminated {
  opacity: 0 !important;
  transform: scale(0.5) !important;
  pointer-events: none;
}

/* ============================================================
   RESULT SECTION
   ============================================================ */

.result-title {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 5px;
  text-transform: uppercase;
  text-align: center;
  color: var(--color-accent);
  text-shadow: 0 0 30px var(--color-accent-glow);
  animation: pulse-title 2.5s ease-in-out infinite;
}

@keyframes pulse-title {
  0%, 100% { text-shadow: 0 0 20px var(--color-accent-glow); }
  50%       { text-shadow: 0 0 50px rgba(245, 200, 66, 0.65); }
}

/* Grid of winner cards */
#winners-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  margin-top: 28px;
  margin-bottom: 36px;
}

/* Individual winner card */
.winner-card {
  background: var(--color-bg-card);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-card);
  padding: 28px 36px;
  text-align: center;
  min-width: 200px;
  box-shadow:
    0 0 36px rgba(245, 200, 66, 0.12),
    var(--shadow-card);

  /* Entrance animation — each card pops in from below */
  animation: card-appear 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes card-appear {
  from {
    opacity: 0;
    transform: scale(0.65) translateY(28px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* "1er GANADOR", "2do GANADOR", etc. */
.winner-position {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

/* The big lottery number */
.winner-numero {
  font-size: 3.2rem;
  font-weight: 900;
  font-family: var(--font-mono);
  color: var(--color-accent);
  line-height: 1;
  margin-bottom: 10px;
}

/* List of nickname(s) who hold that number */
.winner-nicknames {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.winner-nickname {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
}

/* ---- Reset button ---- */
#reset-button {
  display: block;
  margin: 0 auto;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.88rem;
  padding: 10px 28px;
  transition: border-color 0.18s, color 0.18s;
}

#reset-button:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* ============================================================
   RESPONSIVE — phones and small screens
   ============================================================ */

@media (max-width: 600px) {
  .header-inner h1 {
    font-size: 2.2rem;
    letter-spacing: 4px;
  }

  .setup-card {
    padding: 24px 18px;
  }

  #draw-button {
    width: 100%;
    text-align: center;
    padding: 14px 20px;
  }

  #bolillero-drum {
    height: 320px;
    border-radius: 16px;
  }

  .winner-numero {
    font-size: 2.4rem;
  }

  .winner-card {
    padding: 20px 24px;
    min-width: 160px;
  }
}

/* ============================================================
   MODE TOGGLE  (GUARANTEED / OPEN)
   ============================================================ */

.mode-toggle {
  display: flex;
  align-self: flex-start;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 2.5px;
  padding: 9px 22px;
  text-transform: uppercase;
  transition: background 0.15s, color 0.15s;
}

.mode-btn + .mode-btn {
  border-left: 1px solid var(--color-border);
}

.mode-btn:hover:not(.is-active) {
  background: var(--color-accent-dim);
  color: var(--color-text);
}

.mode-btn.is-active {
  background: var(--color-accent);
  color: #0a0a16;
  cursor: default;
}

/* ---- Wrappers for mode-specific settings ---- */
/* Both are flex columns matching the setup-card's internal rhythm */
#guaranteed-settings,
#open-settings {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ---- OPEN play button ---- */
/* Same visual as #draw-button but with a distinct color so operators */
/* can instantly tell which mode they are in. */
#play-button {
  align-self: flex-start;
  background: #2980b9;            /* blue — visually distinct from gold GUARANTEED */
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 3px;
  padding: 14px 40px;
  text-transform: uppercase;
  box-shadow: 0 4px 24px rgba(41, 128, 185, 0.32);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.2s;
}

#play-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(41, 128, 185, 0.48);
}

#play-button:active:not(:disabled) {
  transform: translateY(0);
}

#play-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ============================================================
   SLOT MACHINE SECTION  (OPEN MODE)
   ============================================================ */

/* Center the reels container */
#slot-reels-wrapper {
  display: flex;
  justify-content: center;
}

/* The machine "cabinet" — matches the bolillero drum visual language */
#slot-reels-container {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 36px 40px;
  background: var(--color-bg-drum);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-drum);
  box-shadow: var(--shadow-drum);
  flex-wrap: wrap;      /* allows reels to wrap on very small screens */
}

/* ---- Individual reel ---- */
/*
 * Each reel is a fixed-size window showing one digit at a time.
 * JS updates .reel-digit-display textContent to animate the digit.
 * CSS classes .is-spinning and .is-locked control the visual state.
 */
.slot-reel {
  width: 86px;
  height: 118px;
  background: #07071a;
  border: 2px solid rgba(245, 200, 66, 0.30);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 6px 24px rgba(0, 0, 0, 0.60);
  transition: border-color 0.2s, box-shadow 0.2s;
}

/* Reel is actively spinning — light glow on border */
.slot-reel.is-spinning {
  border-color: rgba(41, 128, 185, 0.70);
  box-shadow:
    inset 0 6px 24px rgba(0, 0, 0, 0.60),
    0 0 14px rgba(41, 128, 185, 0.25);
}

/* Reel has stopped and locked its digit — gold glow */
.slot-reel.is-locked {
  border-color: var(--color-accent);
  box-shadow:
    inset 0 6px 24px rgba(0, 0, 0, 0.60),
    0 0 22px rgba(245, 200, 66, 0.38);
}

/* Decorative horizontal scan lines on the reel face */
.slot-reel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 36%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.04), transparent);
  pointer-events: none;
  border-radius: 10px 10px 0 0;
}

/* ---- Digit shown inside the reel ---- */
.reel-digit-display {
  font-family: var(--font-mono);
  font-size: 3.4rem;
  font-weight: 900;
  color: rgba(245, 200, 66, 0.55);   /* dim while idle / spinning */
  text-shadow: none;
  line-height: 1;
  user-select: none;
  transition: color 0.12s, filter 0.12s, text-shadow 0.2s;
}

/* Spinning state: slight motion blur */
.slot-reel.is-spinning .reel-digit-display {
  color: rgba(41, 128, 185, 0.80);
  filter: blur(0.8px);
}

/* Locked state: bright gold, pop animation, glow */
.slot-reel.is-locked .reel-digit-display {
  color: var(--color-accent);
  filter: none;
  text-shadow: 0 0 20px var(--color-accent-glow);
  animation: digit-lock-pop 0.30s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes digit-lock-pop {
  from { transform: scale(1.5); opacity: 0.5; }
  to   { transform: scale(1.0); opacity: 1.0; }
}

/* ---- "Sin ganador" label inside a winner card (OPEN mode) ---- */
.winner-no-match {
  font-size: 1rem;
  color: var(--color-text-muted);
  font-style: italic;
  margin-top: 4px;
}

/* ============================================================
   RESPONSIVE — slot machine on small screens
   ============================================================ */

@media (max-width: 600px) {
  .slot-reel {
    width: 52px;
    height: 78px;
    border-radius: 8px;
  }

  .reel-digit-display {
    font-size: 2.2rem;
  }

  #slot-reels-container {
    gap: 7px;
    padding: 24px 16px;
  }

  #play-button {
    width: 100%;
    text-align: center;
    padding: 14px 20px;
  }
}
