/* =====================================================================
   PLATAFORMA DE DASHBOARDS ERP — Identidad visual sobre Bootstrap 5.3
   Paleta
     --eo-tinta      #16212C  texto principal
     --eo-petroleo   #0B5563  color de marca / acciones principales
     --eo-niebla     #E6EFF1  fondos suaves de marca
     --eo-superficie #F4F6F7  fondo de la aplicación
     --eo-linea      #D9E1E4  bordes
     --eo-ambar      #9A6412  avisos de prueba / vencimientos
   Tipografía: IBM Plex Sans (cifras tabulares para dashboards)
   ===================================================================== */

:root {
  --eo-tinta: #16212C;
  --eo-tinta-suave: #4A5866;
  --eo-petroleo: #0B5563;
  --eo-petroleo-oscuro: #083F4A;
  --eo-niebla: #E6EFF1;
  --eo-superficie: #F4F6F7;
  --eo-linea: #D9E1E4;
  --eo-ambar: #9A6412;
  --eo-ambar-fondo: #FBF1DF;

  --bs-body-font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: var(--eo-tinta);
  --bs-body-bg: var(--eo-superficie);
  --bs-border-color: var(--eo-linea);
  --bs-primary: var(--eo-petroleo);
  --bs-primary-rgb: 11, 85, 99;
  --bs-link-color: var(--eo-petroleo);
  --bs-link-color-rgb: 11, 85, 99;
  --bs-link-hover-color: var(--eo-petroleo-oscuro);
  --bs-link-hover-color-rgb: 8, 63, 74;
  --bs-border-radius: .5rem;
  --bs-focus-ring-color: rgba(11, 85, 99, .3);
}

body { font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .h1, .h2, .h3 { letter-spacing: -.01em; font-weight: 600; }

.btn-primary {
  --bs-btn-bg: var(--eo-petroleo);
  --bs-btn-border-color: var(--eo-petroleo);
  --bs-btn-hover-bg: var(--eo-petroleo-oscuro);
  --bs-btn-hover-border-color: var(--eo-petroleo-oscuro);
  --bs-btn-active-bg: var(--eo-petroleo-oscuro);
  --bs-btn-active-border-color: var(--eo-petroleo-oscuro);
  --bs-btn-disabled-bg: var(--eo-petroleo);
  --bs-btn-disabled-border-color: var(--eo-petroleo);
  font-weight: 500;
}
.btn-outline-primary {
  --bs-btn-color: var(--eo-petroleo);
  --bs-btn-border-color: var(--eo-petroleo);
  --bs-btn-hover-bg: var(--eo-petroleo);
  --bs-btn-hover-border-color: var(--eo-petroleo);
  --bs-btn-active-bg: var(--eo-petroleo-oscuro);
}
.form-control, .form-select { border-color: var(--eo-linea); padding: .6rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--eo-petroleo); box-shadow: 0 0 0 .2rem rgba(11,85,99,.18); }
.form-label { font-weight: 500; font-size: .925rem; margin-bottom: .35rem; }
.form-text { color: var(--eo-tinta-suave); }
:focus-visible { outline: 2px solid var(--eo-petroleo); outline-offset: 2px; }

