/* --- Variables de tema --- */
:root {
  --bg-dark: #0a0a14;
  --card-dark: #121428;
  --text-dark: #e6e8ff;
  --accent: #00f0ff;
  --accent-secondary: #7b61ff;
  --border: #2a2d4f;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

[data-theme="light"] {
  --bg-dark: #f8f9ff;
  --card-dark: #ffffff;
  --text-dark: #1e293b;
  --border: #e2e8f0;
  --accent: #0ea5e9;
  --accent-secondary: #6366f1;
}

/* --- Reset y base --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Exo 2', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text-dark);
  line-height: 1.6;
  transition: var(--transition);
  min-height: 100vh;
  padding-bottom: 40px;
}

/* Layered animated background (subtle) */
.bg-layered {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.bg-layered .layer {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0.12;
}
.bg-gradient-1 { background: linear-gradient(120deg, rgba(11,12,20,0.9), rgba(18,20,36,0.85)); animation: bgMove 20s linear infinite; }
.bg-gradient-2 { background: radial-gradient(circle at 10% 20%, rgba(123,97,255,0.06), transparent 20%), radial-gradient(circle at 80% 80%, rgba(0,240,255,0.04), transparent 16%); animation: bgMoveReverse 28s linear infinite; }
.bg-particles { background-image: radial-gradient(circle, rgba(255,255,255,0.02) 1px, transparent 1px); background-size: 12px 12px; opacity:0.06; animation: particleDrift 36s linear infinite; }

@keyframes bgMove { from { transform: translate3d(0,0,0); } to { transform: translate3d(-6%, -3%, 0); } }
@keyframes bgMoveReverse { from { transform: translate3d(0,0,0); } to { transform: translate3d(6%, 4%, 0); } }
@keyframes particleDrift { from { transform: translateY(0);} to { transform: translateY(-40px);} }

/* Layer container sitting behind content */
.page-backdrop { position: fixed; inset: 0; z-index: -1; }

@media (prefers-reduced-motion: reduce) {
  .bg-layered .layer { animation: none !important; }
}

.container {
  width: 92%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 15px;
}

/* --- Scroll suave --- */
html {
  scroll-behavior: smooth;
}

/* --- Tipografía gamer --- */
h1, h2, h3, h4 {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.glow {
  text-shadow: 0 0 15px var(--accent), 0 0 30px rgba(0, 240, 255, 0.4);
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* subtle floating animation for the title */
.glow.floating { animation: floatText 6s ease-in-out infinite; }
@keyframes floatText { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-6px);} }

/* --- Botón de tema --- */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--card-dark);
  border: 1px solid rgba(255,255,255,0.04);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.theme-toggle:hover {
  transform: rotate(10deg) scale(1.05);
  box-shadow: 0 12px 28px rgba(123, 97, 255, 0.22);
}

/* Animated gradient header for a premium look */
.header-animated {
  background-size: 300% 300%;
  animation: headerGradient 8s ease infinite;
}

@keyframes headerGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Micro-interaction: quick press animation */
.theme-toggle:active { transform: scale(0.98) rotate(8deg); }

/* Buttons micro-interaction */
.btn { transition: transform 160ms cubic-bezier(.2,.9,.2,1), box-shadow 160ms; }
.btn:hover { transform: translateY(-4px) scale(1.01); }
.btn:active { transform: translateY(-2px) scale(0.995); }

/* --- Header --- */
header {
  text-align: center;
  padding: 56px 0 44px;
  background: linear-gradient(180deg, rgba(14,16,30,0.95), rgba(24,26,50,0.9));
  margin-bottom: 36px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  border-radius: 0 0 18px 18px;
  box-shadow: 0 20px 45px rgba(6,8,20,0.6);
}

header h1 {
  font-size: 3rem;
  margin-bottom: 16px;
}

header p {
  font-size: 1.3rem;
  opacity: 0.9;
  max-width: 650px;
  margin: 0 auto;
}

/* --- Tabs --- */
.tabs {
  background: var(--card-dark);
  padding: 16px 0;
  border-radius: 20px;
  margin-bottom: 35px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.2);
  backdrop-filter: blur(12px);
}

