/* ═══════════════════════════════════════════════════════════════════════
   RifaSegura v2 — Design System 2.0
   Mobile-First • Otimizado para Touch • Acessível • Performático
   ═══════════════════════════════════════════════════════════════════════ */

/* ── CSS VARIABLES ─────────────────────────────────────────────────── */
:root {
  --bg-primary: #010409;
  --bg-secondary: #0d1117;
  --bg-card: rgba(13, 17, 23, 0.95);
  --bg-elevated: #161b22;
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --accent-cyan: #00d4ff;
  --accent-green: #00ff41;
  --accent-gold: #ffd700;
  --accent-purple: #a855f7;
  --glow-cyan: rgba(0, 212, 255, 0.4);
  --glow-green: rgba(0, 255, 65, 0.3);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(0, 212, 255, 0.3);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --space-12: 48px; --space-16: 64px; --space-20: 80px;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px;
  --radius-xl: 24px; --radius-full: 9999px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms; --duration-normal: 250ms; --duration-slow: 400ms;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --header-height: 64px;
}

/* ── ANIMATIONS ─────────────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary); color: var(--text-primary);
  line-height: 1.6; min-height: 100vh; overflow-x: hidden;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: 1rem; }
img { max-width: 100%; height: auto; display: block; }

/* ── ACCESSIBILITY: FOCUS STATES ────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-cyan);
  color: var(--bg-primary);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-weight: 700;
  z-index: 10000;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: var(--space-4);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ── BACKGROUND EFFECTS ─────────────────────────────────────────────── */
.bg-effects { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.bg-grid { position: absolute; inset: 0; background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.03) 1px, transparent 0); background-size: 32px 32px; }
.bg-glow-primary { position: absolute; top: -20%; right: -10%; width: 600px; height: 600px; background: radial-gradient(circle, var(--glow-cyan) 0%, transparent 70%); filter: blur(80px); opacity: 0.3; }
.bg-glow-secondary { position: absolute; bottom: -30%; left: -10%; width: 500px; height: 500px; background: radial-gradient(circle, var(--glow-green) 0%, transparent 70%); filter: blur(80px); opacity: 0.15; }

/* ── LAYOUT ───────────────────────────────────────────────────────── */
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 var(--space-4); }
@media (min-width: 768px) { .container { padding: 0 var(--space-6); } }
.page-content { padding-top: calc(var(--header-height) + var(--space-6)); padding-bottom: var(--space-16); min-height: 100vh; }

/* ── HEADER ─────────────────────────────────────────────────────────── */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-height);
  z-index: 1000; background: rgba(1, 4, 9, 0.85);
  backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 100%; max-width: 1140px; margin: 0 auto; padding: 0 var(--space-4); }
.logo { font-size: 1.2rem; font-weight: 800; letter-spacing: -0.5px; display: flex; align-items: center; gap: var(--space-1); }
.logo-icon { width: 32px; height: 32px; background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green)); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.logo span { color: var(--accent-cyan); }
.nav { display: none; align-items: center; gap: var(--space-6); }
@media (min-width: 768px) { .nav { display: flex; } }
.nav-link { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; font-weight: 500; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; transition: color var(--duration-fast) var(--ease-out); }
.nav-link:hover { color: var(--accent-cyan); }
.mobile-menu-btn { display: flex; flex-direction: column; justify-content: center; align-items: center; width: 44px; height: 44px; gap: 5px; padding: var(--space-2); }
@media (min-width: 768px) { .mobile-menu-btn { display: none; } }
.mobile-menu-btn span { display: block; width: 24px; height: 2px; background: var(--text-primary); border-radius: 2px; transition: all var(--duration-normal) var(--ease-out); }
.mobile-menu { position: fixed; top: var(--header-height); left: 0; right: 0; bottom: 0; background: var(--bg-primary); padding: var(--space-6); transform: translateX(100%); transition: transform var(--duration-normal) var(--ease-out); z-index: 999; }
.mobile-menu.active { transform: translateX(0); }
.mobile-menu-links { display: flex; flex-direction: column; gap: var(--space-4); }
.mobile-menu-link { font-size: 1.25rem; font-weight: 600; color: var(--text-primary); padding: var(--space-4); border-radius: var(--radius-md); transition: background var(--duration-fast); }
.mobile-menu-link:hover { background: var(--bg-secondary); }

