:root {
  --bg: #09120e;
  --bg-surface: #0e1a14;
  --card: #13221b;
  --card-hover: #192d24;
  --card-subtle: #192a22;
  --border: #233b30;
  --border-light: #2e4d3f;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-secondary: #cbd5e1;

  --gold: #eab308;
  --gold-glow: rgba(234, 179, 8, 0.25);
  --gold-bg: rgba(234, 179, 8, 0.12);
  --gold-light: #fde047;

  --red: #dc2626;
  --red-hover: #b91c1c;
  --red-bg: rgba(220, 38, 38, 0.12);

  --green: #10b981;
  --green-hover: #059669;
  --green-bg: rgba(16, 185, 129, 0.12);
  --green-glow: rgba(16, 185, 129, 0.2);

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4);
  --shadow-gold: 0 0 20px rgba(234, 179, 8, 0.18);
  --shadow-green: 0 0 20px rgba(16, 185, 129, 0.18);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  background-image: 
    radial-gradient(ellipse at 50% 0%, rgba(16, 185, 129, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(220, 38, 38, 0.05) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Cuenta Regresiva Banner
   ========================================================================== */

.countdown-banner {
  background: linear-gradient(180deg, rgba(14, 26, 20, 0.95) 0%, rgba(9, 18, 14, 0.8) 100%);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  padding: 0.9rem 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.countdown-container {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.countdown-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.countdown-timer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cd-unit {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.25rem 0.55rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 48px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.cd-num {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold-light);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.cd-label {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.cd-sep {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--border-light);
}

.cd-message {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gold-light);
}

/* ==========================================================================
   Contenedores Principales
   ========================================================================== */

.main-container {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem 3rem;
  width: 100%;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.75rem;
  width: 100%;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.card-login {
  max-width: 440px;
}

.card-choose {
  max-width: 640px;
}

.card-dashboard {
  max-width: 580px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Tipografía y Badges
   ========================================================================== */

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
  color: var(--text);
}

h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

h4 {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
}

.card-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.festive-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold-light);
  background: var(--gold-bg);
  border: 1px solid rgba(234, 179, 8, 0.25);
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ==========================================================================
   Formularios e Inputs
   ========================================================================== */

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-row {
  display: flex;
  gap: 0.75rem;
}

.flex-1 { flex: 1; }
.width-pin { width: 140px; }

label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

select, input, textarea {
  font-family: inherit;
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  font-size: 0.95rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  width: 100%;
}

select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
}

#pin {
  letter-spacing: 0.25em;
  font-size: 1.15rem;
}

/* ==========================================================================
   Botones
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  border: none;
  transition: all 160ms ease;
  user-select: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm {
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
}

.btn-primary {
  background: linear-gradient(180deg, #15803d 0%, #166534 100%);
  color: #fff;
  border: 1px solid #16a34a;
  box-shadow: 0 2px 8px rgba(22, 101, 52, 0.4);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
  box-shadow: 0 4px 14px rgba(22, 101, 52, 0.5);
}

.btn-gold {
  background: linear-gradient(180deg, #eab308 0%, #ca8a04 100%);
  color: #0b1410;
  font-weight: 700;
  border: 1px solid #fde047;
  box-shadow: 0 2px 10px rgba(234, 179, 8, 0.3);
}

.btn-gold:hover:not(:disabled) {
  background: linear-gradient(180deg, #facc15 0%, #eab308 100%);
  box-shadow: 0 4px 18px rgba(234, 179, 8, 0.45);
}

.btn-secondary {
  background: var(--card-subtle);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--card-hover);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border: 1px solid #ef4444;
}

.btn-danger:hover {
  background: var(--red-hover);
}

.btn-danger-sm {
  background: transparent;
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 140ms ease;
}

.btn-danger-sm:hover {
  background: var(--red-bg);
  border-color: #ef4444;
  color: #fff;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Pulsación cuando 3 candidatos están listos */
@keyframes pulse-gold {
  0% { box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(234, 179, 8, 0); }
  100% { box-shadow: 0 0 0 0 rgba(234, 179, 8, 0); }
}

.pulse-ready {
  animation: pulse-gold 2s infinite;
}

/* ==========================================================================
   Vista Login
   ========================================================================== */

.login-footer {
  margin-top: 1.5rem;
  text-align: center;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

.admin-link, .back-link {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 150ms ease;
}

.admin-link:hover, .back-link:hover {
  color: var(--gold-light);
}

.error-msg {
  color: #f87171;
  font-size: 0.85rem;
  min-height: 1.2em;
  margin-top: 0.35rem;
  font-weight: 500;
}

.status-msg {
  font-size: 0.85rem;
  font-weight: 500;
}
.status-msg.success { color: #4ade80; }
.status-msg.error { color: #f87171; }

/* ==========================================================================
   Vista Elegir (3 de 5)
   ========================================================================== */

.choose-header {
  margin-bottom: 1.25rem;
}

.counter-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--card-subtle);
  border: 1px solid var(--border);
  padding: 0.35rem 0.85rem;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.counter-badge strong {
  color: var(--gold-light);
  font-size: 1.05rem;
}

.candidates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}

.candidate-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  transition: all 180ms ease;
  user-select: none;
  position: relative;
}

.candidate-card:hover {
  border-color: var(--border-light);
  background: var(--card-hover);
  transform: translateY(-2px);
}

.cand-avatar {
  font-size: 2rem;
  line-height: 1;
}

.cand-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  word-break: break-word;
}

.cand-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: transparent;
  transition: all 160ms ease;
}

