/**
 * Base Styles - Reset y fundamentos
 * Optimizado para mobile-first (iPhone)
 */

/* ===================================
   CSS RESET (Modern Normalize)
   =================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  font-size: 16px; /* Base para rem units */
  height: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100%;
  position: relative;
}

/* ===================================
   TIPOGRAFÍA BASE
   =================================== */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
  color: var(--text-primary);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); }

p {
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: opacity var(--transition-fast) var(--ease-out);
}

a:active {
  opacity: var(--opacity-subtle);
}

strong, b {
  font-weight: var(--font-weight-semibold);
}

small {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
}

/* ===================================
   LISTAS
   =================================== */

ul, ol {
  list-style: none;
}

/* ===================================
   FORMULARIOS
   =================================== */

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
  user-select: none;
  -webkit-touch-callout: none;
}

input, textarea {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Deshabilitar zoom en inputs (iOS) */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea {
  font-size: 16px; /* Evita zoom automático en iOS */
}

/* ===================================
   IMÁGENES Y MEDIOS
   =================================== */

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

svg {
  fill: currentColor;
}

/* ===================================
   UTILIDADES GLOBALES
   =================================== */

.hidden {
  display: none !important;
}

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

/* ===================================
   LAYOUT PRINCIPAL
   =================================== */

#app {
  min-height: 100vh;
  min-height: -webkit-fill-available; /* iOS Safari fix */
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg-secondary);
}

/* ===================================
   HEADER
   =================================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-4) var(--content-padding-horizontal);
  padding-top: max(var(--space-4), var(--safe-area-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
}

.app-header h1 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  flex: 1;
}

/* ===================================
   MAIN CONTENT
   =================================== */

.main-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* iOS momentum scrolling */
  padding: var(--space-4) var(--content-padding-horizontal);
  padding-bottom: calc(var(--bottom-nav-total-height) + var(--space-4));
  max-width: var(--container-max-width);
  margin: 0 auto;
  width: 100%;
}

/* ===================================
   BOTTOM NAVIGATION
   =================================== */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-fixed);
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  padding-bottom: max(var(--space-2), var(--safe-area-bottom));
  height: var(--bottom-nav-total-height);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
}

/* ===================================
   SCROLLBAR (Desktop)
   =================================== */

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

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-quaternary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ===================================
   ANIMACIONES GLOBALES
   =================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

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

/* ===================================
   PREVENT OVERSCROLL (iOS bounce)
   =================================== */

body {
  overscroll-behavior-y: none;
}

/* ===================================
   FOCUS VISIBLE (Accesibilidad)
   =================================== */

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ===================================
   SELECCIÓN DE TEXTO
   =================================== */

::selection {
  background-color: var(--color-primary);
  color: white;
}

::-moz-selection {
  background-color: var(--color-primary);
  color: white;
}
