/* RuletaNombres.es - Advanced CSS Styles */

/* CSS Variables for Dynamic Theming */
:root {
  /* Primary Colors */
  --primary-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --secondary-gradient: linear-gradient(135deg, #ec4899, #f59e0b);
  --success-gradient: linear-gradient(135deg, #10b981, #34d399);
  --danger-gradient: linear-gradient(135deg, #ef4444, #f87171);
  
  /* Wheel Specific Colors */
  --wheel-border: #ffffff;
  --wheel-shadow: rgba(0, 0, 0, 0.3);
  --pointer-color: #ef4444;
  --center-button-gradient: linear-gradient(135deg, #6366f1, #ec4899);
  
  /* Glass Effect */
  --glass-bg: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
  
  /* Animation Timings */
  --transition-fast: 0.15s ease-in-out;
  --transition-normal: 0.3s ease-in-out;
  --transition-slow: 0.5s ease-in-out;
  --bounce-duration: 0.6s;
  
  /* Spacing */
  --container-padding: 1.5rem;
  --element-spacing: 1rem;
  
  /* Typography */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Fredoka One', cursive;
  --font-script: 'Pacifico', cursive;
  
  /* Z-Index Layers */
  --z-wheel: 10;
  --z-pointer: 20;
  --z-button: 30;
  --z-modal: 50;
  --z-confetti: 40;
}

/* Dark mode variables */
.dark {
  --glass-bg: rgba(17, 24, 39, 0.3);
  --glass-border: rgba(55, 65, 81, 0.3);
  --wheel-border: #374151;
  --wheel-shadow: rgba(0, 0, 0, 0.5);
}

/* Font Face Declarations */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Fredoka+One:wght@400&family=Pacifico&display=swap');

/* Global Styles */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(156, 163, 175, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

/* Glass Effect Utility */
.glass-effect {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* Wheel Styles */
#wheel-container {
  perspective: 1000px;
  transform-style: preserve-3d;
}

#wheel-canvas {
  border-radius: 50%;
  border: 8px solid var(--wheel-border);
  box-shadow: 
    0 0 0 4px rgba(99, 102, 241, 0.3),
    0 20px 40px var(--wheel-shadow),
    inset 0 0 50px rgba(0, 0, 0, 0.1);
  transition: all var(--transition-normal);
  will-change: transform;
  transform: translateZ(0); /* Hardware acceleration */
}

#wheel-canvas:hover {
  box-shadow: 
    0 0 0 6px rgba(99, 102, 241, 0.4),
    0 25px 50px var(--wheel-shadow),
    inset 0 0 60px rgba(0, 0, 0, 0.1);
  transform: translateZ(0) scale(1.02);
}

/* Wheel Spinning Animation */
.wheel-spinning {
  animation: wheelSpin linear forwards;
}

@keyframes wheelSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(var(--spin-rotation, 1800deg));
  }
}

/* Wheel Pointer */
#wheel-pointer {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
  animation: pointerBounce 2s ease-in-out infinite;
  z-index: var(--z-pointer);
}

@keyframes pointerBounce {
  0%, 100% { transform: translateX(-50%) translateY(-8px) scale(1); }
  50% { transform: translateX(-50%) translateY(-12px) scale(1.1); }
}

/* Center Spin Button */
#spin-button {
  background: var(--center-button-gradient);
  border: 4px solid white;
  box-shadow: 
    0 8px 20px rgba(99, 102, 241, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.3);
  z-index: var(--z-button);
  transition: all var(--transition-normal);
  will-change: transform, box-shadow;
  font-family: var(--font-display);
  letter-spacing: 1px;
}

#spin-button:hover {
  transform: translateX(-50%) translateY(-50%) scale(1.1);
  box-shadow: 
    0 12px 25px rgba(99, 102, 241, 0.5),
    inset 0 2px 4px rgba(255, 255, 255, 0.4);
}