/* Tarjeta seleccionada */
.candidate-card.selected {
  border-color: var(--gold);
  background: linear-gradient(180deg, var(--card) 0%, rgba(234, 179, 8, 0.08) 100%);
  box-shadow: var(--shadow-gold);
  transform: translateY(-3px);
}

.candidate-card.selected .cand-check {
  background: var(--gold);
  border-color: var(--gold);
  color: #0a120e;
  font-weight: 700;
}

.choose-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.choose-actions button {
  width: 100%;
}

/* ==========================================================================
   Vista Dashboard
   ========================================================================== */

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

.greeting-pre {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.alert-direct {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: #fef08a;
}

.alert-direct p {
  margin-top: 0.2rem;
  color: var(--text-secondary);
}

.assigned-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.assigned-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.assigned-reveal {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.1) 0%, rgba(234, 179, 8, 0.08) 100%);
  border: 1.5px solid var(--green);
  border-radius: 10px;
  box-shadow: var(--shadow-green);
}

.gift-icon {
  font-size: 1.8rem;
}

.assigned-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

.wishes-section {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.wishes-display {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  font-size: 0.92rem;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.5;
}

.my-wishes-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wishes-help {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ==========================================================================
   Admin Views & Tables
   ========================================================================== */

.admin-body {
  background: var(--bg);
}

.admin-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
  width: 100%;
}

.card-admin-auth {
  max-width: 440px;
  margin: 4rem auto 0;
}

.admin-dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.admin-card {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.admin-table-card {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.table-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.summary-badge {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.table-responsive {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

.admin-table th {
  padding: 0.65rem 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.05em;
}

.admin-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.text-right {
  text-align: right;
}

.font-medium {
  font-weight: 600;
}

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem !important;
  font-style: italic;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: var(--green-bg);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
  background: var(--gold-bg);
  color: var(--gold-light);
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.badge-info {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.badge-muted {
  background: var(--card-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.admin-danger-card {
  border-color: rgba(220, 38, 38, 0.35);
  background: linear-gradient(180deg, var(--card) 0%, rgba(220, 38, 38, 0.05) 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding: 1.25rem;
}

.danger-info h3 {
  color: #f87171;
  margin-bottom: 0.25rem;
}

.danger-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 580px;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 600px) {
  .countdown-timer {
    gap: 0.25rem;
  }
  .cd-unit {
    min-width: 42px;
    padding: 0.2rem 0.4rem;
  }
  .cd-num {
    font-size: 1.1rem;
  }
  .candidates-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-row {
    flex-direction: column;
  }
  .width-pin {
    width: 100%;
  }
  .admin-danger-card {
    flex-direction: column;
    align-items: stretch;
  }
}
