/**
 * Simulador de Créditos de Carbono - Estilos
 * Mobile-first, ultramodular y limpio
 */

/* ═══════════════════════════════════════════════════════════════════════════
   BASE & RESET
   ═══════════════════════════════════════════════════════════════════════════ */

* {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height para móviles */
}

/* ═══════════════════════════════════════════════════════════════════════════
   CUSTOM BREAKPOINT: XS (320px - 480px)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (min-width: 375px) {
  .xs\:flex-row { flex-direction: row; }
  .xs\:justify-between { justify-content: space-between; }
  .xs\:items-center { align-items: center; }
  .xs\:w-24 { width: 6rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SLIDER - Touch-friendly y responsive
   ═══════════════════════════════════════════════════════════════════════════ */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #e5e7eb;
  cursor: pointer;
  touch-action: pan-x;
  margin: 4px 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.4);
}

input[type="range"]:active::-moz-range-thumb {
  transform: scale(1.15);
}

/* Mobile: Thumb más grande para touch */
@media (max-width: 640px) {
  input[type="range"] {
    height: 10px;
  }
  input[type="range"]::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
  }
  input[type="range"]::-moz-range-thumb {
    width: 28px;
    height: 28px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   INPUT NUMBER - Mobile optimized
   ═══════════════════════════════════════════════════════════════════════════ */

input[type="number"] {
  -moz-appearance: textfield;
  font-size: 16px; /* Previene zoom en iOS */
  min-height: 44px; /* Touch target mínimo */
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS - Touch friendly (44px mínimo)
   ═══════════════════════════════════════════════════════════════════════════ */

button {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  min-height: 44px;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

button:active {
  transform: scale(0.98);
}

@media (hover: hover) {
  button:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════ */

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

.animate-fadeIn {
  animation: fadeIn 0.25s ease-out;
}

/* Reducir animaciones si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SCROLLBAR - Minimal
   ═══════════════════════════════════════════════════════════════════════════ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FOCUS STATES - Accesibilidad
   ═══════════════════════════════════════════════════════════════════════════ */

input:focus,
select:focus,
button:focus {
  outline: none;
}

input:focus-visible,
button:focus-visible {
  outline: 2px solid #22c55e;
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════════════════ */

.transition-all {
  transition: all 0.2s ease;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

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

/* ═══════════════════════════════════════════════════════════════════════════
   TABLE - Horizontal scroll para móvil
   ═══════════════════════════════════════════════════════════════════════════ */

.overflow-x-auto {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* Indicador visual de scroll horizontal */
.overflow-x-auto::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.8));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SAFE AREAS - Dispositivos con notch
   ═══════════════════════════════════════════════════════════════════════════ */

@supports (padding: max(0px)) {
  .px-3 {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }
  
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   DARK MODE (Opcional - respeta preferencia del sistema)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
  /* Preparado para futuro dark mode */
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════════════════════ */

@media print {
  body {
    background: white !important;
  }
  
  .shadow-lg {
    box-shadow: none !important;
  }
  
  button {
    display: none !important;
  }
}
