/* ═══════════════════════════════════════════════════════════════
   RifaGenial — Premium Design System v2.0
   Fuente: Outfit · Paleta: Esmeralda luminoso + Blanco
   ═══════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&display=swap');

/* ─── Variables ─────────────────────────────────────────── */
:root {
  /* Colores de marca */
  --brand: #0D9668;
  --brand-dark: #065f46;
  --brand-light: #d1fae5;
  --brand-50: #ecfdf5;
  --brand-glow: rgba(13, 150, 104, .35);
  --brand-gradient: linear-gradient(135deg, #0D9668, #34d399);
  --brand-gradient-soft: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 50%, #a7f3d0 100%);

  /* Acento */
  --accent: #F59E0B;
  --accent-light: #fef3c7;

  /* Neutros (Modo Claro) */
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .07), 0 2px 4px -2px rgba(0, 0, 0, .05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .08), 0 4px 6px -4px rgba(0, 0, 0, .04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, .08), 0 8px 10px -6px rgba(0, 0, 0, .04);
  --shadow-brand: 0 4px 14px rgba(13, 150, 104, .3);
  --shadow-brand-lg: 0 8px 24px rgba(13, 150, 104, .35);

  /* Radios */
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transiciones */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --transition: 200ms var(--ease);
  --transition-slow: 350ms var(--ease);
}

/* Dark Mode Variables */
.dark {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --border-light: #1e293b;
}

/* ─── Base ───────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ─── Tipografía Premium ─────────────────────────────────── */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.text-gradient {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-brand {
  color: var(--brand);
}

.text-brand-dark {
  color: var(--brand-dark);
}

.text-brand-text {
  color: var(--text-primary);
}

/* ─── Animaciones ────────────────────────────────────────── */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 var(--brand-glow);
  }

  70% {
    box-shadow: 0 0 0 12px rgba(13, 150, 104, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(13, 150, 104, 0);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

@keyframes blob {
  0% {
    transform: translate(0, 0) scale(1);
  }

  33% {
    transform: translate(30px, -50px) scale(1.1);
  }

  66% {
    transform: translate(-20px, 20px) scale(0.9);
  }

  100% {
    transform: translate(0, 0) scale(1);
  }
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

@keyframes glow {

  0%,
  100% {
    box-shadow: 0 0 15px var(--brand-glow);
  }

  50% {
    box-shadow: 0 0 30px var(--brand-glow);
  }
}

.animate-slide-in {
  animation: slideIn .3s var(--ease) forwards;
}

.animate-fade-up {
  animation: fadeUp .4s var(--ease) forwards;
}

.animate-fade-in {
  animation: fadeIn .3s var(--ease) forwards;
}

.animate-pulse-ring {
  animation: pulse-ring 1.5s infinite;
}

.animate-blob {
  animation: blob 7s infinite;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-glow {
  animation: glow 2s ease-in-out infinite;
}

.animation-delay-2000 {
  animation-delay: 2s;
}

.animation-delay-4000 {
  animation-delay: 4s;
}

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

/* ─── Botones ————————————————————————————————————————————— */
.btn-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--brand-gradient);
  color: white;
  border-radius: var(--radius);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: .875rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  box-shadow: var(--shadow-brand);
  position: relative;
  overflow: hidden;
}

.btn-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, .15), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.btn-brand:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-brand-lg);
}

.btn-brand:hover::before {
  opacity: 1;
}

.btn-brand:active {
  transform: translateY(0);
  box-shadow: var(--shadow-brand);
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  background: transparent;
  color: var(--brand);
  border: 2px solid var(--brand);
  border-radius: var(--radius);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: .875rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-outline:hover {
  background: var(--brand);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-brand);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border-radius: var(--radius);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: .875rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(239, 68, 68, .3);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(239, 68, 68, .35);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-size: .875rem;
  text-decoration: none;
}

.btn-icon:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-50);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-icon.danger:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: #fef2f2;
}

.btn-icon.success:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-50);
}

.shadow-brand {
  box-shadow: var(--shadow-brand);
}

/* ─── Cards ──────────────────────────────────────────────── */
.card-saas {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition), box-shadow var(--transition);
}

.card-saas:hover {
  box-shadow: var(--shadow-xl);
}

.card-saas-lift:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-xl);
}

/* Card con gradiente sutil en el borde superior */
.card-accent {
  position: relative;
  overflow: hidden;
}

.card-accent::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--brand-gradient);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* ─── Formularios ────────────────────────────────────────── */
.form-group {
  position: relative;
}

.form-label {
  display: block;
  font-size: .8125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: .02em;
}

.form-input {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
  outline: none;
}