#spin-button:active {
  transform: translateX(-50%) translateY(-50%) scale(0.95);
}

#spin-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: translateX(-50%) translateY(-50%) scale(1);
}

/* Spin Button States */
.spinning #spin-button {
  animation: buttonPulse 1s ease-in-out infinite;
}

@keyframes buttonPulse {
  0%, 100% { 
    box-shadow: 
      0 8px 20px rgba(99, 102, 241, 0.4),
      inset 0 2px 4px rgba(255, 255, 255, 0.3);
  }
  50% { 
    box-shadow: 
      0 12px 30px rgba(99, 102, 241, 0.6),
      inset 0 2px 4px rgba(255, 255, 255, 0.5);
  }
}

/* Header Logo Animation */
.animate-spin-slow {
  animation: slowSpin 20s linear infinite;
}

@keyframes slowSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Button Hover Effects */
button {
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s, height 0.3s;
}

button:active::before {
  width: 300px;
  height: 300px;
}

/* Gradient Text Effect */
.gradient-text {
  background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 3s ease-in-out infinite;
}

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

/* Names List Styles */
.name-item {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 0.75rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  transition: all var(--transition-normal);
  animation: slideInLeft 0.3s ease-out;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dark .name-item {
  background: rgba(55, 65, 81, 0.7);
  border: 1px solid rgba(75, 85, 99, 0.3);
}

.name-item:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateX(4px) scale(1.02);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dark .name-item:hover {
  background: rgba(55, 65, 81, 0.9);
}

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

/* Winner Display Animations */
#winner-display {
  animation: winnerPulse 1s ease-in-out infinite;
}

@keyframes winnerPulse {
  0%, 100% { 
    transform: scale(1);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
  }
  50% { 
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(251, 191, 36, 0.7);
  }
}

/* Modal Animations */
.modal-enter {
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-exit {
  animation: modalSlideOut 0.2s ease-in;
}

@keyframes modalSlideOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }
}

/* Confetti Styles */
#confetti-canvas {
  pointer-events: none;
  z-index: var(--z-confetti);
}

.confetti-particle {
  position: absolute;
  width: 10px;
  height: 10px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-100vh) rotateZ(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotateZ(720deg);
    opacity: 0;
  }
}

/* Statistics Cards */
.stat-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all var(--transition-normal);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Input Focus Effects */
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Saved Lists Animation */
.saved-list-item {
  animation: slideInRight 0.3s ease-out;
}

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

/* Color Picker Styles */
.color-picker {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: all var(--transition-normal);
}

.color-picker:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.color-picker.selected {
  border-color: #6366f1;
  transform: scale(1.2);
}

/* Theme Switch Styles */
.theme-option {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid transparent;
  border-radius: 1rem;
  padding: 1rem;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.theme-option:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.theme-option.selected {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.1);
}

/* Loading Animation */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(99, 102, 241, 0.3);
  border-top: 4px solid #6366f1;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Wheel Themes */
.wheel-theme-classic #wheel-canvas {
  border-style: solid;
  box-shadow: 
    0 0 0 4px #8b4513,
    0 20px 40px var(--wheel-shadow);
}

.wheel-theme-modern #wheel-canvas {
  border: none;
  box-shadow: 
    0 0 0 2px rgba(99, 102, 241, 0.3),
    0 20px 40px var(--wheel-shadow);
}

.wheel-theme-fun #wheel-canvas {
  border-style: dotted;
  border-width: 6px;
  box-shadow: 
    0 0 0 4px #ff6b6b,
    0 20px 40px var(--wheel-shadow);
}

.wheel-theme-elegant #wheel-canvas {
  border-width: 2px;
  border-color: #d4af37;
  box-shadow: 
    0 0 0 1px rgba(212, 175, 55, 0.3),
    0 20px 40px var(--wheel-shadow);
}

