/* ─────────────────────────────────────────────────────────────── */
/* Nestra — base.css: Variables, Reset, Tipografía, Temas         */
/* ─────────────────────────────────────────────────────────────── */

:root {
  /* Colores — tema claro (default)
     Paleta fintech: esmeralda primario, grises neutros                */
  --color-primary: #059669;      /* esmeralda-600 — acciones, links   */
  --color-secondary: #6b7280;    /* gris-500 — accento neutro          */
  --color-danger: #ef4444;       /* rojo-500                           */
  --color-warning: #f59e0b;      /* ámbar-500                          */
  --color-success: #10b981;      /* esmeralda-500 — valores positivos  */

  --bg-light: #ffffff;
  --bg-light-secondary: #f9fafb;
  --text-dark: #1f2937;
  --text-secondary: #6b7280;
  --border-light: #e5e7eb;

  /* Tipografía */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 0.75rem;      /* 12px */
  --font-size-sm: 0.875rem;     /* 14px */
  --font-size-base: 1rem;       /* 16px */
  --font-size-lg: 1.125rem;     /* 18px */
  --font-size-xl: 1.25rem;      /* 20px */
  --font-size-2xl: 1.5rem;      /* 24px */

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Espaciado */
  --space-xs: 0.25rem;   /* 4px */
  --space-sm: 0.5rem;    /* 8px */
  --space-md: 1rem;      /* 16px */
  --space-lg: 1.5rem;    /* 24px */
  --space-xl: 2rem;      /* 32px */

  /* Sombras */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

  /* Radio */
  --radius-sm: 0.375rem;   /* 6px */
  --radius-md: 0.5rem;     /* 8px */
  --radius-lg: 0.75rem;    /* 12px */
}

/* Tema oscuro */
html.dark {
  --bg-light: #1f2937;
  --bg-light-secondary: #111827;
  --text-dark: #f9fafb;
  --text-secondary: #d1d5db;
  --border-light: #374151;
  --color-primary: #34d399;      /* esmeralda-400 — contraste en fondo oscuro */
  --color-secondary: #9ca3af;    /* gris-400                                   */
  --color-success: #34d399;      /* esmeralda-400                              */
  --color-danger: #f87171;       /* rojo-400 — más claro para contraste WCAG   */
  --color-warning: #fbbf24;      /* ámbar-400                                  */
}

/* Respetar preferencia OS */
@media (prefers-color-scheme: dark) {
  html:not(.light) {
    --bg-light: #1f2937;
    --bg-light-secondary: #111827;
    --text-dark: #f9fafb;
    --text-secondary: #d1d5db;
    --border-light: #374151;
    --color-primary: #34d399;
    --color-secondary: #9ca3af;
    --color-success: #34d399;
    --color-danger: #f87171;
    --color-warning: #fbbf24;
  }
}

/* ─────────────────────────────────────────────────────────────── */
/* Reset */
/* ─────────────────────────────────────────────────────────────── */

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

html {
  font-family: var(--font-family);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-light);
  color: var(--text-dark);
  line-height: 1.5;
  transition: background-color 0.2s, color 0.2s;
}

/* ─────────────────────────────────────────────────────────────── */
/* Tipografía */
/* ─────────────────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-bold);
  line-height: 1.25;
}

h1 {
  font-size: var(--font-size-2xl);
}

h2 {
  font-size: var(--font-size-xl);
}

h3 {
  font-size: var(--font-size-lg);
}

p {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  font-size: var(--font-size-base);
}

input, textarea, select {
  font-family: inherit;
  font-size: var(--font-size-base);
}

/* iOS auto-zoom prevention: any input < 16px triggers zoom on focus.
   .input uses --font-size-sm (14px). Force 16px on iOS only. */
@supports (-webkit-touch-callout: none) {
  input, textarea, select, .input {
    font-size: 1rem !important;
  }
}

/* ─────────────────────────────────────────────────────────────── */
/* Utility Classes */
/* ─────────────────────────────────────────────────────────────── */

.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;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.text-center {
  text-align: center;
}

.text-xs {
  font-size: var(--font-size-xs);
}

.text-sm {
  font-size: var(--font-size-sm);
}

/* ─────────────────────────────────────────────────────────────── */
/* Semantic Color Utilities                                         */
/* ─────────────────────────────────────────────────────────────── */

.text-muted {
  color: var(--text-secondary);
}

.text-success {
  color: var(--color-success);
}

.text-danger {
  color: var(--color-danger);
}

/* ─────────────────────────────────────────────────────────────── */
/* Badge Utilities                                                  */
/* ─────────────────────────────────────────────────────────────── */

.badge-warning,
.badge-danger {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  line-height: 1.5;
  white-space: nowrap;
}

.badge-warning {
  background-color: #fef3c7;
  color: #92400e;
}

.badge-danger {
  background-color: #fee2e2;
  color: #991b1b;
}

/* Dark mode badge overrides — manual .dark class */
html.dark .badge-warning {
  background-color: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

html.dark .badge-danger {
  background-color: rgba(248, 113, 113, 0.15);
  color: #f87171;
}

/* Dark mode badge overrides — OS preference */
@media (prefers-color-scheme: dark) {
  html:not(.light) .badge-warning {
    background-color: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
  }

  html:not(.light) .badge-danger {
    background-color: rgba(248, 113, 113, 0.15);
    color: #f87171;
  }
}
