/*
 * Previsiones de Formación: colores corporativos sobre la plantilla Doccure (Bootstrap 5) y piezas propias.
 * Se carga después de plantilla/css/doccure.css.
 */

/* Fuente de la plantilla (Mada), servida desde la aplicación: la CSP no permite Google Fonts. */
@font-face { font-family: "Mada"; font-style: normal; font-display: swap; font-weight: 400; src: url("../fonts/mada-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Mada"; font-style: normal; font-display: swap; font-weight: 500; src: url("../fonts/mada-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Mada"; font-style: normal; font-display: swap; font-weight: 600; src: url("../fonts/mada-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Mada"; font-style: normal; font-display: swap; font-weight: 700; src: url("../fonts/mada-latin-700-normal.woff2") format("woff2"); }

/* ---------- Colores corporativos ---------- */
:root {
    --primary: #ff7900;
    --primary-oscuro: #e56d00;
    --primary-texto: #c25700;          /* naranja legible sobre blanco (enlaces y textos pequeños) */
    --primary-suave: #fff1e5;
    --title-color: #000000;            /* menú lateral, cabecera del logo y títulos en negro */

    --bs-primary: #ff7900;
    --bs-primary-rgb: 255, 121, 0;
    --bs-link-color: var(--primary-texto);
    --bs-link-color-rgb: 194, 87, 0;
    --bs-link-hover-color: #8f4000;
    --bs-link-hover-color-rgb: 143, 64, 0;
    --bs-focus-ring-color: rgba(255, 121, 0, 0.25);
}

/* Texto negro sobre naranja: con blanco el contraste no llega al mínimo de accesibilidad. */
.btn-primary,
.btn-primary-gradient,
.btn-gradient {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-oscuro);
    --bs-btn-hover-border-color: var(--primary-oscuro);
    --bs-btn-active-bg: var(--primary-oscuro);
    --bs-btn-active-border-color: var(--primary-oscuro);
    --bs-btn-disabled-bg: var(--primary);
    --bs-btn-disabled-border-color: var(--primary);
    color: #000 !important;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--primary-oscuro);
    border-color: var(--primary-oscuro);
}

.btn-outline-primary:hover {
    background-color: var(--primary);
    color: #000 !important;
}

a.text-primary,
.text-primary-texto {
    color: var(--primary-texto) !important;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(255, 121, 0, 0.2);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.progress-bar.bg-primary,
.bg-primary {
    background-color: var(--primary) !important;
}

/* Paginación de DataTables con Bootstrap 5. */
.page-link {
    color: var(--primary-texto);
}

.active > .page-link,
.page-link.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #000;
}

/* ---------- Estructura ---------- */
.logo-pf {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
}

.logo-pf:hover {
    color: #fff;
}

.logo-pf .marca {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--primary);
    color: #000;
    font-weight: 700;
    font-size: 14px;
}

.logo-pf .nombre {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    white-space: nowrap;
}

.logo-pf .nombre strong {
    font-size: 15px;
    font-weight: 700;
}

.logo-pf .nombre small {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

.mini-sidebar .header-left .logo-pf .nombre,
.header-left .logo-pf .nombre small {
    display: none;
}

.header .header-left {
    display: flex;
    align-items: center;
}

.header .header-left .logo.logo-pf {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    height: 60px;
    line-height: 1;
    padding-left: 4px;
    text-align: left;
}

.header .header-left .logo-pf .nombre strong {
    font-size: 14px;
    letter-spacing: -0.01em;
}

.mini-sidebar .header .header-left .logo.logo-pf {
    justify-content: center;
    padding-left: 0;
}

/* Desplegable del año: que quepan los cuatro dígitos. */
.filtros select[name^="Anyo"] {
    min-width: 96px;
}

.header .entorno-cabecera {
    display: flex;
    align-items: center;
    height: 60px;
    margin-left: 16px;
}

.user-menu .user-img .avatar-iniciales,
.avatar-iniciales {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-suave);
    color: var(--primary-texto);
    font-weight: 700;
    font-size: 13px;
}

/* Elementos del menú que son módulos de la propuesta aún no disponibles. */
.sidebar-menu li.propuesto > a {
    opacity: 0.7;
}

/* El reloj de «próximamente» no es un icono de menú: sin la caja que la plantilla da a los iconos. */
.sidebar .sidebar-menu > ul > li > a .nav-proximamente {
    margin-left: 6px;
}

.sidebar .sidebar-menu > ul > li > a .nav-proximamente i,
.sidebar-leyenda .nav-proximamente i {
    width: auto !important;
    height: auto;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    color: inherit;
    font-size: 10px;
    line-height: 1;
}

/* Las tablas de las tarjetas pueden partir líneas (la plantilla lo impide en .table-responsive). */
.card .table-responsive {
    white-space: normal;
}

.card .table-responsive th {
    white-space: nowrap;
}

table.dataTable td {
    font-size: 14px;
}

/* Selector de filas por página de DataTables: hueco para la flecha de la plantilla. */
.dt-container .dt-length select {
    min-width: 78px;
    padding-right: 32px;
    margin-right: 6px;
}

/* Informe por nivel: formación y división con ancho suficiente; el resto de columnas en una línea. */
.tabla-informe td,
.tabla-informe th {
    white-space: nowrap;
}

.tabla-informe td:nth-child(-n+2) {
    min-width: 240px;
    white-space: normal;
}

.sidebar-menu li.propuesto.active > a {
    opacity: 1;
}

.sidebar-menu li.propuesto > a {
    display: flex;
    align-items: center;
}

.sidebar-menu li.propuesto > a > span:not(.nav-proximamente) {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mini-sidebar:not(.expand-menu) .sidebar-menu .nav-proximamente {
    display: none;
}

.sidebar-menu .nav-proximamente {
    flex-shrink: 0;
    margin-left: 6px;
    padding: 2px 5px;
    border-radius: 4px;
    background: rgba(255, 121, 0, 0.18);
    color: #ffb066;
    font-size: 10px;
    line-height: 1.2;
}

.sidebar-leyenda {
    padding: 12px 20px 24px;
    font-size: 11px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.5);
}

.sidebar-leyenda .nav-proximamente {
    margin-right: 4px;
}

.page-header .page-title {
    margin-bottom: 2px;
}

.page-header .contexto {
    color: var(--text-muted);
    font-size: 14px;
}

/* ---------- Indicadores ---------- */
.appointment-stat-card {
    height: 100%;
}

.appointment-stat-card .stat-number {
    margin-bottom: 4px;
}

.appointment-stat-card .stat-pie {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 10px;
    font-size: 13px;
    color: var(--text-muted);
}

.sube { color: #1a8a3f; font-weight: 600; }
.baja { color: #d63030; font-weight: 600; }
.estable { color: #b26b00; font-weight: 600; }

/* ---------- Tarjetas ---------- */
.card .card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 12px;
}

.card .card-header .card-subtitulo {
    font-size: 13px;
    color: var(--text-muted);
}

.card-table .table {
    margin-bottom: 0;
}

.card-table .table > :not(caption) > * > * {
    padding: 12px 16px;
}

.table thead th {
    white-space: nowrap;
}

/* Tablas anchas (muchos niveles): se desplazan dentro de la tarjeta. */
.dt-container .dt-layout-table > .dt-layout-cell {
    overflow-x: auto;
}

.dt-container .dt-search input {
    min-width: 220px;
}

/* Select2 con el aspecto de los campos de la plantilla. */
.select2-container--default .select2-selection--multiple {
    min-height: 44px;
    border-color: var(--border-color);
    border-radius: 8px;
}

.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--primary);
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    border: 0;
    border-radius: 6px;
    background: var(--primary-suave);
    color: var(--primary-texto);
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--primary);
    color: #000;
}