.tabs .container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.tab-btn {
  background: transparent;
  border: 2px solid transparent;
  color: var(--text-dark);
  padding: 14px 24px;
  border-radius: 14px;
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover {
  border-color: var(--accent-secondary);
  transform: translateY(-3px);
}

.tab-btn.active {
  background: var(--accent-secondary);
  color: white;
  border-color: var(--accent-secondary);
  box-shadow: 0 6px 18px rgba(123, 97, 255, 0.5);
}

/* --- Contenido de pestañas --- */
.tab-content {
  display: none;
  animation: fadeIn 0.6s ease;
}

.tab-content.active {
  display: block;
}

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

/* --- Formularios --- */
.form-group {
  margin-bottom: 24px;
}

label {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
  color: var(--accent);
  font-size: 1.1rem;
}

input, select, textarea {
  width: 100%;
  padding: 16px;
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 14px;
  background: var(--bg-dark);
  color: var(--text-dark);
  font-size: 16px;
  transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 4px rgba(123, 97, 255, 0.3);
}

/* --- Autocompletado --- */
.autocomplete {
  position: relative;
  width: 100%;
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, rgba(18,20,36,0.98), rgba(20,22,40,0.98));
  border: 1px solid rgba(255,255,255,0.03);
  border-radius: 12px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 10;
  display: none;
  box-shadow: 0 18px 40px rgba(6,8,20,0.6);
  margin-top: 6px;
}

.suggestions div {
  padding: 14px 18px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
  display: flex;
  align-items: center;
}

.suggestions div:hover {
  background: linear-gradient(90deg, rgba(123,97,255,0.24), rgba(0,240,255,0.06));
  color: white;
}

.suggestions div:last-child {
  border-bottom: none;
}

/* --- Selector de juegos --- */
.game-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.selected-games {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 12px;
}

.game-chip {
  background: linear-gradient(90deg, rgba(123,97,255,0.12), rgba(0,240,255,0.06));
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(123,97,255,0.12);
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-weight: 600;
}

.game-chip button {
  background: transparent;
  border: none;
  color: var(--accent-secondary);
  cursor: pointer;
  font-weight: 700;
}

.game-chip .quality-select {
  background: transparent;
  border: 1px solid rgba(123,97,255,0.08);
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 600;
  color: var(--text-dark);
}

.compare-results-grid {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.compare-detail {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.compare-detail .col { background: var(--card-dark); padding:12px; border-radius:8px; border:1px solid var(--border); }

/* --- Botones --- */
.btn {
  padding: 16px 32px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Orbitron', sans-serif;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(90deg, #7b61ff 0%, #00f0ff 100%);
  color: #02101a;
  box-shadow: 0 10px 30px rgba(11,12,20,0.55), 0 4px 12px rgba(0,240,255,0.08) inset;
  transform: translateZ(0);
}

.btn-primary:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 22px 48px rgba(11,12,20,0.6), 0 6px 18px rgba(0,240,255,0.06) inset;
}

.btn-secondary {
  background: linear-gradient(90deg, rgba(75,85,99,0.95), rgba(60,64,77,0.95));
  color: white;
  border: 1px solid rgba(255,255,255,0.03);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

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

/* Ripple effect */
.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  background: rgba(255,255,255,0.12);
  animation: ripple 600ms linear;
  pointer-events: none;
}
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

.form-actions {
  display:flex;
  gap:12px;
  align-items:center;
}

/* Price search results */
.prices-list { display:flex; flex-direction:column; gap:10px; }
.price-row { display:flex; flex-direction:column; background:rgba(255,255,255,0.03); padding:10px; border-radius:8px; border:1px solid rgba(255,255,255,0.04); }
.price-row .price-game { font-weight:600; margin-bottom:6px; }
.price-row .price-stores { display:flex; gap:12px; flex-wrap:wrap; }
.price-item { background:linear-gradient(90deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01)); padding:6px 8px; border-radius:6px; font-size:0.95rem; }

