/* ==============================================
   TIPOGRAFÍA RESPONSIVE GLOBAL - BONDCOMMERCE
   ============================================== */

/* === VARIABLES TIPOGRÁFICAS === */
:root {
  /* Fuentes base */
  --font-primary: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-secondary: "Baloo Thambi 2", cursive;
  --font-mono: "SF Mono", "Monaco", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  
  /* Escalas tipográficas responsive */
  --fs-xs: clamp(0.7rem, 1.5vw, 0.8rem);
  --fs-sm: clamp(0.8rem, 1.8vw, 0.9rem);
  --fs-base: clamp(0.9rem, 2.2vw, 1rem);
  --fs-md: clamp(1rem, 2.5vw, 1.125rem);
  --fs-lg: clamp(1.125rem, 3vw, 1.25rem);
  --fs-xl: clamp(1.25rem, 3.5vw, 1.5rem);
  --fs-2xl: clamp(1.5rem, 4vw, 1.875rem);
  --fs-3xl: clamp(1.875rem, 5vw, 2.25rem);
  --fs-4xl: clamp(2.25rem, 6vw, 3rem);
  
  /* Alturas de línea */
  --lh-tight: 1.25;
  --lh-snug: 1.375;
  --lh-normal: 1.5;
  --lh-relaxed: 1.625;
  --lh-loose: 2;
  
  /* Pesos de fuente */
  --fw-light: 300;
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-extrabold: 800;
  
  /* Espaciado de letras */
  --ls-tighter: -0.05em;
  --ls-tight: -0.025em;
  --ls-normal: 0;
  --ls-wide: 0.025em;
  --ls-wider: 0.05em;
  --ls-widest: 0.1em;
}

/* === RESET Y BASE === */
* {
  box-sizing: border-box;
}

html {
  font-size: 16px; /* Base de 16px para rem */
  line-height: var(--lh-normal);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-primary);
  font-size: var(--fs-base);
  font-weight: var(--fw-normal);
  line-height: var(--lh-normal);
  letter-spacing: var(--ls-normal);
  color: #1a202c;
  background-color: #f7fafc;
}

/* === HEADINGS RESPONSIVE === */
h1, .h1 {
  font-size: var(--fs-4xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  margin-bottom: clamp(0.75rem, 3vw, 1.5rem);
}

h2, .h2 {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  margin-bottom: clamp(0.5rem, 2.5vw, 1.25rem);
}

h3, .h3 {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-normal);
  margin-bottom: clamp(0.5rem, 2vw, 1rem);
}

h4, .h4 {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-normal);
  margin-bottom: clamp(0.4rem, 1.8vw, 0.875rem);
}

h5, .h5 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-normal);
  margin-bottom: clamp(0.375rem, 1.5vw, 0.75rem);
}

h6, .h6 {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  line-height: var(--lh-normal);
  letter-spacing: var(--ls-wide);
  margin-bottom: clamp(0.25rem, 1.2vw, 0.625rem);
  text-transform: uppercase;
}

/* === PÁRRAFOS Y TEXTO === */
p {
  font-size: var(--fs-base);
  line-height: var(--lh-relaxed);
  margin-bottom: clamp(0.75rem, 2vw, 1rem);
}

.lead {
  font-size: var(--fs-lg);
  font-weight: var(--fw-normal);
  line-height: var(--lh-relaxed);
}

small, .small {
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
}

.text-xs {
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
}

/* === ENLACES === */
a {
  color: #4c6ef5;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #364fc7;
  text-decoration: underline;
}

a:focus {
  outline: 2px solid #4c6ef5;
  outline-offset: 2px;
  border-radius: 2px;
}

/* === LISTAS === */
ul, ol {
  margin-bottom: clamp(0.75rem, 2vw, 1rem);
  padding-left: clamp(1.25rem, 3vw, 1.5rem);
}

li {
  margin-bottom: clamp(0.25rem, 1vw, 0.5rem);
  line-height: var(--lh-relaxed);
}

/* === CÓDIGO === */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: rgba(0,0,0,0.05);
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  color: #e91e63;
}

pre {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  background-color: #1a202c;
  color: #f7fafc;
  padding: clamp(0.75rem, 2vw, 1rem);
  border-radius: 0.5rem;
  overflow-x: auto;
  margin-bottom: clamp(0.75rem, 2vw, 1rem);
}

/* === UTILIDADES TIPOGRÁFICAS === */
.font-mono {
  font-family: var(--font-mono);
}

.font-secondary {
  font-family: var(--font-secondary);
}

/* Pesos */
.font-light { font-weight: var(--fw-light); }
.font-normal { font-weight: var(--fw-normal); }
.font-medium { font-weight: var(--fw-medium); }
.font-semibold { font-weight: var(--fw-semibold); }
.font-bold { font-weight: var(--fw-bold); }
.font-extrabold { font-weight: var(--fw-extrabold); }

/* Tamaños */
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-base { font-size: var(--fs-base); }
.text-lg { font-size: var(--fs-lg); }
.text-xl { font-size: var(--fs-xl); }
.text-2xl { font-size: var(--fs-2xl); }
.text-3xl { font-size: var(--fs-3xl); }
.text-4xl { font-size: var(--fs-4xl); }

