/**
 * ============================================================================
 * TEAM DASHBOARD MOBILE - RESET CSS
 * ============================================================================
 * 
 * Archivo: 02-reset-mobile.css
 * Versión: 1.0.0
 * Descripción: Reset/Normalize CSS optimizado para móvil. Normaliza estilos
 *              entre navegadores y establece defaults para touch interactions.
 * 
 * Principios:
 * - Box-sizing universal para cálculos predecibles
 * - Touch-optimized (tap highlights, smooth scrolling)
 * - Reset de márgenes y paddings molestos
 * - Base tipográfica consistente
 * - Accesibilidad (focus states, contrast)
 * 
 * Navegadores soportados:
 * - iOS Safari 12+
 * - Chrome Android 8+
 * - Firefox Mobile
 * ============================================================================
 */


/* ============================================================================
   BOX SIZING UNIVERSAL
   ============================================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}


/* ============================================================================
   HTML Y BODY BASE
   ============================================================================ */

html {
  /* Font size base: 16px (permite usar rem correctamente) */
  font-size: 16px;
  
  /* Smooth scrolling para navegación interna */
  scroll-behavior: smooth;
  
  /* Prevenir ajuste automático del tamaño de fuente en iOS */
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  
  /* Mejor rendering de fuentes */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  
  /* Altura mínima completa */
  min-height: 100%;
}