/* Responsive Design Enhancements */
@media (max-width: 768px) {
  :root {
    --container-padding: 1rem;
    --element-spacing: 0.75rem;
  }
  
  #wheel-canvas {
    width: 300px !important;
    height: 300px !important;
  }
  
  #spin-button {
    width: 60px;
    height: 60px;
    font-size: 0.75rem;
  }
  
  .name-item {
    padding: 0.5rem;
    font-size: 0.875rem;
  }
  
  h1 {
    font-size: 1.5rem !important;
  }
  
  h2 {
    font-size: 1.25rem !important;
  }
}

@media (max-width: 480px) {
  #wheel-canvas {
    width: 250px !important;
    height: 250px !important;
  }
  
  #spin-button {
    width: 50px;
    height: 50px;
    font-size: 0.625rem;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --wheel-border: #000000;
    --glass-border: rgba(0, 0, 0, 0.8);
  }
  
  .dark {
    --wheel-border: #ffffff;
    --glass-border: rgba(255, 255, 255, 0.8);
  }
}

/* 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;
  }
  
  #wheel-pointer {
    animation: none;
  }
  
  .animate-spin-slow {
    animation: none;
  }
}

/* Print Styles */
@media print {
  body {
    background: white !important;
    color: black !important;
  }
  
  .no-print,
  button,
  #adsense-top,
  #adsense-sidebar,
  #adsense-content,
  #adsense-mobile,
  footer {
    display: none !important;
  }
  
  #wheel-container {
    page-break-inside: avoid;
  }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  button {
    min-height: 44px;
    min-width: 44px;
  }
  
  .name-item {
    min-height: 44px;
  }
  
  input,
  textarea,
  select {
    min-height: 44px;
  }
}

/* Landscape Mobile Optimization */
@media (max-height: 500px) and (orientation: landscape) {
  header {
    padding: 0.5rem 0;
  }
  
  main {
    padding: 1rem 0;
  }
  
  #wheel-canvas {
    width: 200px !important;
    height: 200px !important;
  }
  
  #spin-button {
    width: 40px;
    height: 40px;
    font-size: 0.5rem;
  }
}

/* Focus Visible Support */
.focus-visible:focus {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

/* Selection Styles */
::selection {
  background: rgba(99, 102, 241, 0.3);
  color: inherit;
}

.dark ::selection {
  background: rgba(139, 92, 246, 0.4);
}

/* Utility Classes */
.glass-morphism {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.dark .glass-morphism {
  background: rgba(17, 24, 39, 0.25);
  border: 1px solid rgba(55, 65, 81, 0.18);
}

.text-shadow {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.transition-gpu {
  will-change: transform;
  transform: translateZ(0);
}

/* Advanced Gradients */
.gradient-purple {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.gradient-sunset {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.gradient-ocean {
  background: linear-gradient(135deg, #2196f3 0%, #21cbf3 100%);
}

.gradient-forest {
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

/* Wheel Segment Hover Effect */
.wheel-segment-hover {
  filter: brightness(1.2) saturate(1.1);
  transform: scale(1.02);
  transition: all 0.2s ease;
}

/* Custom Range Slider */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #6366f1, #8b5cf6);
  outline: none;
  opacity: 0.7;
  transition: opacity var(--transition-normal);
}

input[type="range"]:hover {
  opacity: 1;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #6366f1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: all var(--transition-normal);
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: #4f46e5;
  transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #6366f1;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: all var(--transition-normal);
}

input[type="range"]::-moz-range-thumb:hover {
  background: #4f46e5;
  transform: scale(1.2);
}

/* Performance Optimizations */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

.hardware-accelerated {
  will-change: transform, opacity;
}

/* Accessibility Improvements */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus States */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

/* Animation Performance */
@media (prefers-reduced-motion: no-preference) {
  .animate-on-scroll {
    animation: fadeInUp 0.6s ease-out;
  }
}

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

/* Container Queries Support (Future-proofing) */
@container (max-width: 600px) {
  .container-responsive {
    flex-direction: column;
  }
}
