/* ===== VIRALIZA SORTEOS — MAIN CSS ===== */
:root {
  --brand: #7c3aed;
  --brand-light: #a78bfa;
  --brand-dark: #5b21b6;
  --accent: #f59e0b;
  --accent2: #10b981;
  --bg: #0f0e17;
  --bg2: #1a1828;
  --bg3: #252338;
  --surface: #1e1c2e;
  --surface2: #2a2840;
  --border: rgba(124, 58, 237, 0.2);
  --text: #f0eeff;
  --text2: #9d9bbf;
  --text3: #6b6988;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-brand: 0 8px 32px rgba(124, 58, 237, 0.3);
  --sidebar-w: 260px;
  --transition: all 0.2s ease;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.logo-text {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
  color: white;
}

.logo-text span { color: var(--accent); }

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
}

.sidebar-logo > span {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-menu {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
}

.sidebar-menu li.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 8px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
}

.sidebar-menu a svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

.sidebar-menu a:hover { background: var(--surface2); color: var(--text); }
.sidebar-menu a.active {
  background: rgba(124, 58, 237, 0.2);
  color: var(--brand-light);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }

.btn-logout {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
  font-family: inherit;
}
.btn-logout:hover { background: rgba(239, 68, 68, 0.15); border-color: rgba(239,68,68,0.4); color: #f87171; }

.powered-by { font-size: 11px; color: var(--text3); text-align: center; margin-top: 10px; }
.powered-by a { color: var(--brand-light); text-decoration: none; }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px;
  min-height: 100vh;
  max-width: calc(100vw - var(--sidebar-w));
}

/* ===== PAGE HEADER ===== */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
}

.page-header p {
  color: var(--text2);
  margin-top: 4px;
  font-size: 15px;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ===== STATS CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-light));
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  background: rgba(124, 58, 237, 0.15);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  font-size: 20px;
}

.stat-card .stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text2);
  margin-top: 4px;
}

/* ===== CARDS / TABLES ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header h2 {
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 700;
}

.card-body { padding: 20px; }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 12px 16px;
  color: var(--text3);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-weight: 600;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(124, 58, 237, 0.05); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color: white;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 40px rgba(124, 58, 237, 0.4); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg3); }

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

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

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.badge-draft { background: rgba(107,114,128,0.15); color: #9ca3af; }
.badge-active { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-active::before { content: ''; width: 6px; height: 6px; background: #34d399; border-radius: 50%; }
.badge-finished { background: rgba(124, 58, 237, 0.15); color: #a78bfa; }
.badge-paused { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="color"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

input[type="color"] {
  padding: 6px 8px;
  height: 42px;
  cursor: pointer;
}

textarea { resize: vertical; min-height: 100px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.form-hint { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* ===== ALERTS ===== */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-error { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); color: #fca5a5; }
.alert-success { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.3); color: #6ee7b7; }
.alert-info { background: rgba(124, 58, 237, 0.1); border: 1px solid var(--border); color: var(--brand-light); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-family: 'Syne', sans-serif; font-size: 18px; color: var(--text2); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* ===== SORTEO CARD ===== */
.sorteo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.sorteo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
  display: block;
}

.sorteo-card:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: var(--shadow-brand); }

.sorteo-card-banner {
  height: 140px;
  background: linear-gradient(135deg, var(--bg3), var(--bg2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  position: relative;
  overflow: hidden;
}

.sorteo-card-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sorteo-card-body { padding: 16px; }

.sorteo-card-title {
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.sorteo-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text3);
  margin-top: 10px;
}

/* ===== WINNER REVEAL ===== */
.winner-reveal {
  text-align: center;
  padding: 40px 20px;
}

.winner-trophy {
  font-size: 72px;
  margin-bottom: 16px;
  display: block;
  animation: bounce 0.6s ease;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}

.winner-name {
  font-family: 'Syne', sans-serif;
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.winners-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.winner-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  animation: slideIn 0.4s ease forwards;
  opacity: 0;
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.winner-position {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.winner-pos-1 { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.winner-pos-2 { background: linear-gradient(135deg, #9ca3af, #d1d5db); }
.winner-pos-3 { background: linear-gradient(135deg, #92400e, #b45309); }

/* ===== PUBLIC PAGE ===== */
.public-wrap {
  margin-left: 0;
  max-width: 100vw;
}

.public-hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(124,58,237,0.3) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 80%, rgba(245,158,11,0.15) 0%, transparent 50%),
              var(--bg);
  padding: 40px 20px;
}

.public-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
}

.public-card-banner {
  height: 200px;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand), var(--brand-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  position: relative;
  overflow: hidden;
}

.public-card-banner img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.public-card-body { padding: 32px; }

.public-brand {
  font-size: 13px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.public-title {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
}

.public-stats-row {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.public-stat {
  text-align: center;
}

.public-stat .num {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--brand-light);
}

.public-stat .lbl { font-size: 12px; color: var(--text3); }

/* ===== LOGIN ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(124,58,237,0.25) 0%, transparent 60%), var(--bg);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-big {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 24px;
  color: white;
  margin-bottom: 14px;
}

.login-logo h1 {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 800;
}

.login-logo p { color: var(--text2); font-size: 14px; margin-top: 4px; }

/* ===== SORTEO DETAIL ===== */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
}

.participants-box {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 14px;
  max-height: 360px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text2);
}

.draw-btn-wrap {
  text-align: center;
  padding: 24px 0;
}

.btn-draw {
  padding: 18px 40px;
  font-size: 18px;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: white;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 8px 32px rgba(124,58,237,0.4);
  letter-spacing: 0.5px;
}

.btn-draw:hover { transform: scale(1.04); box-shadow: 0 12px 48px rgba(124,58,237,0.5); }
.btn-draw:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ===== CONFETTI CANVAS ===== */
#confetti-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* ===== TABS ===== */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; }
.tab-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  font-family: inherit;
  transition: var(--transition);
}
.tab-btn.active { background: rgba(124,58,237,0.2); color: var(--brand-light); border-color: var(--brand); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; max-width: 100vw; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== UTILITIES ===== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--text2); }
.text-faint { color: var(--text3); }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
