/**
 * Sitio público (/, /login/): modo claro/oscuro alineado al admin (theme.js + localStorage).
 * Variables base en `html` (no en :root inline de las plantillas) para que
 * html[data-theme="dark"] gane en cascada y no quede texto oscuro sobre fondo oscuro.
 */

@import url("egg-brand-theme.css");

html {
  --egg-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --egg-ink: #0b1220;
  --egg-muted: #5b6475;
  --egg-surface: rgba(255, 255, 255, 0.8);
  --egg-border: rgba(15, 23, 42, 0.12);
  --egg-shadow: 0 18px 55px rgba(2, 6, 23, 0.14);
  --header-link-color: #0b1220;
  --header-bg: #ffffff;
}

html[data-theme="light"] {
  --egg-ink: #0b1220;
  --egg-muted: #5b6475;
  --egg-surface: rgba(255, 255, 255, 0.8);
  --egg-border: rgba(15, 23, 42, 0.12);
  --egg-shadow: 0 18px 55px rgba(2, 6, 23, 0.14);
  --header-link-color: #0b1220;
  --header-bg: #ffffff;
}

html[data-theme="dark"] {
  --egg-ink: #e8eaed;
  --egg-muted: #a8b4c8;
  --egg-surface: rgba(30, 41, 59, 0.58);
  --egg-border: rgba(255, 255, 255, 0.14);
  --egg-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --header-link-color: #e8eaed;
  --header-bg: #121212;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --egg-ink: #e8eaed;
    --egg-muted: #a8b4c8;
    --egg-surface: rgba(30, 41, 59, 0.58);
    --egg-border: rgba(255, 255, 255, 0.14);
    --egg-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    --header-link-color: #e8eaed;
    --header-bg: #121212;
  }
}

