/* ================= VARIABLES GLOBALES ================= */
:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --background: #f3f4f6;
  --text: #111;
  --card: #fff;
  --input-bg: #f9f9f9;
  --border: #d1d5db;
  --footer-bg: #e5e7eb;
  --bg-nav: #f5f5f5;
  --accent: #007bff;
}

/* Modo oscuro */
body.dark {
  --background: #111827;
  --text: #f3f4f6;
  --card: #1f2937;
  --input-bg: #374151;
  --border: #4b5563;
  --footer-bg: #1f2937;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --bg-nav: #222;
  --accent: #4f9fff;
}

/* ================= RESET ================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Roboto, sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ================= HEADER ================= */

header {
  min-height: 60px; /* O la altura que suela tener tu nav */
  background: var(--bg-nav);
}

/* ================= ENLACES ================= */
a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* ================= NAVBAR ================= */
.main-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  background: var(--bg-nav);
  padding: 0.75rem;
  font-weight: bold;
  border-bottom: 1px solid var(--accent);
}
.main-nav a {
  color: var(--text);
  transition: color 0.3s;
}
.main-nav a:hover {
  color: var(--accent);
}

/* ================= DROPDOWN MENU (CORREGIDO) ================= */

/* Contenedor principal con "puente" para evitar cierres accidentales */
.dropdown {
  position: relative;
  display: inline-block;
  /* El padding-bottom crea una zona invisible que une el botón con el menú */
  padding-bottom: 15px; 
  margin-bottom: -15px; 
}

/* Botón "Herramientas" */
.dropbtn {
  background: none;
  border: none;
  color: var(--text);
  padding: 0;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.3s ease;
}

.dropdown:hover .dropbtn {
  color: var(--primary);
}

/* Caja desplegable con transición suave */
.dropdown-content {
  position: absolute;
  background-color: var(--card);
  min-width: 200px;
  box-shadow: 0px 8px 25px rgba(0,0,0,0.2);
  border-radius: 12px;
  border: 1px solid var(--border);
  z-index: 1001;
  
  /* Posicionamiento */
  top: 100%; 
  left: 50%;
  
  /* Efecto de aparición suave */
  visibility: hidden;
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  
  overflow: hidden;
}

/* Mostramos el menú al hacer hover en el contenedor padre */
.dropdown:hover .dropdown-content {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* EL PUENTE INVISIBLE: Evita que el menú se cierre al bajar el ratón */
.dropdown-content::before {
  content: "";
  position: absolute;
  top: -20px; /* Cubre el hueco entre el botón y el menú */
  left: 0;
  right: 0;
  height: 20px;
  background: transparent;
}

/* Enlaces dentro del menú */
.dropdown-content a {
  color: var(--text) !important;
  padding: 14px 18px;
  text-decoration: none;
  display: block;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease, color 0.2s ease;
}

.dropdown-content a:last-child {
  border-bottom: none;
}

.dropdown-content a:hover {
  background-color: var(--input-bg);
  color: var(--primary) !important;
  text-decoration: none !important;
  padding-left: 22px; /* Pequeño efecto de desplazamiento al pasar el ratón */
}

/* Adaptación para móviles (menú más grande para dedos) */
@media (max-width: 480px) {
  .dropdown-content {
    position: fixed;
    left: 15px;
    right: 15px;
    top: 70px;
    transform: none;
    width: auto;
  }
  
  .dropdown:hover .dropdown-content {
    transform: none;
  }
}

/* ================= MAIN ================= */
main {
  flex: 1;
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* ================= HEADINGS ================= */
h1, h2, h3, h4 {
  margin-bottom: 0.5rem;
  color: var(--text);
}

/* ================= CARDS ================= */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* ================= FORMULARIOS ================= */
.field {
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  width: 100%;
  background: var(--input-bg);
  color: var(--text);
  transition: border 0.2s ease;
}
.field:focus {
  border-color: var(--primary);
  outline: none;
}
 
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

button.btn {
  padding: 0.7rem;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}
button.btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* ================= RESULTADOS ================= */
.result {
  margin-top: 1rem;
  font-weight: 600;
  text-align: center;
  color: var(--primary);
}

/* ================= BARRAS VISUALES Y FORMULAS REPRESENTATIVAS================= */
.imc-bar{
  position: relative;
  height: 12px;
  border-radius: 999px;
  margin-top: 1rem;
  background: linear-gradient(
    90deg,
    #60a5fa 0%,
    #34d399 40%,
    #facc15 70%,
    #f87171 100%
  );
  overflow: hidden;
}
.imc-indicator{
  position: absolute;
  top: -4px;
  width: 4px;
  height: 20px;
  background: black;
  border-radius: 2px;
  left: 0%;
  transition: left 0.4s ease;
}
body.dark .imc-indicator,
body.dark .percent-indicator {
  background: white;
}

.formule{
  text-align: center; 
  margin: 15px 0; 
  font-weight: bold; 
  background: var(--input-bg); 
  padding: 10px; 
  border-radius: 8px;
}
/* ================= GRID (landing + tarjetas) ================= */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card-link:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.08);
}
.card.muted {
  opacity: 0.6;
  pointer-events: none;
}

