/* ============================================================
   Servicio de Salud Coquimbo — Estilos del sitio público
   ============================================================ */

/* ---------- Reset ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: 'Open Sans', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #475156;
    background: #e6e6e6;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { color: #0f69b4; text-decoration: none; }
img { max-width: 100%; height: auto; border: 0; }
ul, ol, li { list-style: none; }
.clearfix::after { content: ""; display: table; clear: both; }

.wrap {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 15px;
    position: relative;
    box-sizing: border-box;
}

/* ============================================================
   HEADER
   ============================================================ */
header {
    background-color: #0f69b4;
    background-image: url("../images/header.png");
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    padding: 0;
    margin-bottom: 20px;
    min-height: 220px;
    position: relative;
}
header .wrap {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 0 15px;
}
header h1#logo-main {
    position: absolute;
    top: 20px;
    left: 15px;
    margin: 0;
}
header h1#logo-main a { display: block; width: 160px; }
header h1#logo-main img { width: 100%; height: auto; }

header nav#menu-principal { width: 100%; }
header nav#menu-principal ul.menu-main {
    display: table;
    width: 100%;
    background: #ffffff;
    border-top: 1px solid #e6e6e6;
}
header nav#menu-principal ul.menu-main > li {
    display: table-cell;
    text-align: center;
    border-right: 1px solid #e6e6e6;
}
header nav#menu-principal ul.menu-main > li:last-child { border-right: none; }
header nav#menu-principal ul.menu-main > li > a {
    display: block;
    padding: 16px 10px;
    font-size: 13px;
    color: #475156;
    border-bottom: 3px solid transparent;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
header nav#menu-principal ul.menu-main > li > a:hover {
    color: #0f69b4;
    border-bottom-color: #0f69b4;
}
header nav#menu-principal ul.menu-main > li.current-menu-item > a {
    color: #0f69b4;
    border-bottom-color: #0f69b4;
    font-weight: 700;
}

/* ============================================================
   CONTENIDO
   ============================================================ */
#content { margin: 0 auto 30px; }
#content .wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
}
#main { flex: 1 1 0; min-width: 0; }
#sidebar { width: 320px; flex: 0 0 320px; }

.post.tarjeta {
    background: #ffffff;
    border-bottom: 2px solid #bdc9d1;
    padding: 25px 30px 35px;
}
.post.tarjeta .texto .left { width: 100%; }
.post.tarjeta .texto h4.title {
    font-size: 22px;
    font-weight: 500;
    color: #0f69b4;
    margin: 0 0 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e6e6e6;
    line-height: 1.3;
}
.post.tarjeta .texto h4.title a { color: #0f69b4; }
.post.tarjeta .texto h4.title a:hover { color: #045282; }

/* ============================================================
   ÁRBOL DE DOCUMENTOS
   ============================================================ */
#sidetree { margin-top: 10px; }
#sidetree #tree {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 14px;
    color: #475156;
}
#sidetree #tree ul {
    list-style: none;
    padding-left: 22px;
    margin: 0;
}
#sidetree #tree li {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
}
#sidetree #tree div.line {
    height: 1px;
    background: transparent;
    margin: 3px 0;
    padding: 0;
    line-height: 0;
    font-size: 0;
    overflow: hidden;
}
#sidetree #tree li.principal { border-bottom: 1px solid #e6e6e6; }
#sidetree #tree li.principal2,
#sidetree #tree li.principal3 { border-bottom: 1px solid #e6e6e6; }

#sidetree #tree li.principal > span {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 6px;
    cursor: pointer;
    color: #0f69b4;
    font-size: 14px;
    transition: background .12s, padding-left .15s;
    user-select: none;
}
#sidetree #tree li.principal > span:hover {
    background: #e8f0fe;
    padding-left: 12px;
}
#sidetree #tree li.principal.abierta > span { font-weight: 600; }
#sidetree #tree li.principal > span .toggle-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    font-size: 14px;
    font-weight: 700;
    color: #7a8791;
    flex-shrink: 0;
}
#sidetree #tree li img {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    vertical-align: middle;
}
#sidetree #tree li.principal2 > a,
#sidetree #tree li.principal3 > a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 6px 8px 22px;
    color: #0f69b4;
    font-size: 13.5px;
    text-decoration: none;
    transition: background .12s;
    width: 100%;
}
#sidetree #tree li.principal2 > a:hover,
#sidetree #tree li.principal3 > a:hover {
    background: #e8f0fe;
    text-decoration: underline;
}
#sidetree #tree .cuarto {
    color: #0f69b4;
    font-size: 12px;
    font-weight: 600;
    margin-left: 6px;
}
#sidetree #tree li.principal > ul { display: none; }
#sidetree #tree li.principal.abierta > ul {
    display: block;
    animation: desplegar .25s ease-out;
    padding-left: 22px;
    border-left: 1px dashed #d5dde3;
    margin-left: 8px;
}
@keyframes desplegar {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
#sidetree .vacio {
    color: #7a8791;
    font-style: italic;
    padding: 15px 0;
}