.numerica,
table.dataTable th.numerica,
table.dataTable td.numerica {
    text-align: end;
}

.fila-atenuada td {
    color: var(--text-muted);
}

.texto-secundario {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
}

/* Barra de avance con su porcentaje. */
.avance {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
}

.avance .progress {
    flex-grow: 1;
    height: 6px;
    margin: 0;
}

.avance .valor {
    width: 46px;
    flex-shrink: 0;
    text-align: end;
    font-size: 13px;
    font-weight: 600;
    color: var(--title-color);
}

/* Etiquetas de estado. */
.estado {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.estado-correcto { background: rgba(26, 138, 63, 0.12); color: #17793a; }
.estado-riesgo { background: rgba(255, 188, 52, 0.18); color: #8a5a00; }
.estado-critico { background: rgba(232, 70, 70, 0.12); color: #c22c2c; }
.estado-sin { background: #eef0f4; color: #5b6475; }
.estado-info { background: rgba(0, 158, 251, 0.12); color: #0072b5; }

/* Listas dentro de tarjetas. */
.fila-lista {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-300);
}

.fila-lista:last-child {
    border-bottom: 0;
}

.fila-lista .nombre {
    display: block;
    max-width: 230px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    color: var(--title-color);
}

a.nombre:hover {
    color: var(--primary-texto);
}

/* ---------- Filtros ---------- */
.filtros .form-label {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
}

/* ---------- Gráfico de barras (evolución mensual) ---------- */
.grafico {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    height: 220px;
    padding-top: 24px;
    border-bottom: 1px solid var(--gray-300);
}

.grafico-grupo {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    height: 100%;
}

.barra {
    position: relative;
    width: 100%;
    max-width: 42px;
    border-radius: 6px 6px 0 0;
}

.barra span {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 700;
    color: var(--title-color);
    white-space: nowrap;
}

.barra-objetivo { background: #d7dce5; }
.barra-formados { background: var(--primary); }

.leyenda {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.leyenda .punto {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ---------- Proyección de cierre ---------- */
.proyeccion-barra {
    position: relative;
    height: 12px;
    border-radius: 6px;
    background: #eef0f4;
}

.proyeccion-barra .tramo {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    border-radius: 6px;
}

.proyeccion-barra .tramo-proyectado { background: rgba(255, 121, 0, 0.3); }
.proyeccion-barra .tramo-formados { background: var(--primary); }

.proyeccion-barra .meta {
    position: absolute;
    top: -6px;
    bottom: -6px;
    border-left: 2px solid var(--title-color);
}

.cifra-destacada {
    padding: 16px;
    border-radius: 12px;
    background: #f5f7fc;
    height: 100%;
}

.cifra-destacada.cifra-naranja { background: var(--primary-suave); }
.cifra-destacada.cifra-verde { background: rgba(26, 138, 63, 0.08); }

.cifra-destacada .titulo {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}

.cifra-destacada .valor {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--title-color);
}

/* ---------- Resumen IA ---------- */
.card-ia {
    border: 1px solid rgba(255, 121, 0, 0.35);
}

.card-ia .icono-ia,
.icono-modulo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--primary-suave);
    color: var(--primary-texto);
}

.icono-modulo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    font-size: 22px;
}

.lista-numerada {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: accion;
}

.lista-numerada li {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    counter-increment: accion;
}

.lista-numerada li::before {
    content: counter(accion);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    margin-top: 1px;
    border-radius: 50%;
    background: var(--primary);
    color: #000;
    font-size: 12px;
    font-weight: 700;
}

.datos-ia {
    max-height: 300px;
    overflow: auto;
    padding: 12px;
    border-radius: 8px;
    background: #f5f7fc;
    font-size: 12px;
}

/* ---------- Pasos de la validación de carga ---------- */
.paso {
    height: 100%;
    padding: 16px;
    border: 1px solid var(--gray-300);
    border-radius: 14px;
    background: var(--white);
}

.paso .numero {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-bottom: 6px;
    border-radius: 50%;
    background: #eef0f4;
    font-weight: 700;
}

.paso strong { display: block; color: var(--title-color); }
.paso span:not(.numero) { font-size: 13px; color: var(--text-muted); }
.paso.hecho .numero { background: rgba(26, 138, 63, 0.12); color: #17793a; }
.paso.actual { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.paso.actual .numero { background: var(--primary); color: #000; }
.paso.inactivo { opacity: 0.6; }

/* ---------- Informe por nivel ---------- */
.tabla-informe td.con-formados { font-weight: 700; color: #17793a; }
.tabla-informe td.sin-formados { color: var(--text-muted); }

.selector-multiple {
    min-height: 120px;
}

/* ---------- Aviso semanal (vista previa de correo) ---------- */
.correo {
    max-width: 720px;
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid var(--gray-300);
    border-radius: 16px;
    background: var(--white);
    box-shadow: 0 4px 20px -5px rgba(15, 23, 42, 0.08);
}

.correo .cabecera-correo {
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-300);
    background: #f8f9fb;
    font-size: 14px;
}

.correo .cabecera-correo .etiqueta {
    display: inline-block;
    width: 64px;
    color: var(--text-muted);
}

.correo .franja {
    height: 6px;
    background: var(--primary);
}

.correo .cuerpo {
    padding: 28px 32px;
    font-size: 15px;
}

.correo .cifra {
    height: 100%;
    padding: 14px;
    border: 1px solid var(--gray-300);
    border-radius: 10px;
}

/* ---------- Inicio de sesión ---------- */
.login-left .logo-pf .nombre strong {
    font-size: 20px;
}

.login-left .logo-pf .marca {
    width: 46px;
    height: 46px;
    font-size: 17px;
}

.btn-login-submit {
    background: var(--primary) !important;
    color: #000 !important;
}

.validation-summary-valid {
    display: none;
}

.validation-summary-errors ul {
    margin: 0;
    padding-left: 1rem;
}

/* Excel de ejemplo incluido en la aplicación (validar sin subir un archivo). */
.ejemplo-carga {
    padding: 14px 16px;
    border: 1px dashed var(--primary);
    border-radius: 8px;
    background: rgba(255, 121, 0, 0.04);
}
.ejemplo-carga .btn-outline-primary { color: var(--primary-texto) !important; }
.ejemplo-carga .btn-outline-primary:hover { color: #000 !important; }
