/* ========== Protocolos Normalizados - Estilos del módulo ==========
   Cache: cargado en base.html con ?v=getFileVersion('css/protocolos_normalizados.css')
   (mismo sistema que los JS en el importmap) para evitar caché antigua. */

/* Cuando body tiene esta clase (página protocolos), fijar altura desde el contenedor principal.
   Así la cadena de alturas funciona sin depender de :has() (compatibilidad navegadores). */
body.page-protocolos-normalizados .container-fluid {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: calc(100vh - 200px);
}
body.page-protocolos-normalizados #dashboard-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
    overflow: hidden;
}
body.page-protocolos-normalizados #protocolos-normalizados-page {
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
    overflow: hidden;
}

#protocolos-normalizados-page .row.mb-3:first-of-type {
    flex-shrink: 0;
}

/* Fila de 2 columnas: ocupa el espacio restante (altura definida) */
#protocolos-normalizados-page .row[style*="min-height"],
#protocolos-normalizados-page .row.flex-grow-1 {
    flex: 1 1 0%;
    min-height: 0;
    overflow: hidden;
    display: flex;
}

#protocolos-normalizados-page .sidebar-protocolos-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

#protocolos-normalizados-page #sidebar-navegacion {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#protocolos-normalizados-page #sidebar-menu-content {
    min-height: 0;
}

/* Columna derecha: altura 100% de la fila para que el grid de 3 divs tenga altura */
#protocolos-normalizados-page .col-md-8.col-lg-9 {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

#protocolos-normalizados-page #contenido-protocolo {
    flex: 1 1 0%;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Panel derecho: 3 divs en vertical. Altura fija para que el grid y el footer funcionen. */
#protocolos-normalizados-page #vista-protocolo-detalle.protocolo-panel-right {
    flex: 1 1 0%;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto 1fr auto;
}
/* Alturas: TOP = auto, CENTER = 1fr (resto), BOTTOM = auto. El grid ocupa el 100% del padre. */

#protocolos-normalizados-page #vista-inicial {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

/* TOP: altura automática (título + botones), más fino */
.protocolo-panel-top {
    flex-shrink: 0;
    padding: 0.4rem 0;
    background: #fff;
    border-bottom: 1px solid #e9ecef;
}

.protocolo-panel-top .protocolo-titulo-line {
    font-size: 1.1rem;
    line-height: 1.3;
}

.protocolo-panel-top .protocolo-meta-line {
    font-size: 0.8rem;
    line-height: 1.25;
    margin-top: 0.15rem;
}

/* CENTER: scrollable. Altura 84% del panel derecho. */
.protocolo-panel-center {
    height: 84%;
    min-height: 120px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 1rem 0;
    background: #f8f9fa;
}

/* BOTTOM: altura automática, siempre pegado abajo del panel */
.protocolo-panel-bottom {
    flex-shrink: 0;
    padding: 0.75rem 1.25rem;
    background: #fff;
    border-top: 1px solid #e9ecef;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.04);
    box-sizing: border-box;
}

/* ========== Hoja A4: contenedor del contenido (sin cabecera/pie ni saltos) ========== */
.protocolo-hoja-a4 {
    max-width: 210mm;
    margin: 0 auto;
    padding: 20mm 25mm;
    box-sizing: border-box;
    background-color: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 0 1px rgba(0, 0, 0, 0.06);
}

@media (max-width: 576px) {
    .protocolo-hoja-a4 {
        padding: 15px;
    }
}

/* ========== Diseño unificado del contenido (todos los protocolos igual) ========== */
.protocolo-contenido {
    font-family: 'Georgia', 'Times New Roman', serif !important;
    font-size: 11pt !important;
    line-height: 1.6 !important;
    color: #222 !important;
}

.protocolo-contenido * {
    font-family: inherit !important;
    max-width: 100%;
}

.protocolo-contenido [style] {
    font-family: inherit !important;
    font-size: inherit !important;
    color: inherit !important;
    line-height: inherit !important;
}

.protocolo-contenido h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 1.25em 0 0.5em;
    color: #1a1a1a;
    line-height: 1.3;
}

.protocolo-contenido h1:first-child {
    margin-top: 0;
}

.protocolo-contenido h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 1.1em 0 0.5em;
    color: #2c3e50;
    padding-bottom: 0.25em;
    border-bottom: 1px solid #e0e0e0;
}

.protocolo-contenido h2:first-child {
    margin-top: 0;
}

.protocolo-contenido h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 1em 0 0.4em;
    color: #34495e;
}

.protocolo-contenido h4,
.protocolo-contenido h5,
.protocolo-contenido h6 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0.9em 0 0.3em;
    color: #34495e;
}

.protocolo-contenido p {
    margin-bottom: 0.85em;
    text-align: justify;
}

/* Listas: indentación clara por niveles (1 → a,b,c → i,ii,iii) */
.protocolo-contenido ul,
.protocolo-contenido ol {
    margin: 0.6em 0 1em;
    padding-left: 1.75em;
}

.protocolo-contenido li {
    margin-bottom: 0.4em;
}

.protocolo-contenido li>ul,
.protocolo-contenido li>ol {
    margin-top: 0.5em;
    margin-bottom: 0.6em;
    padding-left: 2.25em;
}

.protocolo-contenido ul ul,
.protocolo-contenido ol ul,
.protocolo-contenido ul ol,
.protocolo-contenido ol ol {
    margin: 0.45em 0 0.55em;
    padding-left: 2.5em;
    list-style-type: lower-alpha;
}