/* ── BUTTONS ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-5); font-size: 0.875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; border-radius: var(--radius-md);
  transition: all var(--duration-normal) var(--ease-out); white-space: nowrap;
  min-height: 48px; min-width: 48px;
}
.btn-primary { background: var(--text-primary); color: var(--bg-primary); box-shadow: 0 4px 16px rgba(255, 255, 255, 0.15); }
.btn-primary:hover { background: var(--accent-cyan); transform: translateY(-2px); box-shadow: 0 8px 24px var(--glow-cyan); }
.btn-secondary { background: transparent; color: var(--accent-cyan); border: 1.5px solid var(--accent-cyan); }
.btn-secondary:hover { background: rgba(0, 212, 255, 0.1); transform: translateY(-2px); }
.btn-success { background: var(--accent-green); color: var(--bg-primary); }
.btn-success:hover { box-shadow: 0 4px 16px var(--glow-green); transform: translateY(-2px); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-secondary); }
.btn-lg { padding: var(--space-4) var(--space-8); font-size: 1rem; min-height: 56px; }
.btn-sm { padding: var(--space-2) var(--space-4); font-size: 0.75rem; min-height: 40px; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; height: 44px; padding: 0; border-radius: var(--radius-full); }

/* ── BUTTON STATES ─────────────────────────────────────────────────── */
.btn:disabled,
.btn.loading {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.btn.loading {
  position: relative;
  color: transparent !important;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid var(--bg-primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn-primary.loading::after {
  border-color: var(--text-primary);
  border-top-color: transparent;
}

.btn-success.loading::after {
  border-color: var(--bg-primary);
  border-top-color: transparent;
}

/* Error state for inputs */
.input-error {
  border-color: #ff4757 !important;
}

.error-message {
  color: #ff4757;
  font-size: 0.75rem;
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ── CARDS ──────────────────────────────────────────────────────────── */
.card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; transition: all var(--duration-normal) var(--ease-out); }
.card:hover { border-color: var(--border-accent); transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card-body { padding: var(--space-5); }
@media (min-width: 768px) { .card-body { padding: var(--space-6); } }

/* ── BADGES ─────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: var(--space-1) var(--space-3); font-family: 'JetBrains Mono', monospace; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; border-radius: var(--radius-sm); }
.badge-cyan { background: rgba(0, 212, 255, 0.1); color: var(--accent-cyan); border: 1px solid rgba(0, 212, 255, 0.2); }
.badge-green { background: rgba(0, 255, 65, 0.1); color: var(--accent-green); border: 1px solid rgba(0, 255, 65, 0.2); }
.badge-gold { background: rgba(255, 215, 0, 0.1); color: var(--accent-gold); border: 1px solid rgba(255, 215, 0, 0.2); }
.badge-purple { background: rgba(168, 85, 247, 0.1); color: var(--accent-purple); border: 1px solid rgba(168, 85, 247, 0.2); }
.badge-red { background: rgba(255, 71, 87, 0.1); color: #ff4757; border: 1px solid rgba(255, 71, 87, 0.2); }

/* ── FORMS ──────────────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--space-5); }
.form-label { display: block; margin-bottom: var(--space-2); font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); font-family: 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-textarea, .form-select { width: 100%; padding: var(--space-4); background: var(--bg-secondary); border: 1.5px solid var(--border-default); border-radius: var(--radius-md); color: var(--text-primary); font-size: 1rem; transition: all var(--duration-fast); }
.form-input:focus, .form-textarea:focus, .form-select:focus { outline: none; border-color: var(--accent-cyan); background: rgba(0, 212, 255, 0.05); box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.1); }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 120px; }
.form-hint { margin-top: var(--space-2); font-size: 0.75rem; color: var(--text-muted); }
.form-error { margin-top: var(--space-2); font-size: 0.75rem; color: #ff4757; }

/* ── SECTION ───────────────────────────────────────────────────────── */
.section { padding: var(--space-12) 0; }
@media (min-width: 768px) { .section { padding: var(--space-20) 0; } }
.section-header { text-align: center; margin-bottom: var(--space-10); }
.section-label { font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: var(--accent-cyan); text-transform: uppercase; letter-spacing: 3px; margin-bottom: var(--space-3); }
.section-title { font-size: clamp(1.75rem, 5vw, 2.5rem); font-weight: 800; letter-spacing: -0.5px; margin-bottom: var(--space-4); }
.section-subtitle { font-size: 1.1rem; color: var(--text-secondary); max-width: 600px; margin: 0 auto; }

/* ── PROGRESS BAR ──────────────────────────────────────────────────── */
.progress-bar { height: 8px; background: var(--bg-secondary); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent-cyan), var(--accent-green)); border-radius: 4px; transition: width 0.5s ease; }

/* ── EMPTY STATE ───────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: var(--space-12) var(--space-6); }
.empty-icon { font-size: 3rem; margin-bottom: var(--space-4); }
.empty-title { font-size: 1.25rem; font-weight: 700; margin-bottom: var(--space-2); }
.empty-message { color: var(--text-secondary); max-width: 400px; margin: 0 auto; }

/* ── ANIMATIONS ────────────────────────────────────────────────────── */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(20px); } }