/* ---------- Pantallas de acceso (login, registro...) ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: #fff; }
@media (min-width: 992px) { .auth { grid-template-columns: minmax(420px, 5fr) 7fr; } }
.auth-panel {
  display: none;
  background: var(--eo-petroleo-oscuro);
  color: #EAF3F4;
  padding: 3rem 3.5rem;
  flex-direction: column;
  justify-content: space-between;
}
@media (min-width: 992px) { .auth-panel { display: flex; } }
.auth-panel .marca { color: #fff; }
.auth-panel h2 { font-size: 1.9rem; line-height: 1.2; max-width: 20ch; font-weight: 500; color: #fff; }
.auth-panel p { color: #B9D2D6; max-width: 38ch; }
.auth-grafico { width: 100%; max-width: 440px; height: auto; margin: 2rem 0; }
.auth-grafico .serie {
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
  animation: dibujar 1.6s .2s cubic-bezier(.3,.7,.2,1) forwards;
}
.auth-grafico .barra { transform-origin: bottom; transform-box: fill-box; animation: crecer .9s cubic-bezier(.3,.7,.2,1) both; }
@keyframes dibujar { to { stroke-dashoffset: 0; } }
@keyframes crecer { from { transform: scaleY(0); } }
@media (prefers-reduced-motion: reduce) {
  .auth-grafico .serie, .auth-grafico .barra { animation: none; stroke-dashoffset: 0; }
}

.auth-form { display: flex; flex-direction: column; justify-content: center; padding: 2.5rem 1.25rem; }
.auth-form-inner { width: 100%; max-width: 420px; margin: 0 auto; }
.auth-form h1 { font-size: 1.6rem; margin-bottom: .35rem; }
.auth-form .lead-sm { color: var(--eo-tinta-suave); margin-bottom: 1.75rem; }

.marca { display: inline-flex; align-items: center; gap: .55rem; font-weight: 600; font-size: 1.1rem; text-decoration: none; color: var(--eo-tinta); }
.marca-simbolo { width: 28px; height: 28px; flex: none; }

/* ---------- Aplicación ---------- */
.app { display: flex; min-height: 100vh; }
.app-sidebar { width: 256px; background: #fff; border-right: 1px solid var(--eo-linea); }
@media (min-width: 992px) { .app-sidebar { position: sticky; top: 0; height: 100vh; flex: none; } }
.app-sidebar .offcanvas-body { display: flex; flex-direction: column; padding: 1.25rem 1rem; }
.nav-app .nav-link {
  display: flex; align-items: center; gap: .7rem;
  color: var(--eo-tinta-suave);
  padding: .55rem .75rem; border-radius: .45rem; font-weight: 500;
}
.nav-app .nav-link i { font-size: 1.05rem; }
.nav-app .nav-link:hover { background: var(--eo-superficie); color: var(--eo-tinta); }
.nav-app .nav-link.active { background: var(--eo-niebla); color: var(--eo-petroleo-oscuro); }
.nav-app .nav-link.disabled { opacity: .55; }
.nav-app .pronto { margin-left: auto; font-size: .7rem; font-weight: 500; color: var(--eo-tinta-suave); }
.nav-grupo { font-size: .78rem; color: var(--eo-tinta-suave); margin: 1.25rem .75rem .35rem; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1.25rem; background: #fff; border-bottom: 1px solid var(--eo-linea);
  position: sticky; top: 0; z-index: 1010;
}
.app-topbar h1 { font-size: 1.15rem; margin: 0; }
.app-content { padding: 1.5rem 1.25rem 3rem; }
@media (min-width: 992px) { .app-content { padding: 2rem 2.25rem 3rem; } }

.pill-prueba {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--eo-ambar-fondo); color: var(--eo-ambar);
  border-radius: 999px; padding: .3rem .75rem; font-size: .85rem; font-weight: 500; text-decoration: none;
}
.pill-prueba:hover { color: #7A4E0C; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--eo-niebla); color: var(--eo-petroleo-oscuro); font-weight: 600; font-size: .85rem;
}

