/* main.css */

/* Variables globales - conviven ambas paletas */
:root {
  /* Paleta original (verde azulado) */
  --bs-primary-rgb: 159, 208, 159; /* Un tono verde azulado corporativo */
  
  /* Paleta del dashboard (verde oliva) */
  --color-primary: #6B8E23;
  --color-secondary: #556B2F;
} 

/* Estilos base */
html {
  scroll-behavior: smooth;
}

body {
  background-color: #f8f9fa;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  padding-top: 100px; /* Unificado con el segundo bloque */
}

/* ========== ESTILOS DEL HEADER (primer bloque) ========== */
.header {
  background-color: #ffffff;
  margin-bottom: 40px;
}

.topbar {
  padding: 10px 0;
  font-size: 14px;
  background-color: #333;
  color: #fff;
}
.topbar a {
  color: #fff;
  text-decoration: none;
  transition: 0.3s;
}
.topbar a:hover {
  color: rgb(var(--bs-primary-rgb));
}
.topbar .contact-info i {
  color: rgb(var(--bs-primary-rgb));
  line-height: 0;
  margin-right: 5px;
}
.topbar .social-links a {
  color: #fff;
  font-size: 18px;
  display: inline-block;
  line-height: 1px;
  padding-left: 10px;
}
.topbar .social-links a:hover {
  color: rgb(var(--bs-primary-rgb));
}

.logo-img {
  height: 40px;
  width: auto;
  transition: transform 0.3s ease;
}
.logo-img:hover {
  transform: scale(1.05);
}

/* ========== ESTILOS PARA EL MENÚ PRINCIPAL (fondo claro) ========== */
.mis-pestanas .nav-link {
  color: #333;
  background-color: #f8f9fa;
  border: 1px solid transparent;
  border-radius: 0.25rem 0.25rem 0 0;
}
.mis-pestanas .nav-link.active {
  color: #fff;
  background-color: #007bff;
  border-color: #007bff #007bff #fff;
}
.navbar {
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 0.5rem 1rem;
}
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.5rem;
    color: #333333;
}
.navbar-brand:hover { color: #333333; }

.navbar-nav .nav-link {
    color: #333333;
    font-weight: 600;
    padding: 0.5rem 1rem;
    transition: color 0.2s ease;
}
.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus {
    color: rgb(var(--bs-primary-rgb));
    background-color: transparent;
}
.navbar-nav .nav-link.active {
    color: rgb(var(--bs-primary-rgb)) !important;
    background-color: transparent;
}

/* Dropdown nivel 1 */
.navbar-nav .dropdown-menu {
    background-color: #ffffff;
    border: none;
    border-radius: 0.25rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin-top: 0;
    padding: 0.5rem 0;
}
.navbar-nav .dropdown-item {
    color: #333333;
    padding: 0.5rem 1.5rem;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.navbar-nav .dropdown-item:hover,
.navbar-nav .dropdown-item:focus {
    background-color: rgba(var(--bs-primary-rgb), 0.1);
    color: #333333;
}
.navbar-nav .dropdown-divider {
    border-top-color: rgba(0, 0, 0, 0.1);
}

/* ── ELIMINADO: hover en dropdown nivel 1 ─────────────────────
   Causaba que el dropdown se abriese al pasar el ratón,
   impidiendo el control correcto de los submenús nivel 2.
   Bootstrap 5 abre dropdowns solo con click por defecto.
   ──────────────────────────────────────────────────────────── */

/* ── Submenú nivel 2 ───────────────────────────────────────── */
.dropdown-submenu { position: relative; }

.dropdown-submenu > .dropdown-menu {
    display: none;
    position: absolute;
    top: 0;
    left: 100%;
    margin-top: -6px;
    margin-left: 1px;
    border-radius: 0.25rem;
    min-width: 220px;
    box-shadow: 0 4px 8px rgba(0,0,0,.12);
    background-color: #ffffff;
    border: none;
    z-index: 1021;
}
/* Solo visible cuando JS añade .show — NUNCA por hover */
.dropdown-submenu.show > .dropdown-menu { display: block; }

/* Flecha ▶ indicadora */
.dropdown-submenu > .dropdown-toggle::after {
    content: "";
    display: inline-block;
    border-top: .3em solid transparent;
    border-bottom: .3em solid transparent;
    border-left: .3em solid currentColor;
    border-right: 0;
    vertical-align: middle;
    float: right;
    margin-top: 7px;
}

/* Móvil: submenu estático debajo del padre */
@media (max-width: 991px) {
    .dropdown-submenu > .dropdown-menu {
        position: static;
        left: 0;
        margin: 0 0 0 1rem;
        border: none;
        box-shadow: none;
        background: #f8f9fa;
    }
}

/* ── Logo responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
    .logo-img { height: 35px; }
    .navbar-brand span { font-size: 1.1rem !important; }
}
/* ========== ESTILOS DE BOTONES Y COLORES COMUNES ========== */
.btn-primary {
  background-color: rgb(var(--bs-primary-rgb));
  border-color: rgb(var(--bs-primary-rgb));
  /* Las propiedades de padding y hover del segundo bloque se pierden por el gradiente posterior.
     Si quieres conservarlas, cópialas aquí manualmente. */
}
.btn-primary:hover {
  opacity: 0.9;
  background-color: rgb(var(--bs-primary-rgb));
  border-color: rgb(var(--bs-primary-rgb));
}

.text-primary {
  color: rgb(var(--bs-primary-rgb)) !important;
}

/* ========== ESTILOS DE LA LANDING PAGE (primer bloque) ========== */
.hero-section {
  background: 
    linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.5)),
    url('https://aliatar.tser.es/img/aliatar-landing1.png') center center/contain no-repeat;
  background-color: white;
  color: #333;
  padding: 140px 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  position: relative;
}

