/* =============================================================
   DPROMA Dashboard — Estilos globales, variables CSS y reset
   © DPROMA. Todos los derechos reservados.
   ============================================================= */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables de color DPROMA ── */
:root {
  --green:       #1f7938;
  --green-lt:    #e8f5ec;
  --green-dk:    #155c2b;
  --blue:        #1f7890;
  --blue-lt:     #e6f4f8;
  --gold:        #c99a29;
  --gold-lt:     #fdf4dc;
  --red:         #c0392b;
  --red-lt:      #fdecea;
  --orange:      #d97706;

  /* Superficies (tema oscuro por defecto) */
  --bg-app:      #141d1a;
  --bg-surface:  #1a2420;
  --bg-card:     #1e2e28;
  --bg-elevated: #243328;
  --bg-hover:    #2c3e32;

  /* Bordes */
  --border:      #2c3e32;
  --border-lt:   #3a4e40;

  /* Texto */
  --text:        #e2f0e6;
  --text-muted:  #7a9e86;
  --text-faint:  #4a6654;

  /* Semánticos */
  --success:     var(--green);
  --success-bg:  #1a3022;
  --error:       var(--red);
  --error-bg:    #3a1a18;
  --warn:        var(--gold);
  --warn-bg:     #3a2e10;
  --info:        var(--blue);
  --info-bg:     #1a2e38;

  /* Tipografía */
  --font:        'Inter', system-ui, sans-serif;
  --text-xs:     0.75rem;
  --text-sm:     0.875rem;
  --text-base:   1rem;
  --text-lg:     1.125rem;
  --text-xl:     1.25rem;
  --text-2xl:    1.5rem;

  /* Espaciado */
  --radius-sm:   0.375rem;
  --radius:      0.5rem;
  --radius-lg:   0.75rem;
  --radius-xl:   1rem;

  /* Sombras */
  --shadow-sm:   0 1px 3px rgba(0,0,0,.4);
  --shadow:      0 4px 12px rgba(0,0,0,.5);
  --shadow-lg:   0 8px 24px rgba(0,0,0,.6);

  /* Transiciones */
  --transition:  150ms ease;
  --transition-md: 250ms ease;
}

/* Tema claro */
html:not(.dark) {
  --bg-app:      #f0f5f2;
  --bg-surface:  #f8faf9;
  --bg-card:     #ffffff;
  --bg-elevated: #f4f8f5;
  --bg-hover:    #e8f0ea;
  --border:      #d0e0d5;
  --border-lt:   #e0ece4;
  --text:        #1a2e24;
  --text-muted:  #4a7060;
  --text-faint:  #8ab09a;
  --success-bg:  #e8f5ec;
  --error-bg:    #fdecea;
  --warn-bg:     #fdf4dc;
  --info-bg:     #e6f4f8;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font: inherit; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea { font: inherit; }
ul, ol { list-style: none; }

/* ── Scrollbar personalizado ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border-lt); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Animaciones ── */
@keyframes fadeIn    { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp   { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin      { to { transform: rotate(360deg); } }
@keyframes progressFill { from { width: 0; } to { width: 100%; } }
@keyframes pulse     { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* ── Splash Screen ── */
.splash-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-app);
  display: flex; align-items: center; justify-content: center;
  transition: opacity var(--transition-md);
}
.splash-screen.hiding { opacity: 0; pointer-events: none; }
.splash-content { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1.5rem; }
.splash-logo { width: 160px; height: auto; animation: fadeIn .6s ease; }

/* ── Logo adaptable al tema ──
   El HTML carga por defecto el logo para modo oscuro (transparente, texto blanco).
   En modo claro se sustituye por la variante con texto oscuro. */
html:not(.dark) .splash-logo,
html:not(.dark) .login-logo,
html:not(.dark) .rail-logo {
  content: url('/assets/dproma-logo-light-transparent.png');
}
.splash-progress-bar {
  width: 240px; height: 4px;
  background: var(--border);
  border-radius: 2px; overflow: hidden;
}
.splash-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  animation: progressFill 1.8s ease-in-out forwards;
}
.splash-message { font-size: var(--text-sm); color: var(--text-muted); animation: pulse 1.5s ease infinite; }

/* ── Login ── */
.login-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg-app);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fadeIn .3s ease;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  animation: slideUp .3s ease;
}
.login-header { text-align: center; margin-bottom: 1.75rem; }
.login-logo { width: 100px; margin: 0 auto 1rem; }
.login-title { font-size: var(--text-xl); font-weight: 700; color: var(--text); }
.login-subtitle { font-size: var(--text-sm); color: var(--text-muted); margin-top: .25rem; }
.login-footer { text-align: center; margin-top: 1.5rem; font-size: var(--text-xs); color: var(--text-faint); }
.recover-hint { font-size: var(--text-sm); color: var(--text-muted); margin-bottom: 1rem; line-height: 1.5; }

/* ── Formularios ── */
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.field-group { display: flex; flex-direction: column; gap: .375rem; }
.field-label { font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); }
.field-input {
  width: 100%; padding: .625rem .875rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--text-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.field-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,121,56,.2); }
.field-input::placeholder { color: var(--text-faint); }
.field-input[aria-invalid="true"] { border-color: var(--red); }
.field-password-wrap { position: relative; }
.field-password-wrap .field-input { padding-right: 2.75rem; }
.btn-password-toggle {
  position: absolute; right: .625rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted); padding: .25rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.btn-password-toggle:hover { color: var(--text); }

/* ── Botones ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .625rem 1.25rem;
  border-radius: var(--radius);
  font-size: var(--text-sm); font-weight: 500;
  border: 1px solid transparent;
  transition: background var(--transition), opacity var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green-dk); }
.btn-primary:hover:not(:disabled) { background: var(--green-dk); box-shadow: 0 2px 8px rgba(31,121,56,.4); }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a93226; }
.btn-full { width: 100%; }
.btn-icon {
  background: none; border: none;
  color: var(--text-muted); padding: .5rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover { color: var(--text); background: var(--bg-hover); }
.btn-link {
  background: none; border: none;
  color: var(--green); font-size: var(--text-sm);
  text-align: center; padding: .25rem;
  transition: opacity var(--transition);
}
.btn-link:hover { opacity: .8; text-decoration: underline; }
.btn-loader {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Alertas ── */
.alert {
  padding: .625rem .875rem;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.alert-error   { background: var(--error-bg);   color: #f87171; border: 1px solid rgba(192,57,43,.4); }
.alert-success { background: var(--success-bg);  color: #4ade80; border: 1px solid rgba(31,121,56,.4); }
.alert-warn    { background: var(--warn-bg);     color: #fbbf24; border: 1px solid rgba(201,154,41,.4); }
.alert-info    { background: var(--info-bg);     color: #60a5fa; border: 1px solid rgba(31,120,144,.4); }

/* ── Spinner ── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* ── Utilidades ── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-gold  { color: var(--gold); }