body {
  /* Colores base desde tokens */
  background-color: var(--color-bg-primary, #0a0e27);
  color: var(--color-text-primary, #ffffff);
  
  /* Tipografía base */
  font-family: var(--font-primary, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
  font-size: var(--mobile-text-md, 0.9375rem); /* 15px */
  font-weight: var(--font-weight-regular, 400);
  line-height: var(--line-height-normal, 1.5);
  
  /* Altura mínima completa */
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height (mejor para móvil) */
  
  /* Prevenir scroll horizontal no deseado */
  overflow-x: hidden;
  
  /* Smooth scrolling en iOS */
  -webkit-overflow-scrolling: touch;
}


/* ============================================================================
   ELEMENTOS DE TEXTO
   ============================================================================ */

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  padding: 0;
  font-weight: var(--font-weight-bold, 700);
  line-height: var(--line-height-tight, 1.2);
  color: var(--color-text-primary, #ffffff);
}

p {
  margin: 0;
  padding: 0;
}

a {
  color: var(--color-primary, #00d9ff);
  text-decoration: none;
  transition: var(--transition-colors);
  
  /* Touch feedback */
  -webkit-tap-highlight-color: rgba(0, 217, 255, 0.1);
}

a:hover {
  color: var(--color-primary-light, #33e3ff);
}

a:active {
  color: var(--color-primary-dark, #00a8cc);
}

strong, b {
  font-weight: var(--font-weight-bold, 700);
}

em, i {
  font-style: italic;
}

small {
  font-size: var(--mobile-text-sm, 0.8125rem);
}

code, kbd, samp, pre {
  font-family: var(--font-mono, 'SF Mono', monospace);
  font-size: 0.875em;
}


/* ============================================================================
   LISTAS
   ============================================================================ */

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}


/* ============================================================================
   IMÁGENES Y MEDIA
   ============================================================================ */

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  /* Prevenir problemas de espacio debajo de imágenes */
  vertical-align: middle;
  
  /* Mejor calidad de imagen en pantallas retina */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

svg {
  /* SVGs deben ser flexibles por defecto */
  width: 100%;
  height: 100%;
  fill: currentColor;
}


/* ============================================================================
   FORMULARIOS
   ============================================================================ */

button, input, optgroup, select, textarea {
  font-family: inherit;
  font-size: 100%;
  line-height: inherit;
  margin: 0;
  padding: 0;
  color: inherit;
}

button, select {
  text-transform: none;
}

button,
[type="button"],
[type="reset"],
[type="submit"] {
  /* Cursor pointer en botones */
  cursor: pointer;
  
  /* Eliminar estilos nativos de iOS */
  -webkit-appearance: none;
  appearance: none;
  
  /* Eliminar borde por defecto */
  border: none;
  background: none;
  
  /* Touch feedback */
  -webkit-tap-highlight-color: rgba(0, 217, 255, 0.1);
  
  /* Touch action optimization */
  touch-action: manipulation;
  
  /* User select (no seleccionar texto del botón) */
  user-select: none;
  -webkit-user-select: none;
}

button:disabled,
[type="button"]:disabled,
[type="reset"]:disabled,
[type="submit"]:disabled {
  cursor: not-allowed;
  opacity: var(--opacity-disabled, 0.4);
}

input,
textarea,
select {
  /* Eliminar estilos nativos */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  
  /* Border y background base */
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.1));
  background-color: var(--color-bg-secondary, #1a1f3a);
  
  /* Border radius */
  border-radius: var(--radius-md, 0.75rem);
  
  /* Padding base */
  padding: var(--padding-input, 0.75rem);
  
  /* Transition */
  transition: var(--transition-colors);
  
  /* Touch feedback */
  -webkit-tap-highlight-color: transparent;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary, #00d9ff);
  box-shadow: 0 0 0 3px var(--color-primary-alpha, rgba(0, 217, 255, 0.1));
}

textarea {
  /* Permitir resize solo vertical */
  resize: vertical;
  
  /* Altura mínima */
  min-height: 5rem;
}

/* Eliminar spinner de inputs numéricos */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* Inputs de búsqueda */
input[type="search"] {
  -webkit-appearance: none;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
}

/* Checkboxes y radios */
input[type="checkbox"],
input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
}


/* ============================================================================
   TABLAS
   ============================================================================ */

table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

th {
  text-align: left;
  font-weight: var(--font-weight-semibold, 600);
}


/* ============================================================================
   ELEMENTOS INTERACTIVOS
   ============================================================================ */

/* Optimización para touch */
a, button, input, select, textarea, [role="button"] {
  /* Prevenir el comportamiento de "callout" en iOS */
  -webkit-touch-callout: none;
}

/* Área táctil mínima (44x44px según Apple/Google guidelines) */
button,
[role="button"],
input[type="button"],
input[type="submit"],
input[type="reset"],
a[role="button"] {
  min-height: var(--touch-target-min, 2.75rem); /* 44px */
  min-width: var(--touch-target-min, 2.75rem);
}


/* ============================================================================
   FOCUS VISIBLE (Accesibilidad)
   ============================================================================ */

/* Focus outline solo cuando se usa teclado */
:focus-visible {
  outline: 2px solid var(--color-primary, #00d9ff);
  outline-offset: 2px;
}

/* Eliminar outline cuando se usa touch/mouse */
:focus:not(:focus-visible) {
  outline: none;
}


/* ============================================================================
   SELECCIÓN DE TEXTO
   ============================================================================ */

::selection {
  background-color: var(--color-primary, #00d9ff);
  color: var(--color-text-inverted, #0a0e27);
}

::-moz-selection {
  background-color: var(--color-primary, #00d9ff);
  color: var(--color-text-inverted, #0a0e27);
}


/* ============================================================================
   SCROLLBARS PERSONALIZADOS (Webkit)
   ============================================================================ */

/* Scrollbar en contenedores con scroll */
::-webkit-scrollbar {
  width: var(--scrollbar-width, 0.375rem);
  height: var(--scrollbar-width, 0.375rem);
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track, transparent);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb, rgba(255, 255, 255, 0.2));
  border-radius: var(--radius-full, 9999px);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover, rgba(255, 255, 255, 0.3));
}

/* Ocultar scrollbar en Firefox (opcional) */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb, rgba(255, 255, 255, 0.2)) 
                   var(--scrollbar-track, transparent);
}


/* ============================================================================
   ELEMENTOS HR (Horizontal Rule / Divider)
   ============================================================================ */

hr {
  height: var(--divider-width, 1px);
  border: none;
  background-color: var(--divider-color, var(--color-border, rgba(255, 255, 255, 0.1)));
  margin: var(--space-lg, 1rem) 0;
}


/* ============================================================================
   ELEMENTOS HIDDEN
   ============================================================================ */

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}


/* ============================================================================
   UTILIDADES DE ACCESIBILIDAD
   ============================================================================ */

/* Respetar preferencias de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Alto contraste en modo alto contraste */
@media (prefers-contrast: high) {
  :root {
    --color-border: rgba(255, 255, 255, 0.3);
    --color-border-light: rgba(255, 255, 255, 0.4);
  }
}


/* ============================================================================
   SAFE AREAS (Para notch, island, etc.)
   ============================================================================ */

/* Soporte para safe areas en iOS (notch, Dynamic Island) */
body {
  /* Padding para safe areas */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}


/* ============================================================================
   PREVENIR COMPORTAMIENTOS NO DESEADOS EN MÓVIL
   ============================================================================ */

/* Prevenir zoom en inputs en iOS */
@media screen and (max-width: 767px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  textarea,
  select {
    font-size: 16px; /* Mínimo 16px para prevenir zoom en iOS */
  }
}

/* Prevenir pull-to-refresh en Chrome Android (si se desea) */
body {
  overscroll-behavior-y: contain;
}


/* ============================================================================
   FIN DEL RESET CSS
   ============================================================================
   
   RESUMEN:
   ✓ Box-sizing universal (border-box)
   ✓ Márgenes y paddings reseteados
   ✓ Tipografía base optimizada para móvil (15px)
   ✓ Touch optimization (-webkit-tap-highlight, touch-action)
   ✓ Smooth scrolling (iOS y general)
   ✓ Formularios normalizados y estilizados
   ✓ Focus states accesibles
   ✓ Selección de texto personalizada
   ✓ Scrollbars personalizados
   ✓ Safe areas para notch/island
   ✓ Prevención de comportamientos móviles no deseados
   ✓ Soporte para preferencias de accesibilidad
   ✓ Cross-browser normalization
   
   Este reset está 100% optimizado para móvil y listo para usar.
   ============================================================================ */