.hero-section:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 150px;
  background: linear-gradient(to top, rgba(255,255,255,1), transparent);
  z-index: 1;
}

.hero-content {
  position: relative;
  z-index: 2;
}

.hero-section h1 {
  color: #2c6e49;
  font-weight: 800;
  margin-bottom: 25px;
  text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}

.hero-section p {
  color: #222;
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 35px;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
}

.section-icon {
  font-size: 3.5rem;
  color: rgb(var(--bs-primary-rgb));
}

.card-feature {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid #eee;
}
.card-feature:hover {
  transform: translateY(-8px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

/* Calculadora */
.calculator-container {
  max-width: 800px;
  margin: 2rem auto;
  background-color: white;
  padding: 2rem;
  border-radius: 15px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.nav-tabs .nav-link {
  font-weight: 600;
}
.nav-tabs .nav-link.active {
  color: rgb(var(--bs-primary-rgb));
  border-color: rgb(var(--bs-primary-rgb)) rgb(var(--bs-primary-rgb)) #fff;
}

.result-card {
  background-color: #eef7f5;
  border-left: 5px solid rgb(var(--bs-primary-rgb));
}

/* Demo */
.demo-container {
  max-width: 600px;
  margin: 4rem auto;
  background-color: white;
  padding: 2.5rem;
  border-radius: 15px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

/* ========== ESTILOS DEL DASHBOARD (segundo bloque) ========== */
.header-panel {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  padding: 1.5rem 0;
  margin-bottom: 2rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.card {
  border-radius: 12px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.08);
  margin-bottom: 1.5rem;
  transition: transform 0.3s ease;
}
.card:hover {
  transform: translateY(-3px);
}
.card-header {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  font-weight: 600;
  border-radius: 12px 12px 0 0 !important;
  padding: 1rem 1.5rem;
}

.stats-card {
  text-align: center;
  padding: 1.5rem;
  border-radius: 12px;
  background: white;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
}
.stats-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}
.stats-number {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0.5rem 0;
}
.stats-label {
  color: #6c757d;
  font-size: 1.05rem;
}

.badge-frecuencia {
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.85rem;
}
.freq-minuto { background: rgba(220, 53, 69, 0.15); color: #dc3545; border: 1px solid rgba(220, 53, 69, 0.3); }
.freq-hora { background: rgba(255, 193, 7, 0.15); color: #856404; border: 1px solid rgba(255, 193, 7, 0.4); }
.freq-diario { background: rgba(40, 167, 69, 0.15); color: #28a745; border: 1px solid rgba(40, 167, 69, 0.3); }
.freq-semanal { background: rgba(23, 162, 184, 0.15); color: #17a2b8; border: 1px solid rgba(23, 162, 184, 0.3); }

.status-activo {
  background: rgba(40, 167, 69, 0.15);
  color: #28a745;
  border: 1px solid rgba(40, 167, 69, 0.3);
}
.status-inactivo {
  background: rgba(220, 53, 69, 0.15);
  color: #dc3545;
  border: 1px solid rgba(220, 53, 69, 0.3);
}

.json-preview {
  background: #2d2d3a;
  color: #f8f9fa;
  font-family: monospace;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  max-height: 150px;
  overflow: auto;
}

.tipo-color {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.2);
}

/* Botón primary del dashboard (gradiente) - SOBREESCRIBE al anterior */
.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border: none;
  padding: 0.5rem 1.5rem;
}
.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(107, 142, 35, 0.4);
}

.table-responsive {
  margin-top: 1rem;
}

.modal-content {
  border-radius: 16px;
  border: none;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
.modal-header {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  border-radius: 16px 16px 0 0 !important;
}

.json-editor {
  font-family: monospace;
  min-height: 120px;
  resize: vertical;
  background: #2d2d3a;
  color: #f8f9fa;
  border: 1px solid #495057;
}

.frecuencia-help {
  background: rgba(107, 142, 35, 0.05);
  border-left: 3px solid var(--color-primary);
  padding: 1rem;
  border-radius: 0 8px 8px 0;
  margin: 1rem 0;
}

.tipo-icon {
  font-size: 1.2rem;
  margin-right: 8px;
  width: 24px;
  text-align: center;
}

@media (max-width: 767px) {
  .stats-number {
    font-size: 1.8rem;
  }
  .d-md-flex {
    display: block !important;
  }
  .mb-md-0 {
    margin-bottom: 1rem !important;
  }
  .header-panel {
    padding: 1rem 0;
  }
  .stats-card {
    margin-bottom: 1rem;
  }
}

/* ===== Correcciones de contraste WCAG AA (AU-006) ===== */

/* El verde claro #9FD09F no alcanza AA como texto. Texto de marca → verde oscuro */
.text-primary { color: #4d6029 !important; }          /* ~6:1 sobre blanco */

/* Hover de navegación: usar verde oscuro en vez de #9FD09F */
.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus,
.navbar-nav .nav-link.active { color: #4d6029 !important; }

/* Botón primario: oscurecer el gradiente para que el texto blanco pase AA */
.btn-primary {
  background: linear-gradient(135deg, #5E7D1F, #44561f);
  border: none;
  color: #fff;
}

/* Enlaces tipo badge de estado ya usan texto coloreado sobre fondo claro:
   verificar que el verde de éxito sea el de Bootstrap (#198754), no #28a745 claro */
.status-activo { color: #146c43; }   /* sube contraste del texto "Activo" */

/* Flecha ▶ del submenú en la MISMA línea, alineada a la derecha */
.dropdown-submenu > .dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.dropdown-submenu > .dropdown-toggle::after {
    content: "";
    display: inline-block;
    border-top: .3em solid transparent;
    border-bottom: .3em solid transparent;
    border-left: .3em solid currentColor;
    border-right: 0;
    margin-left: .5em;     /* separa la flecha del texto */
    margin-top: 0;         /* anula el desfase vertical anterior */
    float: none;           /* anula el float que la descolgaba */
    flex-shrink: 0;        /* la flecha no se encoge si el texto es largo */
}

/* ===== AU-007: cursor correcto en tarjetas no interactivas ===== */
/* Se mantiene el efecto hover de elevación como recurso visual,
   pero el cursor por defecto deja de sugerir que son clicables.
   Los enlaces/botones internos conservan su propio cursor:pointer. */
.card,
.stats-card,
.card-feature {
  cursor: default;
}

/* ===== AU-012: historial responsive ===== */
@media (max-width: 767px) {
  /* La cabecera de cada conversación pasa de fila a columna */
  #main .card-body > .d-flex.align-items-center.gap-3 {
    flex-wrap: wrap;
    gap: .5rem !important;
  }
  /* Título y preview ocupan todo el ancho, uno debajo de otro */
  #main .card-body .flex-grow-1.min-w-0 {
    flex: 1 1 100%;
    order: 3;
  }
  #main .card-body > .d-flex .flex-shrink-0[style*="max-width:140px"] {
    max-width: 100% !important;
    flex: 1 1 auto;
  }
  /* Los badges se envuelven y se alinean a la izquierda */
  #main .card-body .d-flex.gap-2.flex-wrap {
    justify-content: flex-start !important;
    flex: 1 1 100%;
    order: 4;
  }
  /* Stats: que no se aplasten demasiado en móvil */
  .stats-number { font-size: 1.5rem; }
  .stats-label  { font-size: .85rem; }
}
/* AU-019: botones legibles sobre el fondo verde claro del informe */
.report-container .btn-outline-secondary {
    color: #212529;
    border-color: #6c757d;
}
.report-container .btn-outline-secondary:hover {
    background-color: #495057;
    color: #fff;
}

/* AU-023: legibilidad de la cabecera de card sobre fondo verde (oliva) */
.card-header code {
    color: #ffffff !important;
    background: rgba(255,255,255,.18);
    padding: .1rem .45rem;
    border-radius: .25rem;
}
.card-header .badge.bg-secondary {
    background-color: rgba(255,255,255,.25) !important;
    color: #fff !important;
}