@media (min-width:900px) {
  .price-row { flex-direction:row; align-items:center; justify-content:space-between; }
  .price-row .price-game { margin-bottom:0; }
}

/* --- Resultados y reportes --- */
.result-box, .report-box {
  margin-top: 30px;
  padding: 28px;
  background: linear-gradient(180deg, rgba(18,20,36,0.95), rgba(16,18,32,0.95));
  border-radius: 20px;
  border-left: 6px solid var(--accent);
  display: none;
  animation: slideIn 0.5s ease;
  box-shadow: 0 30px 60px rgba(6,8,20,0.6);
  position: relative;
  overflow: hidden;
}

.report-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: linear-gradient(to bottom, var(--accent), var(--accent-secondary));
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-25px); }
  to { opacity: 1; transform: translateX(0); }
}

.warning {
  color: var(--warning);
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-item {
  background: rgba(123, 97, 255, 0.08);
  padding: 20px;
  border-radius: 16px;
  margin-bottom: 20px;
  border-left: 5px solid var(--accent-secondary);
  transition: var(--transition);
}

.game-item:hover {
  background: rgba(123, 97, 255, 0.15);
  transform: translateX(6px);
}

/* entrance animation for items */
.animate-in { opacity: 0; transform: translateY(12px); transition: opacity 520ms ease, transform 520ms ease; }
.animate-in.visible { opacity: 1; transform: translateY(0); }

/* additional polished micro-animations */
.card-tilt { transition: transform 420ms cubic-bezier(.2,.9,.2,1), box-shadow 320ms; }
.card-tilt:hover { transform: translateY(-10px) rotateX(1deg); box-shadow: 0 30px 80px rgba(6,8,20,0.6); }

/* make header elements animate-in too */
header .container > * { will-change: transform, opacity; }

/* --- Comparador --- */
.compare-grid {
  display: flex;
  gap: 28px;
  align-items: center;
  margin: 30px 0;
  flex-wrap: wrap;
}

.compare-card {
  flex: 1;
  min-width: 240px;
  background: linear-gradient(180deg, rgba(18,20,36,0.6), rgba(24,26,40,0.48));
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  padding: 28px 26px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.04);
  box-shadow: 0 18px 40px rgba(6,8,20,0.55), inset 0 1px 0 rgba(255,255,255,0.02);
  transition: transform 380ms cubic-bezier(.2,.9,.2,1), box-shadow 320ms, border-color 300ms;
}

.compare-card:hover {
  border-color: rgba(123,97,255,0.6);
  transform: translateY(-8px) scale(1.01);
  box-shadow: 0 30px 70px rgba(6,8,20,0.7), inset 0 1px 0 rgba(255,255,255,0.02);
}

/* inputs inside compare cards: softer, darker field */
.compare-card input, .compare-card select {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.04);
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--text-dark);
}

/* diagonal glass overlay removed for a cleaner compare card appearance */
.compare-card::before { content: none; }

/* tilt transform helper (toggled by JS) */
.compare-card.tilt { will-change: transform; transform-style: preserve-3d; }

/* entrance animation: use animate-in class */
.compare-card.animate-in { opacity: 0; transform: translateY(18px) scale(0.995); }
.compare-card.animate-in.visible { opacity: 1; transform: translateY(0) scale(1); transition: opacity 520ms ease, transform 520ms cubic-bezier(.2,.9,.2,1); }

/* subtle shine overlay intentionally disabled; keep hover transform only */
.compare-card::after { content: none; }

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
  .header-animated { animation: none !important; }
  .glow.floating { animation: none !important; }
  .animate-in { transition: none !important; transform: none !important; opacity: 1 !important; }
  .compare-card::after { transition: none !important; }
}

.vs {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--accent);
  margin: 0 16px;
  text-shadow: 0 0 15px rgba(0, 240, 255, 0.6);
}

/* --- Optimizador --- */
.optimizer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  margin: 30px 0;
}

.optimizer-card {
  background: var(--card-dark);
  padding: 24px;
  border-radius: 20px;
  border: 2px solid var(--border);
  transition: var(--transition);
}

