/* =============================================
   RIFAS VIRTUALES - Design System
   ============================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-dark: #f8fafc; /* Professional Slate 50 */
  --bg-card: #ffffff;
  --bg-card2: #f1f5f9; /* Slate 100 */
  --border: #e2e8f0; /* Slate 200 */
  --text-primary: #0f172a; /* Slate 900 */
  --text-secondary: #475569; /* Slate 600 */
  --text-muted: #94a3b8; /* Slate 400 */
  --accent-corp: #2563eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-bg: rgba(37, 99, 235, 0.08);

  --green: #16a34a; /* Emerald 600 */
  --green-bg: #f0fdf4;
  /* DARK LUXE SYSTEM */
  --primary: #a855f7; /* Púrpura Eléctrico */
  --primary-dark: #7e22ce;
  --secondary: #f59e0b; /* Oro */
  --bg: #050505;
  --bg-alt: #0c0c0e;
  --text: #94a3b8;
  --text-bold: #f8fafc;
  --border: rgba(255, 255, 255, 0.08);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 0 20px rgba(168, 85, 247, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── TYPOGRAPHY ───────────────────────────── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.3; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

/* ── BUTTONS ──────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  border: none; transition: var(--transition); text-decoration: none;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #ffffff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 15px rgba(88,166,255,0.3); }
.btn-success { background: var(--green); color: #0d1117; }
.btn-success:hover { background: #4fd46a; transform: translateY(-1px); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #ff6b63; transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card2); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── FORMS ────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.875rem; font-weight: 500; color: inherit; opacity: 0.9; }
.form-control, input[type="text"], input[type="number"], input[type="email"], input[type="tel"], input[type="date"], input[type="file"], textarea, select {
  width: 100%; padding: 10px 14px; background: #ffffff !important;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary) !important; font-size: 0.9rem; font-family: inherit;
  transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.form-control::placeholder { color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── CARDS ────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}

/* ── BADGES ───────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600;
}
.badge-disponible { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge-reservado   { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); }
.badge-pagado      { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }

/* ── ALERTS (toast) ───────────────────────── */
#toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; max-width: 340px;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-radius: var(--radius-sm);
  background: var(--bg-card2); border-left: 4px solid var(--accent);
  box-shadow: var(--shadow); animation: slideIn 0.3s ease;
  font-size: 0.875rem;
}
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--yellow); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* ── TABLES ───────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th { background: var(--bg-card2); color: var(--text-secondary); font-weight: 600; padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--bg-card2); }
tbody tr:last-child td { border-bottom: none; }

/* ── NUMBER GRID ─────────────────────────── */
.numero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 10px;
}
.numero-btn {
  aspect-ratio: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm); font-size: 1.1rem; font-weight: 700;
  cursor: pointer; border: 2px solid; transition: all 0.15s ease;
  font-family: inherit; position: relative; overflow: hidden;
}
.numero-btn::after {
  content: ''; position: absolute; inset: 0;
  background: currentColor; opacity: 0; transition: opacity 0.15s;
}
.numero-btn:hover::after { opacity: 0.06; }
.numero-btn.disponible {
  background: var(--green-bg); border-color: var(--green-border);
  color: var(--green);
}
.numero-btn.disponible:hover { border-color: var(--green); box-shadow: 0 0 12px rgba(63,185,80,0.35); transform: scale(1.05); }
.numero-btn.reservado {
  background: var(--yellow-bg); border-color: var(--yellow-border);
  color: var(--yellow); cursor: not-allowed;
}
.numero-btn.pagado {
  background: var(--red-bg); border-color: var(--red-border);
  color: var(--red); cursor: not-allowed;
}
.numero-btn.seleccionando {
  background: var(--accent-bg); border-color: var(--accent);
  color: var(--accent); animation: pulse 1s infinite;
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(88,166,255,0.5); } 50% { box-shadow: 0 0 0 8px rgba(88,166,255,0); } }

/* ── LOADER ───────────────────────────────── */
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── NAV ──────────────────────────────────── */
nav.topnav {
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 60px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(10px);
}
.nav-brand { font-size: 1.1rem; font-weight: 800; color: var(--accent); display: flex; align-items: center; gap: 10px; }
.nav-actions { display: flex; align-items: center; gap: 12px; }