/* ── MOBILE UTILITIES ─────────────────────────────────────────────── */
@media (max-width: 767px) {
  .mobile-only { display: block !important; }
  .desktop-only { display: none !important; }
}
@media (min-width: 768px) {
  .mobile-only { display: none !important; }
  .desktop-only { display: block !important; }
}

/* ── RIFA CARD COMPONENTS ──────────────────────────────────────────── */
.rifa-card-image { position: relative; aspect-ratio: 16/9; overflow: hidden; background: var(--bg-secondary); }
.rifa-card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.rifa-card:hover .rifa-card-image img { transform: scale(1.05); }
.rifa-card-body { padding: var(--space-5); flex: 1; display: flex; flex-direction: column; }
.rifa-card-title { font-size: 1.1rem; font-weight: 700; margin-bottom: var(--space-3); line-height: 1.3; }
.rifa-card-meta { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-bottom: var(--space-4); }
.meta-item { display: flex; flex-direction: column; }
.meta-label { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-family: 'JetBrains Mono', monospace; margin-bottom: var(--space-1); }
.meta-value { font-size: 0.9rem; font-weight: 700; }
.rifa-card-footer { margin-top: auto; display: flex; justify-content: space-between; align-items: center; }
.rifa-card-price { display: flex; flex-direction: column; }
.price-label { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-family: 'JetBrains Mono', monospace; }
.price-value { font-size: 1rem; font-weight: 800; color: var(--accent-green); }
.rifa-card-actions { display: flex; gap: var(--space-2); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }

/* ── STAT CARD ─────────────────────────────────────────────────────── */
.stat-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: var(--space-5); display: flex; align-items: center; gap: var(--space-4); }
.stat-icon { font-size: 1.8rem; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: rgba(0, 212, 255, 0.1); border-radius: var(--radius-md); flex-shrink: 0; }
.stat-content { display: flex; flex-direction: column; }
.stat-value { font-size: 1.5rem; font-weight: 800; }
.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-family: 'JetBrains Mono', monospace; }

/* ── FOOTER ─────────────────────────────────────────────────────────── */
.footer { padding: var(--space-12) var(--space-4); border-top: 1px solid var(--border-subtle); }
.footer-grid { display: grid; gap: var(--space-8); max-width: 1140px; margin: 0 auto; }
@media (min-width: 768px) { .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; gap: var(--space-12); } }
.footer-brand { max-width: 300px; }
.footer-brand .logo { margin-bottom: var(--space-4); }
.footer-brand p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; }
.footer-col h4 { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); margin-bottom: var(--space-4); }
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: var(--space-3); }
.footer-col a { font-size: 0.85rem; color: var(--text-muted); transition: color var(--duration-fast); }
.footer-col a:hover { color: var(--accent-cyan); }
.footer-bottom { max-width: 1140px; margin: var(--space-10) auto 0; padding-top: var(--space-6); border-top: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: var(--space-4); align-items: center; text-align: center; }
@media (min-width: 640px) { .footer-bottom { flex-direction: row; justify-content: space-between; } }
.footer-copy { font-size: 0.75rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.footer-status { font-size: 0.7rem; color: var(--accent-green); font-family: 'JetBrains Mono', monospace; }

/* ── TOAST ANIMATION ───────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: calc(100% - 32px); max-width: 400px; }