/* ================= FOOTER ================= */
footer {
  background: var(--footer-bg);
  padding: 1rem 0;
  text-align: center;
  font-size: 0.85rem;
}


/* ================= BANNER COOKIES REFINADO ================= */
.cookie-banner {
  display: none; /* Se activa por JS */
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  max-width: 450px;
  margin: 0 auto;
  background: var(--card);
  padding: 1.5rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  flex-direction: column; /* Cambiado a columna para mejor lectura */
  gap: 1rem;
  z-index: 9999;
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.cookie-main-view p {
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.cookie-buttons {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.cookie-banner button {
  flex: 1; /* Botones de igual tamaño */
  padding: 0.6rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.2s;
}

/* Usamos tus variables de color existentes */
.cookie-banner button.accept-cookies {
  background: var(--primary);
  color: white;
}

.cookie-banner button.settings-cookies {
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.cookie-banner button:hover {
  filter: brightness(0.9);
}

/* Estilo para los checkboxes de configuración */
.cookie-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  background: var(--input-bg);
  border-radius: 8px;
  margin-bottom: 5px;
}

.cookie-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* ================= DARK MODE TOGGLE ================= */
/* ================= MODO OSCURO INTEGRADO ================= */
.toggle-dark-inline {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-dark-inline:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* En móviles, nos aseguramos de que no se vea gigante */
@media (max-width: 480px) {
  .main-nav {
      justify-content: space-between; /* Separa los elementos */
      padding: 0.5rem 1rem;
  }
  .toggle-dark-inline {
      padding: 0.4rem;
  }
}

/* ================= LEGALES ================= */
.legal-content {
  margin: 20px auto;
  max-width: 900px;
  padding: 25px;
  line-height: 1.7;
  color: var(--text);
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 6px 15px rgba(0,0,0,0.05);
}
.legal-content h2,
.legal-content h3,
.legal-content h4 {
  margin-top: 25px;
  margin-bottom: 10px;
  color: var(--text);
}
.legal-content p, .legal-content li {
  margin-bottom: 12px;
}
.legal-content ul {
  padding-left: 20px;
  margin-bottom: 15px;
}
.legal-content a {
  color: var(--primary);
  text-decoration: underline;
}
.legal-content a:hover {
  text-decoration: none;
}
/* Estilos para páginas legales */
.legal-container {
  max-width: 900px;
  margin: 2rem auto;
  padding: 3rem;
  line-height: 1.6;
  text-align: left;
}

.legal-header {
  border-bottom: 2px solid var(--border);
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  text-align: center;
}

.legal-body h3 {
  margin-top: 2rem;
  color: var(--primary);
}

.legal-body h4 {
  margin-top: 1.5rem;
  text-decoration: underline;
}

.legal-date {
  margin-top: 3rem;
  font-size: 0.85rem;
  color: var(--text-light);
  font-style: italic;
}


/* ================= VALIDACIÓN Y ESTADOS ================= */

/* Resaltado del campo con error */
.field.error {
  border-color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.05);
}

/* Contenedor de mensajes (Debajo del formulario de contacto) */
.form-status {
  min-height: 1.5rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  border-radius: 8px;
  transition: all 0.3s ease;
}

/* Colores de los mensajes de estado */
.error-text {
  color: #ef4444;
}

.success-text {
  color: #10b981;
}

/* Pequeño ajuste para que los placeholders se vean bien en modo oscuro */
body.dark .field::placeholder {
  color: #9ca3af;
}

/* ================= RESPONSIVE ================= */
@media(max-width:480px){
  main {padding:0 1rem;}
  h1{font-size:1.8rem;}
  h2{font-size:1.4rem;}
  .hero-actions, .grid {justify-content:center;}
}