.optimizer-card:hover {
  border-color: var(--accent-secondary);
  transform: translateY(-5px);
}

.optimizer-card h3 {
  color: var(--accent);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Optimizer card enhancements */
.optimizer-card {
  position: relative;
  background: linear-gradient(180deg, rgba(18,20,36,0.6), rgba(20,22,40,0.5));
  border: 1px solid rgba(255,255,255,0.04);
  box-shadow: 0 20px 50px rgba(6,8,20,0.55);
}
.optimizer-card p { opacity: 0.95; margin-bottom: 14px; }
.card-actions { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.card-actions .btn { padding:10px 16px; font-size:0.95rem; }

/* Checklist download button */
#downloadChecklist { padding: 12px 20px; }

/* Toast notification */
.toast {
  position: fixed;
  right: 20px;
  bottom: 24px;
  background: linear-gradient(90deg, var(--accent-secondary), var(--accent));
  color: #02101a;
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(6,8,20,0.6);
  z-index: 200;
  font-weight: 700;
  transform: translateY(8px);
  opacity: 0;
  transition: transform 260ms ease, opacity 260ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Steps panel inside optimizer cards */
.optimizer-card .steps {
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(0,0,0,0.35);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.03);
  color: var(--text-dark);
  font-size: 0.95rem;
}
.optimizer-card .steps ol { margin-left: 18px; }
.optimizer-card .steps li { margin-bottom: 8px; }
.optimizer-card .steps li::marker { color: var(--accent-secondary); font-weight: 900; }

/* Make the warn box more visually distinct and accessible */
.warn {
  margin-top: 10px;
  padding: 10px;
  border-left: 4px solid var(--warning);
  background: linear-gradient(90deg, rgba(251,191,36,0.04), rgba(255,255,255,0.01));
  color: var(--warning);
  border-radius: 8px;
  font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
  .optimizer-card .steps { transition: none !important; }
}

/* Warning text inside steps */
.warn {
  margin-top: 10px;
  padding: 10px;
  border-left: 4px solid var(--warning);
  background: rgba(250, 230, 180, 0.03);
  color: var(--warning);
  border-radius: 8px;
  font-weight: 700;
}

/* Ensure icon buttons have consistent width and center alignment */
[data-steps-toggle] { display:inline-flex; align-items:center; gap:8px; }
[data-steps-toggle] svg { width:18px; height:18px; }

/* --- Historial --- */
.history-list {
  background: var(--card-dark);
  padding: 24px;
  border-radius: 20px;
  margin: 25px 0;
}

.history-item {
  background: rgba(123, 97, 255, 0.05);
  padding: 16px;
  border-radius: 14px;
  margin-bottom: 12px;
  border-left: 3px solid var(--accent-secondary);
}

/* --- Footer --- */
footer {
  text-align: center;
  padding: 35px 0 15px;
  margin-top: 50px;
  color: #a0a4d0;
  border-top: 1px solid var(--border);
  font-size: 1rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  header h1 {
    font-size: 2.6rem;
  }

  header p {
    font-size: 1.1rem;
  }

  .tabs .container {
    flex-direction: column;
    align-items: center;
  }

  .tab-btn {
    width: 90%;
    justify-content: center;
  }

  .compare-grid {
    flex-direction: column;
    text-align: center;
  }

  .vs {
    margin: 20px 0;
  }

  .form-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  header {
    padding: 50px 0 30px;
  }

  header h1 {
    font-size: 2.2rem;
  }

  .container {
    width: 95%;
  }
}

/* skip-link removed by user preference */

/* Focus visible improvements for keyboard users */
.theme-toggle:focus, .tab-btn:focus, .btn:focus, input:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 4px rgba(123, 97, 255, 0.28);
  outline: none;
}

/* Make tab buttons wrap into a scrollable row on very small screens */
@media (max-width: 420px) {
  .tabs .container { overflow-x: auto; -webkit-overflow-scrolling: touch; gap:8px; padding:6px 4px; }
  .tab-btn { white-space: nowrap; }
  .theme-toggle { right: 12px; top: 12px; width:48px; height:48px; }
}