/* Altura de línea */
.leading-tight { line-height: var(--lh-tight); }
.leading-snug { line-height: var(--lh-snug); }
.leading-normal { line-height: var(--lh-normal); }
.leading-relaxed { line-height: var(--lh-relaxed); }
.leading-loose { line-height: var(--lh-loose); }

/* Espaciado de letras */
.tracking-tighter { letter-spacing: var(--ls-tighter); }
.tracking-tight { letter-spacing: var(--ls-tight); }
.tracking-normal { letter-spacing: var(--ls-normal); }
.tracking-wide { letter-spacing: var(--ls-wide); }
.tracking-wider { letter-spacing: var(--ls-wider); }
.tracking-widest { letter-spacing: var(--ls-widest); }

/* === RESPONSIVE BREAKPOINTS === */

/* Tablets pequeñas (hasta 768px) */
@media (max-width: 767.98px) {
  :root {
    --fs-xs: 0.75rem;
    --fs-sm: 0.85rem;
    --fs-base: 0.95rem;
    --fs-md: 1.05rem;
    --fs-lg: 1.15rem;
    --fs-xl: 1.3rem;
    --fs-2xl: 1.6rem;
    --fs-3xl: 2rem;
    --fs-4xl: 2.5rem;
  }
  
  /* Ajustar espaciado en móvil */
  h1, h2, h3, h4, h5, h6 {
    margin-bottom: 0.75rem;
  }
  
  p {
    margin-bottom: 0.875rem;
  }
  
  /* Mejor legibilidad en móvil */
  body {
    line-height: var(--lh-relaxed);
  }
}

/* Móviles muy pequeños (hasta 480px) */
@media (max-width: 479.98px) {
  :root {
    --fs-xs: 0.7rem;
    --fs-sm: 0.8rem;
    --fs-base: 0.9rem;
    --fs-md: 1rem;
    --fs-lg: 1.1rem;
    --fs-xl: 1.2rem;
    --fs-2xl: 1.4rem;
    --fs-3xl: 1.75rem;
    --fs-4xl: 2.25rem;
  }
  
  /* Espaciado más compacto */
  h1, h2, h3, h4, h5, h6 {
    margin-bottom: 0.5rem;
  }
  
  p {
    margin-bottom: 0.75rem;
  }
  
  /* Evitar texto muy pequeño */
  small, .small {
    font-size: 0.8rem;
  }
}

/* Pantallas grandes (escritorio) */
@media (min-width: 1200px) {
  :root {
    --fs-xs: 0.8rem;
    --fs-sm: 0.9rem;
    --fs-base: 1rem;
    --fs-md: 1.125rem;
    --fs-lg: 1.25rem;
    --fs-xl: 1.5rem;
    --fs-2xl: 1.875rem;
    --fs-3xl: 2.25rem;
    --fs-4xl: 3rem;
  }
}

/* === MEJORAR LEGIBILIDAD === */

/* Mejor contraste en modo claro */
body {
  color: #2d3748;
}

/* Modo oscuro */
.dark body {
  color: #e2e8f0;
  background-color: #1a202c;
}

.dark h1, .dark h2, .dark h3, .dark h4, .dark h5, .dark h6 {
  color: #f7fafc;
}

.dark a {
  color: #63b3ed;
}

.dark a:hover {
  color: #90cdf4;
}

.dark code {
  background-color: rgba(255,255,255,0.1);
  color: #f687b3;
}

/* === ACCESIBILIDAD === */

/* Mejores focus states */
:focus {
  outline: 2px solid #4c6ef5;
  outline-offset: 2px;
}

/* Respetar preferencias de movimiento */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* === COMPONENTES ESPECÍFICOS === */

/* Badges mejorados */
.badge {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
}

/* Botones mejorados */
.btn {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
  line-height: var(--lh-normal);
}

.btn-sm {
  font-size: var(--fs-sm);
  padding: 0.375rem 0.75rem;
}

.btn-lg {
  font-size: var(--fs-lg);
  padding: 0.75rem 1.5rem;
}

/* Forms mejorados */
.form-label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  margin-bottom: 0.375rem;
  color: #4a5568;
}

.form-control, .form-select {
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
}

.form-control:focus, .form-select:focus {
  border-color: #4c6ef5;
  box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.1);
}

/* Cards mejoradas */
.card-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  margin-bottom: 0.75rem;
}

.card-text {
  font-size: var(--fs-base);
  line-height: var(--lh-relaxed);
  color: #6b7280;
}

.dark .card-text {
  color: #9ca3af;
}

/* Tables mejoradas */
.table th {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}

.table td {
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
}

/* === UTILIDADES ADICIONALES === */

/* Truncado responsive */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

/* Números monoespacio */
.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

/* === OPTIMIZACIONES DE RENDIMIENTO === */

/* Prevenir reflow en fuentes */
h1, h2, h3, h4, h5, h6 {
  font-feature-settings: "kern" 1;
  text-rendering: optimizeLegibility;
}

/* Mejor renderizado de texto */
p, li, span {
  text-rendering: optimizeSpeed;
}

/* Preload de fuentes críticas */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMa25L7.woff2') format('woff2');
}