.panel { background: #fff; border: 1px solid var(--eo-linea); border-radius: .75rem; }
.panel-cuerpo { padding: 1.5rem; }

/* Pasos de puesta en marcha (secuencia real: conectar, crear, compartir) */
.pasos { list-style: none; padding: 0; margin: 0; counter-reset: paso; }
.pasos li { display: flex; gap: 1rem; padding: 1.1rem 0; border-top: 1px solid var(--eo-linea); }
.pasos li:first-child { border-top: 0; }
.pasos .num {
  counter-increment: paso; flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--eo-linea); display: grid; place-items: center;
  font-weight: 600; font-size: .9rem; color: var(--eo-tinta-suave);
}
.pasos .num::before { content: counter(paso); }
.pasos li.hecho .num { background: var(--eo-petroleo); border-color: var(--eo-petroleo); color: #fff; }
.pasos li.hecho .num::before { content: "✓"; }
.pasos h3 { font-size: 1rem; margin: .25rem 0 .2rem; }
.pasos p { margin: 0; color: var(--eo-tinta-suave); font-size: .925rem; }

.cifra { font-size: 2rem; font-weight: 600; line-height: 1.1; }
.cifra-label { color: var(--eo-tinta-suave); font-size: .9rem; }

.table > :not(caption) > * > * { padding: .75rem .75rem; }
.table thead th { font-weight: 500; font-size: .85rem; color: var(--eo-tinta-suave); background: var(--eo-superficie); }

.estado { display: inline-block; font-size: .8rem; font-weight: 500; padding: .2rem .6rem; border-radius: 999px; white-space: nowrap; }
.estado-trial     { background: var(--eo-ambar-fondo); color: var(--eo-ambar); }
.estado-activa    { background: #E2F2EA; color: #1E6B45; }
.estado-vencida, .estado-suspendida, .estado-sin_suscripcion { background: #F8E5E5; color: #9B2C2C; }
.estado-cancelada { background: #ECEFF1; color: #4A5866; }

/* ---------- Dashboards ---------- */
.icono-dashboard {
  width: 40px; height: 40px; border-radius: .6rem; flex: none;
  display: grid; place-items: center; background: var(--eo-niebla); color: var(--eo-petroleo-oscuro); font-size: 1.15rem;
}
.tarjeta-dashboard:hover { border-color: var(--eo-petroleo); }
.min-w-0 { min-width: 0; }
.opcion-paquete {
  display: block; height: 100%; padding: .75rem .9rem; border: 1px solid var(--eo-linea); border-radius: .6rem; cursor: pointer; background: #fff;
}
.btn-check:checked + .opcion-paquete { border-color: var(--eo-petroleo); box-shadow: 0 0 0 .15rem rgba(11,85,99,.18); background: var(--eo-niebla); }
.btn-check:focus-visible + .opcion-paquete { outline: 2px solid var(--eo-petroleo); outline-offset: 2px; }
.lista-plantillas { max-height: 320px; overflow-y: auto; }

.widget { display: flex; flex-direction: column; }
.widget-cabecera { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; padding: 1rem 1.25rem .25rem; }
.widget-cuerpo { flex: 1; padding: .5rem 1.25rem 1.25rem; min-height: 120px; }
.widget-cuerpo.widget-kpi { min-height: 90px; display: flex; align-items: center; }
.kpi-valor { font-size: clamp(1.6rem, 3vw, 2.3rem); font-weight: 600; letter-spacing: -.02em; color: var(--eo-tinta); }
.widget-lienzo { position: relative; height: 260px; }
.widget-cargando, .widget-vacio, .widget-error { font-size: .875rem; color: var(--eo-tinta-suave); }
.widget-cargando { display: flex; align-items: center; gap: .5rem; min-height: 60px; }
.widget-error { color: #9B2C2C; }
.widget-edicion { border-top: 1px dashed var(--eo-linea); padding: .75rem 1.25rem; background: var(--eo-superficie); border-radius: 0 0 .75rem .75rem; }
.filtros-dashboard .form-select, .filtros-dashboard .form-control { min-width: 150px; }

/* ---------- Asistente IA ---------- */
.caja-ia { background: var(--eo-niebla); border-radius: .6rem; padding: .9rem 1rem; }
.btn-analizar { color: var(--eo-petroleo); line-height: 1; }

/* ---------- Documentos legales ---------- */
.pie-legal { display: flex; justify-content: center; gap: .5rem; flex-wrap: wrap; }
.pie-legal a { color: inherit; }
.documento-legal { line-height: 1.7; }
.documento-legal h2 { color: var(--eo-tinta); }
.aviso-verificacion { background: var(--eo-ambar-fondo); color: #6B460C; border-radius: .6rem; }
.icono-libro { width: 48px; height: 48px; border-radius: .6rem; display: grid; place-items: center; background: var(--eo-petroleo); color: #fff; font-size: 1.5rem; flex: none; }
.enlace-libro { font-weight: 500; }
@media print { .pie-legal, header, .d-print-none { display: none !important; } }

/* ---------- Avisos de la plataforma (toasts) ---------- */
.aviso-toast .toast-header { color: #fff; }
.aviso-toast .toast-header .btn-close { filter: invert(1) grayscale(1) brightness(2); }
.aviso-info .toast-header, .badge.aviso-info { background: var(--eo-petroleo); color: #fff; }
.aviso-exito .toast-header, .badge.aviso-exito { background: #2E7D4F; color: #fff; }
.aviso-aviso .toast-header, .badge.aviso-aviso { background: #C98A12; color: #fff; }
.aviso-urgente .toast-header, .badge.aviso-urgente { background: #9B2C2C; color: #fff; }
.punto-conectado { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: #2E7D4F; }

/* ---------- Configuración del superadmin: bloques colapsables ---------- */
.config-acordeon .accordion-button { gap: .25rem; }
.config-acordeon .accordion-button:not(.collapsed) { background: var(--eo-niebla); color: var(--eo-tinta); box-shadow: none; }
.config-acordeon .accordion-body { padding: 0; }
.config-acordeon .accordion-body .panel { border: 0; box-shadow: none; border-radius: 0; max-width: none !important; background: transparent; }
.config-acordeon .accordion-body .panel + .panel { border-top: 1px dashed var(--eo-linea); }
.config-acordeon .resumen-bloque { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
@media (max-width: 575.98px) { .config-acordeon .resumen-bloque { display: none; } }