/* ============================================================
   BANNERS LATERALES
   ============================================================ */
#sidebar .banners {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.banner {
    display: block;
    background: #ffffff;
    border: 1px solid #d5dde3;
    border-bottom: 2px solid #bdc9d1;
    overflow: hidden;
    transition: box-shadow .15s;
}
.banner:hover { box-shadow: 0 3px 10px rgba(0,0,0,.10); }
.banner.banner-corto { width: 100%; }
.banner.banner-corto a { display: block; }
.banner.banner-corto img { display: block; width: 100%; height: auto; }

/* ============================================================
   FOOTER
   ============================================================ */
footer {
    background: transparent;
    margin-top: 40px;
    padding: 0;
}

footer .wrap {
    width: 970px;
    max-width: calc(100% - 30px);
    margin: 0 auto;
    padding: 0;
    background: #ffffff;
    box-sizing: border-box;
}

footer .bicolor {
    display: flex;
    height: 3px;
    width: 100%;
    margin: 0;
}
footer .bicolor span.azul { background: #0f69b4; flex: 1; }
footer .bicolor span.rojo { background: #eb3646; flex: 0 0 46%; }

footer .bottom {
    padding: 18px 15px 22px;
    font-size: 12px;
    color: #475156;
    line-height: 1.6;
}
footer .bottom .left { display: block; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1040px) {
    #content .wrap { flex-direction: column; }
    #sidebar { width: 100%; flex: 1 1 auto; }
    #sidebar .banners {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 12px;
    }
}

@media (max-width: 700px) {
    header { min-height: 130px; }
    header .wrap { min-height: 130px; }

    header nav#menu-principal ul.menu-main { display: block; }
    header nav#menu-principal ul.menu-main > li {
        display: block;
        border-right: none;
        border-bottom: 1px solid #e6e6e6;
        text-align: left;
    }
    header nav#menu-principal ul.menu-main > li > a {
        text-align: left;
        padding: 12px 15px;
        border-bottom: none;
        border-left: 3px solid transparent;
    }
    header nav#menu-principal ul.menu-main > li > a:hover,
    header nav#menu-principal ul.menu-main > li.current-menu-item > a {
        border-bottom: none;
        border-left-color: #0f69b4;
        background: #f0f4f8;
    }

    .post.tarjeta { padding: 18px 15px 22px; }
    .post.tarjeta .texto h4.title { font-size: 18px; }
    #sidebar .banners { grid-template-columns: 1fr; }

    footer .wrap {
        width: 100%;
        max-width: 100%;
    }
}

/* ============================================================
   FECHAS Y BADGES
   ============================================================ */

.badge-nuevo {
    display: inline-block;
    background: #88E788;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
    font-size: .55rem;
    font-weight: 600;
    padding: .2rem .45rem;
    border-radius: 12px;
    margin-left: .5rem;
    vertical-align: middle;
    line-height: 1;
    letter-spacing: .3px;
}

.fecha-pub {
    display: inline-block;
    color: #6c757d;
    font-size: .70rem;
    margin-left: .5rem;
    vertical-align: middle;
}

/* ============================================================
   REGLAS DE VISIBILIDAD DE LA FECHA (ACTUALIZADO)
   ============================================================ */

/* 
 * REGLA 1: Fecha base. Ocultamos por defecto.
 * Aplicamos esto a TODAS las fechas en el árbol.
 */
#sidetree #tree .fecha-actualizacion {
    display: inline-block;
    color: #6c757d;
    font-size: .68rem;
    white-space: nowrap;
    margin-left: auto; 
    padding-left: 1rem;
    opacity: 0; /* Oculto por defecto */
    transition: opacity 0.2s ease-in-out;
}

/* 
 * REGLA 2: El PADRE PRINCIPAL (Nivel 1) siempre visible.
 * Usamos el selector de hijo directo ">" para que SOLO afecte a las carpetas 
 * que están pegadas directamente a la raíz del árbol (primer nivel).
 */
#sidetree #tree > li.principal > span > .fecha-actualizacion {
    opacity: 1; 
}

/* 
 * REGLA 3: Mostrar al pasar el mouse en SUBCARPETAS.
 * Si la fecha está dentro de un "ul" (o sea, no es hijo directo de #tree), 
 * se mostrará solo cuando el mouse esté sobre la fila.
 */
#sidetree #tree ul .fecha-actualizacion {
    /* Forzamos que herede la opacidad 0 de la Regla 1 */
    opacity: 0; 
}

#sidetree #tree ul li.principal > span:hover .fecha-actualizacion {
    opacity: 1;
}

.fecha-actualizacion strong {
    color: #495057;
    font-weight: 600;
}

/* Quitar subrayado de los links del árbol */
#sidetree a,
#sidetree a:hover,
#sidetree a:focus,
#sidetree a:visited {
    text-decoration: none !important;
    color: inherit;
}