.protocolo-contenido ol ol {
    list-style-type: lower-alpha;
}

.protocolo-contenido ol[type="a"],
.protocolo-contenido ol[type="a"] ol {
    list-style-type: lower-alpha;
}

.protocolo-contenido ol[type="i"] {
    list-style-type: lower-roman;
}

.protocolo-contenido ul ul ul,
.protocolo-contenido ul ul ol,
.protocolo-contenido ol ul ul,
.protocolo-contenido ol ol ul,
.protocolo-contenido ol ol ol {
    margin: 0.4em 0 0.5em;
    padding-left: 2.75em;
    list-style-type: lower-roman;
}

.protocolo-contenido ol ol ol {
    list-style-type: lower-roman;
}

.protocolo-contenido ul ul ul ul,
.protocolo-contenido ul ul ul ol,
.protocolo-contenido ol ol ol ol {
    padding-left: 3em;
    list-style-type: decimal;
}

.protocolo-contenido strong,
.protocolo-contenido b {
    font-weight: 700;
    color: inherit;
}

.protocolo-contenido table {
    width: 100%;
    margin: 1em 0;
    border-collapse: collapse;
    font-size: inherit;
}

.protocolo-contenido table th,
.protocolo-contenido table td {
    padding: 0.45em 0.6em;
    border: 1px solid #ddd;
}

.protocolo-contenido table th {
    background-color: #f0f2f5;
    font-weight: 700;
}

.protocolo-contenido blockquote {
    margin: 1em 0;
    padding: 0.5em 1em;
    border-left: 4px solid #007bff;
    background: #f8f9fa;
    color: #444;
}

/* Título del protocolo: estilo documento */
.protocolo-titulo-documento {
    font-weight: 700;
    text-decoration: underline;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-size: 1.25rem;
}

/* Footer del protocolo: una línea compacta, texto más pequeño */

.protocolo-footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem 1rem;
    font-size: 0.75rem;
    color: #495057;
}

.protocolo-footer-left,
.protocolo-footer-right {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 0.75rem;
}

.protocolo-footer-right {
    text-align: right;
}

.protocolo-footer-inner strong {
    font-size: 0.7rem;
    font-weight: 600;
}

@media (max-width: 576px) {
    .protocolo-panel-bottom {
        padding: 1rem 15px;
    }

    .protocolo-footer-inner {
        flex-direction: column;
    }

    .protocolo-footer-right {
        text-align: left;
    }
}

@media print {
    .protocolo-hoja-a4 {
        box-shadow: none;
        min-height: auto;
        padding: 0;
    }

    .protocolo-panel-bottom {
        box-shadow: none;
        border-top: 1px solid #dee2e6;
    }

    .card-body.bg-light {
        background: #fff !important;
    }

    .navbar,
    .sidebar-protocolos-col,
    .btn,
    #vista-inicial {
        display: none !important;
    }
}

/* Sidebar: scroll individual (no usa scroll de la página) */
.sidebar-protocolos-col {
    height: 100%;
    min-height: 0;
}

#sidebar-navegacion {
    min-height: 0;
}

#sidebar-menu-content {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Acordeón de áreas */
.area-accordion-item {
    border: none;
    border-bottom: 1px solid #eee;
}

.area-accordion-header {
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
    transition: background 0.15s;
}

.area-accordion-header:hover {
    background: rgba(0, 123, 255, 0.06);
}

.area-accordion-header.active {
    background: rgba(0, 123, 255, 0.12);
    border-left: 3px solid #007bff;
}

.area-accordion-header .area-chevron {
    transition: transform 0.2s;
}

.area-accordion-header.collapsed .area-chevron {
    transform: rotate(-90deg);
}

.area-protocolos-body {
    padding: 0 0 0 1.25rem;
    border-left: 1px solid #eee;
    margin-left: 0.75rem;
}

/* Papelera: sección destacada para protocolos desactivados */
.area-accordion-item-papelera {
    border-top: 1px solid #dee2e6;
    background: linear-gradient(to bottom, #f8f9fa 0%, #fff 100%);
}
.area-accordion-item-papelera .area-accordion-header:hover {
    background: rgba(108, 117, 125, 0.12);
}
.sidebar-protocolo-item-papelera {
    border-left: 2px solid #adb5bd;
}
.sidebar-protocolo-item-papelera:hover {
    background: rgba(108, 117, 125, 0.08);
}

.sidebar-protocolo-item {
    padding: 0.4rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.9rem;
    border: none;
    background: transparent;
}

.sidebar-protocolo-item:hover {
    background: rgba(0, 123, 255, 0.08);
}

.sidebar-protocolo-item.active {
    background: #007bff;
    color: white;
}

.sidebar-protocolo-item.active .text-muted {
    color: rgba(255, 255, 255, 0.9) !important;
}

.sidebar-protocolo-item.active .badge.badge-light {
    background: rgba(255, 255, 255, 0.25) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    color: white !important;
}

.sidebar-protocolo-item .sidebar-protocolo-codigo {
    font-size: 0.7rem;
    color: #6c757d;
}

.sidebar-protocolo-item.active .sidebar-protocolo-codigo {
    color: rgba(255, 255, 255, 0.85);
}

.list-group-item.active {
    background-color: #007bff;
    border-color: #007bff;
    color: white;
}

.list-group-item.active .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
}