.form-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.form-input:focus {
  border-color: var(--brand);
  background: var(--bg-card);
  box-shadow: 0 0 0 4px var(--brand-glow);
}

.form-input:invalid:not(:placeholder-shown) {
  border-color: #ef4444;
}

/* Input con icono a la izquierda */
.input-icon-left {
  padding-left: 44px;
}

/* Toggle contraseña (ojito) */
.password-wrapper {
  position: relative;
}

.password-toggle {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: color var(--transition);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-toggle:hover {
  color: var(--brand);
}

/* Validaciones inline */
.form-error {
  font-size: .75rem;
  color: #ef4444;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.form-success {
  font-size: .75rem;
  color: var(--brand);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

/* Indicador de fortaleza de contraseña */
.password-strength {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.password-strength-bar {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  transition: background var(--transition);
}

.password-strength-bar.weak {
  background: #ef4444;
}

.password-strength-bar.medium {
  background: #f59e0b;
}

.password-strength-bar.strong {
  background: var(--brand);
}

/* ─── Ticket Grid ────────────────────────────────────────── */
.ticket-btn {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: .8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.ticket-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  transform: scale(1.08);
  box-shadow: var(--shadow-md);
}

.ticket-btn.selected {
  background: var(--brand-gradient);
  border-color: var(--brand);
  color: white;
  animation: pulse-ring .4s ease;
  transform: scale(1.1);
  box-shadow: var(--shadow-brand);
}

.ticket-btn.reserved {
  background: var(--border-light);
  border: 2px dashed var(--accent);
  color: #92400e;
  cursor: not-allowed;
  opacity: 0.6;
  text-decoration: line-through;
}

.ticket-btn.sold {
  background: var(--border-light);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.5;
  text-decoration: line-through;
}

/* ─── Progress Bar ────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--brand-gradient);
  border-radius: var(--radius-full);
  transition: width .6s var(--ease);
}

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 12px;
  border-radius: var(--radius-full);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.badge-active {
  background: var(--brand-light);
  color: var(--brand-dark);
}

.badge-paused {
  background: var(--accent-light);
  color: #92400e;
}

.badge-finished {
  background: #e0e7ff;
  color: #3730a3;
}

.badge-draft {
  background: var(--border-light);
  color: var(--text-secondary);
}

/* ─── Glass effect ───────────────────────────────────────── */
.glass {
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, .4);
}

.dark .glass {
  background: rgba(30, 41, 59, .85);
  border-color: rgba(255, 255, 255, .08);
}

/* ─── HTMX Loading ───────────────────────────────────────── */
.htmx-request .htmx-indicator {
  display: inline-flex !important;
}

.htmx-indicator {
  display: none;
}

/* ─── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 40;
}

/* ─── Cart bar flotante ──────────────────────────────────── */
.cart-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, .08);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
  margin: 2px 0;
}

.sidebar-link:hover {
  background: var(--brand-50);
  color: var(--brand);
}

.sidebar-link.active {
  background: var(--brand-50);
  color: var(--brand);
  box-shadow: inset 3px 0 0 var(--brand);
}

.sidebar-link i,
.sidebar-link svg {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

/* ─── Stat Cards ─────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

/* ─── Image cards aspect ratio ───────────────────────────── */
.aspect-card {
  position: relative;
  width: 100%;
  padding-top: 75%;
  /* 4:3 */
  overflow: hidden;
  background: var(--border-light);
}

.aspect-card>img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.aspect-card:hover>img {
  transform: scale(1.05);
}

/* ─── Image Lightbox overlay ─────────────────────────────── */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .92);
  backdrop-filter: blur(8px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.lightbox-overlay img {
  max-width: 92vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}

/* ─── Tooltips ───────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  padding: 6px 12px;
  background: var(--text-primary);
  color: var(--bg-card);
  font-size: .7rem;
  font-weight: 600;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition);
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--brand);
}

/* ─── Utilidades ─────────────────────────────────────────── */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Responsive: Mobile First ───────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    z-index: 50;
    height: 100vh;
    width: 280px;
    transition: left var(--transition-slow);
    box-shadow: var(--shadow-xl);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
  }

  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  .btn-brand,
  .btn-outline {
    padding: 14px 24px;
    font-size: .9rem;
  }

  .stat-card {
    padding: 18px;
  }
}

/* Safe area para notch en iPhones */
@supports (padding: max(0px)) {
  .safe-bottom {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .safe-top {
    padding-top: max(0px, env(safe-area-inset-top));
  }
}

/* HTMX Transitions & Optimistic UI */
.htmx-request {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 200ms ease-in;
}

@keyframes progress-loading {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}