/* ── STATS ────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; text-align: center;
}
.stat-number { font-size: 2.2rem; font-weight: 800; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }
.stat-card.green .stat-number { color: var(--green); }
.stat-card.yellow .stat-number { color: var(--yellow); }
.stat-card.red .stat-number { color: var(--red); }
.stat-card.blue .stat-number { color: var(--accent); }

/* ── MODAL ────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px); z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 32px; width: 100%; max-width: 500px;
  transform: translateY(20px); transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  max-height: 90vh; overflow-y: auto;
  color: var(--text);
}
.modal-lg { max-width: 750px; }
.modal-xl { max-width: 1100px; }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.4rem; cursor: pointer; }
.modal-close:hover { color: var(--text-primary); }

/* ── UTILITIES ────────────────────────────── */
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: 16px; } .gap-1 { gap: 8px; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* ── CONNECTION STATUS ─────────────────────── */
.conn-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.75rem; padding: 4px 10px; border-radius: 20px; font-weight: 600;
}
.conn-status .dot { width: 8px; height: 8px; border-radius: 50%; }
.conn-status.connected { color: var(--green); } .conn-status.connected .dot { background: var(--green); }
.conn-status.disconnected { color: var(--red); } .conn-status.disconnected .dot { background: var(--red); animation: pulse-dot 1s infinite; }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── INFO RIFA (public) ────────────────────── */
.rifa-info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 24px; }
.rifa-info-item { padding: 14px 16px; background: var(--bg-card); border-radius: var(--radius-sm); border: 1px solid var(--border); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
.rifa-info-item label { font-size: 0.75rem; color: var(--text); opacity: 0.7; text-transform: uppercase; letter-spacing: 0.5px; }
.rifa-info-item span { display: block; font-weight: 600; margin-top: 2px; color: var(--text); }

/* ── RESPONSIVE ───────────────────────────── */
/* ── MOBILE OPTIMIZATIONS ───────────────────── */
@media (max-width: 768px) {
  html { font-size: 14px; }
  main { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr !important; }
  .grid-3 { grid-template-columns: 1fr !important; }
  
  /* Stats Grid Mobile optimization */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px 8px; border-radius: 10px; }
  .stat-number { font-size: 1.6rem; }
  .stat-label { font-size: 0.75rem; margin-top: 2px; }

  /* Tables to Cards on Mobile */
  .table-responsive-stack thead { display: none; }
  .table-responsive-stack tr { 
    display: block; background: #ffffff !important; border: 1px solid var(--border); 
    border-radius: var(--radius-sm); margin-bottom: 12px; padding: 12px;
    color: var(--text-dark) !important;
  }
  .table-responsive-stack td { 
    display: flex; justify-content: space-between; align-items: center;
    border: none !important; padding: 8px 0 !important; font-size: 0.9rem;
    color: var(--text-dark) !important;
    min-height: 35px;
  }
  .table-responsive-stack td:before { 
    content: attr(data-label); font-weight: 700; color: var(--text-muted); 
    font-size: 0.75rem; text-transform: uppercase;
    margin-right: 15px; flex-shrink: 0;
  }
  
  /* PREVENT IOS ZOOM BUG: Inputs must be at least 16px / 1rem if root is 16px. But root is 14px! */
  .form-control, input, select, textarea {
    font-size: 16px !important;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
  }

  .modal { padding: 20px; width: 95%; margin: 10px; }
  .btn { width: 100%; justify-content: center; }
}

/* ── BACK BUTTON CIRCLE ── */
.btn-back-circle {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: white;
  display: flex !important; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s; font-size: 1.2rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.btn-back-circle:hover { background: var(--bg-main); border-color: var(--accent-corp); transform: translateX(-3px); }
.btn-back-circle:active { transform: scale(0.95); }

/* ── TABLE COMPACT ── */
.table-compact {
  width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
.table-compact th, .table-compact td {
  padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left;
}
.table-compact th { background: #f8fafc; font-weight: 700; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; }

@media (max-width: 600px) {
  .table-compact { font-size: 0.75rem; min-width: 500px; }
  .table-compact th, .table-compact td { padding: 8px 4px; }
}

@media (max-width: 480px) {
  .numero-grid { 
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)) !important;
    gap: 5px !important; 
  }
  .numero-btn { 
    font-size: 0.9rem !important;
    padding: 2px !important;
  }
}
/* --- PREMIUM FLOATING BAR --- */
.floating-cart-premium {
  display: none;
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  max-width: 420px;
  background: rgba(15, 23, 42, 0.85); /* Slate 900 con transparencia */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  padding: 10px 10px 10px 20px;
  border-radius: 100px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
  z-index: 1005;
  align-items: center;
  justify-content: space-between;
  animation: floatIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes floatIn {
  from { transform: translate(-50%, 100px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.floating-cart-premium .cart-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.floating-cart-premium .cart-info .icon-badge {
  background: var(--accent-corp);
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.4);
}

.floating-cart-premium .cart-text {
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.floating-cart-premium .btn-reserve-now {
  background: white;
  color: var(--accent-corp);
  border: none;
  padding: 12px 24px;
  border-radius: 100px;
  font-weight: 900;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.floating-cart-premium .btn-reserve-now:hover {
  transform: scale(1.05);
  background: var(--accent-corp);
  color: white;
}

@media (max-width: 480px) {
  .floating-cart-premium {
    padding: 8px 8px 8px 16px;
  }
  .floating-cart-premium .btn-reserve-now {
    padding: 10px 20px;
    font-size: 0.75rem;
  }
}