html[data-theme="dark"] body:not(.egg-login-page) {
  background: var(--body-bg, #121212) !important;
  color: var(--body-fg, #eeeeee) !important;
  background-image: none !important;
}

/* En modo oscuro, .text-muted debe cambiar color, no pintar un bloque */
html[data-theme="dark"] body .text-muted {
  color: var(--egg-muted, #a8b4c8) !important;
  background: transparent !important;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] body:not(.egg-login-page) {
    background: var(--body-bg, #121212) !important;
    color: var(--body-fg, #eeeeee) !important;
    background-image: none !important;
  }

  html[data-theme="auto"] body .text-muted {
    color: var(--egg-muted, #a8b4c8) !important;
    background: transparent !important;
  }
}

html[data-theme="dark"] .egg-title,
html[data-theme="dark"] .egg-sub,
html[data-theme="dark"] .egg-subtitle {
  color: var(--egg-ink);
}

html[data-theme="dark"] .egg-eyebrow {
  color: #a5b4fc;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .egg-title,
  html[data-theme="auto"] .egg-sub,
  html[data-theme="auto"] .egg-subtitle {
    color: var(--egg-ink);
  }

  html[data-theme="auto"] .egg-eyebrow {
    color: #a5b4fc;
  }
}

html[data-theme="dark"] .egg-card:not(.egg-login-card),
html[data-theme="dark"] .egg-hero {
  background: var(--egg-surface) !important;
  border-color: var(--egg-border) !important;
  box-shadow: var(--egg-shadow) !important;
  backdrop-filter: blur(16px) saturate(1.05);
  -webkit-backdrop-filter: blur(16px) saturate(1.05);
}

html[data-theme="dark"] .egg-feature {
  background: rgba(15, 23, 42, 0.75) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

html[data-theme="dark"] .egg-feature h3 {
  color: var(--egg-ink);
}

html[data-theme="dark"] .egg-feature .icon {
  background: color-mix(in srgb, var(--accent, #6366f1) 22%, #1e293b) !important;
  border-color: color-mix(in srgb, var(--accent, #6366f1) 40%, transparent) !important;
}

html[data-theme="dark"] .egg-contact-bar {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(14, 165, 233, 0.1)) !important;
  border-color: rgba(99, 102, 241, 0.25) !important;
}

html[data-theme="dark"] .egg-footer {
  color: var(--egg-muted) !important;
  border-top-color: var(--egg-border) !important;
}

html[data-theme="dark"] .egg-footer strong {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .egg-chip {
  background: rgba(99, 102, 241, 0.12) !important;
  border-color: rgba(165, 180, 252, 0.35) !important;
  color: #c7d2fe !important;
}

html[data-theme="dark"] .btn-ghost {
  border-color: rgba(165, 180, 252, 0.45) !important;
  color: #c7d2fe !important;
}

html[data-theme="dark"] .btn-ghost:hover {
  background: rgba(99, 102, 241, 0.15) !important;
  border-color: rgba(199, 210, 254, 0.55) !important;
  color: #e0e7ff !important;
}

html[data-theme="dark"] .egg-logo {
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.35));
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .egg-card:not(.egg-login-card),
  html[data-theme="auto"] .egg-hero {
    background: var(--egg-surface) !important;
    border-color: var(--egg-border) !important;
    box-shadow: var(--egg-shadow) !important;
    backdrop-filter: blur(16px) saturate(1.05);
    -webkit-backdrop-filter: blur(16px) saturate(1.05);
  }

  html[data-theme="auto"] .egg-feature {
    background: rgba(15, 23, 42, 0.75) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
  }

  html[data-theme="auto"] .egg-feature h3 {
    color: var(--egg-ink);
  }

  html[data-theme="auto"] .egg-feature .icon {
    background: color-mix(in srgb, var(--accent, #6366f1) 22%, #1e293b) !important;
    border-color: color-mix(in srgb, var(--accent, #6366f1) 40%, transparent) !important;
  }

  html[data-theme="auto"] .egg-contact-bar {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(14, 165, 233, 0.1)) !important;
    border-color: rgba(99, 102, 241, 0.25) !important;
  }

  html[data-theme="auto"] .egg-footer {
    color: var(--egg-muted) !important;
    border-top-color: var(--egg-border) !important;
  }

  html[data-theme="auto"] .egg-footer strong {
    color: #cbd5e1 !important;
  }

  html[data-theme="auto"] .egg-chip {
    background: rgba(99, 102, 241, 0.12) !important;
    border-color: rgba(165, 180, 252, 0.35) !important;
    color: #c7d2fe !important;
  }

  html[data-theme="auto"] .btn-ghost {
    border-color: rgba(165, 180, 252, 0.45) !important;
    color: #c7d2fe !important;
  }

  html[data-theme="auto"] .btn-ghost:hover {
    background: rgba(99, 102, 241, 0.15) !important;
    border-color: rgba(199, 210, 254, 0.55) !important;
    color: #e0e7ff !important;
  }

  html[data-theme="auto"] .egg-logo {
    filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.35));
  }
}

/* Login: alerta (la tarjeta login se estiliza en login.html: vidrio + línea marca) */
html[data-theme="dark"] .egg-alert {
  border-color: rgba(248, 113, 113, 0.35) !important;
  background: rgba(127, 29, 29, 0.35) !important;
  color: #fecaca !important;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .egg-alert {
    border-color: rgba(248, 113, 113, 0.35) !important;
    background: rgba(127, 29, 29, 0.35) !important;
    color: #fecaca !important;
  }
}

/* Barra oscura home: iconos del toggle en blanco */
.egg-nav .theme-toggle {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  padding: 0.35rem 0.45rem;
}

.egg-nav .theme-toggle svg.theme-icon-when-auto,
.egg-nav .theme-toggle svg.theme-icon-when-dark,
.egg-nav .theme-toggle svg.theme-icon-when-light {
  fill: rgba(255, 255, 255, 0.92) !important;
  color: transparent;
}

/* Login: toggle flotante (fondo claro u oscuro según tema) */
.egg-login-theme-bar .theme-toggle {
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.85);
  padding: 0.4rem 0.5rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.egg-login-theme-bar .theme-toggle svg.theme-icon-when-auto,
.egg-login-theme-bar .theme-toggle svg.theme-icon-when-dark,
.egg-login-theme-bar .theme-toggle svg.theme-icon-when-light {
  fill: rgba(15, 23, 42, 0.85) !important;
}

html[data-theme="dark"] .egg-login-theme-bar .theme-toggle {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(30, 41, 59, 0.95);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .egg-login-theme-bar .theme-toggle svg.theme-icon-when-auto,
html[data-theme="dark"] .egg-login-theme-bar .theme-toggle svg.theme-icon-when-dark,
html[data-theme="dark"] .egg-login-theme-bar .theme-toggle svg.theme-icon-when-light {
  fill: rgba(255, 255, 255, 0.92) !important;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .egg-login-theme-bar .theme-toggle {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(30, 41, 59, 0.95);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }

  html[data-theme="auto"] .egg-login-theme-bar .theme-toggle svg.theme-icon-when-auto,
  html[data-theme="auto"] .egg-login-theme-bar .theme-toggle svg.theme-icon-when-dark,
  html[data-theme="auto"] .egg-login-theme-bar .theme-toggle svg.theme-icon-when-light {
    fill: rgba(255, 255, 255, 0.92) !important;
  }
}

/* Bootstrap con data-bs-theme oscuro */
html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select {
  background-color: #1e293b;
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--egg-ink, #e8eaed);
}

html[data-bs-theme="dark"] .form-label {
  color: var(--egg-ink, #e8eaed);
}

html[data-bs-theme="dark"] .btn-outline-secondary {
  --bs-btn-color: #cbd5e1;
  --bs-btn-border-color: rgba(255, 255, 255, 0.28);
  --bs-btn-hover-bg: rgba(255, 255, 255, 0.08);
  --bs-btn-hover-border-color: rgba(255, 255, 255, 0.4);
  --bs-btn-hover-color: #fff;
}

html[data-bs-theme="dark"] .btn-outline-primary.btn-ghost {
  --bs-btn-color: #a5b4fc;
  --bs-btn-border-color: rgba(165, 180, 252, 0.45);
}

html[data-bs-theme="dark"] .link-primary {
  color: #93c5fd !important;
}

html[data-bs-theme="dark"] .text-body {
  color: var(--body-fg, #eee) !important;
}
