/* =====================================
   VARIABLES Y CONFIGURACIÓN (PALETA INSTITUCIONAL)
   ===================================== */
:root {
    --color-primary: #007A96;
    --color-secondary: #ffc107;
    --color-light: #f8f9fa;
    --color-dark: #1a2a36;
    --accent-color: #0097a7;
    --bg-light: #f0f9fc;
    --border-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 2px 8px rgba(0, 122, 150, 0.05);
    --shadow-md: 0 10px 40px rgba(0, 0, 0, 0.08);
}

/* =====================================
   ESTILOS DE CABECERA
   ===================================== */
.psc-header {
    margin-bottom: 3.5rem !important;
}

.psc-header h2.section-title {
    color: var(--color-primary);
    font-weight: 700;
    display: block !important;
    padding-left: 0 !important;
    text-align: center !important;
    margin: 0 auto 0.2rem auto;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
}

.psc-header p.section-subtitle {
    color: #546e7a;
    font-weight: 400;
    font-size: 1rem;
}

/* =====================================
   ESTADO 1: LANDING GRID (MOSAICO)
   ===================================== */
.psc-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 0;
}

.psc-tab-item.landing-item {
    background: #fff;
    border: 1px solid #e2eef1;
    padding: 30px 20px;
    text-align: center;
    border-radius: var(--border-radius);
    transition: var(--transition);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 300px;
}

.psc-tab-item.landing-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 122, 150, 0.15);
    border-color: var(--accent-color);
}

.psc-logo-wrapper img {
    width: 130px;
    height: 90px;
    object-fit: contain;
    margin-bottom: 20px;
}

.psc-tab-item .psc-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-dark);
    line-height: 1.4;
    margin-bottom: 15px;
}

.view-details-btn {
    margin-top: auto;
    color: var(--color-primary);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 8px 20px;
    border-radius: 50px;
    background: var(--bg-light);
    transition: var(--transition);
}

.psc-tab-item.landing-item:hover .view-details-btn {
    background: var(--color-primary);
    color: #fff;
}

/* =====================================
   ESTADO 2: VISTA DE DETALLE
   ===================================== */
.psc-detail-view {
    display: grid;
    grid-template-columns: 320px 1fr;
    background-color: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid #eef6f8;
}

/* ===== SIDEBAR NAVEGACIÓN ===== */
.psc-sidebar-nav {
    background-color: #f4f9fb;
    padding: 30px 20px;
    border-right: 1px solid #e2eff2;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-heading {
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.75rem;
    color: #90a4ae;
    margin-bottom: 20px;
    flex-shrink: 0;
}

/* Contenedor de la lista (toggle) */
.psc-list-wrapper {
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
}

.psc-list-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 4px;
}

.psc-tab-item:not(.landing-item) {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: #fff;
    border-radius: 12px;
    cursor: pointer;
    border: 1px solid #e2eff2;
    transition: var(--transition);
    min-height: 60px;
    flex-shrink: 0;
}

.psc-sidebar-logo-box img {
    width: 40px;
    height: 30px;
    object-fit: contain;
    filter: grayscale(100%);
    opacity: 0.6;
    flex-shrink: 0;
}

.psc-tab-item .psc-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-dark);
    line-height: 1.3;
    word-break: break-word;
}

.psc-tab-item.active {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(0, 122, 150, 0.2);
}

.psc-tab-item.active .psc-name {
    color: #fff;
}
.psc-tab-item.active img {
    filter: grayscale(0) brightness(2);
    opacity: 1;
}

/* ===== BOTÓN TOGGLE ===== */
.psc-toggle-btn {
    display: none;
    background: none;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 12px;
    align-self: center;
    width: 100%;
    max-width: 200px;
    text-align: center;
    background: #fff;
}

.psc-toggle-btn:hover {
    background: var(--color-primary);
    color: #fff;
}
.psc-toggle-btn i {
    margin-left: 6px;
    transition: transform 0.3s ease;
}
.psc-toggle-btn.expanded i {
    transform: rotate(180deg);
}

/* ===== PANEL DE CONTENIDO ===== */
.psc-content-panel {
    padding: 40px;
    overflow-x: hidden;
}

/* ===== BARRA DE INFORMACIÓN COMPACTA ===== */
.psc-compact-info-bar {
    background-color: #fff;
    border: 1px solid #eef6f8 !important;
    border-radius: 12px;
}

.info-block small {
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #78909c;
    margin-bottom: 2px;
}
.info-block span {
    color: var(--color-dark);
    font-weight: 600;
    font-size: 0.9rem;
}

.contact-list div {
    font-size: 0.85rem;
    color: #546e7a;
    word-break: break-word;
    overflow-wrap: break-word;
}
.contact-list i {
    color: var(--accent-color) !important;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}
.contact-list a {
    color: #546e7a;
    transition: var(--transition);
    text-decoration: none;
    word-break: break-word;
}
.contact-list a:hover {
    color: var(--color-primary);
}
.contact-list span {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* ===== BOTONES ===== */
.btn-primary {
    background-color: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
}
.btn-primary:hover {
    background-color: #006580 !important;
    border-color: #006580 !important;
}
.btn-outline-primary {
    color: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
}
.btn-outline-primary:hover {
    background-color: var(--color-primary) !important;
    color: #fff !important;
}

/* ===== TILES DE DOCUMENTOS ===== */
.psc-tiles-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.subitem-tile {
    background-color: #fff;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #eef6f8;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}
.subitem-tile:hover {
    border-color: var(--accent-color);
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 151, 167, 0.1);
    background: var(--bg-light);
}
.subitem-tile i {
    font-size: 2rem;
    color: var(--color-primary);
    margin-bottom: 12px;
    display: block;
}
.subitem-tile h6 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--color-dark);
}
.subitem-tile .badge {
    background-color: var(--bg-light) !important;
    color: var(--color-primary) !important;
    border: 1px solid #d0e8f0 !important;
    font-weight: 600;
}

/* ============================================================
   ===== RESPONSIVE - ESTRATEGIA SIMPLIFICADA =====
   ============================================================ */

/* ----- DESKTOP (≥ 992px): sidebar columna fija, sin toggle ----- */
@media (min-width: 992px) {
    .psc-list-wrapper {
        max-height: none !important;
        overflow: visible !important;
        flex: 1;
    }
    .psc-list-group {
        flex-direction: column;
        gap: 10px;
    }
    .psc-tab-item:not(.landing-item) {
        min-width: unset;
        width: 100%;
        padding: 12px 15px;
        min-height: 60px;
    }
    .psc-toggle-btn {
        display: none !important;
    }
}

/* ----- TABLETS Y MÓVILES (≤ 991px): sidebar columna con toggle ----- */
@media (max-width: 991px) {
    .psc-detail-view {
        grid-template-columns: 1fr;
    }
    .psc-sidebar-nav {
        border-right: none;
        border-bottom: 1px solid #eef2f7;
        padding: 15px;
    }
    .psc-content-panel {
        padding: 16px !important;
    }

    /* Botón toggle visible */
    .psc-toggle-btn {
        display: block;
        max-width: 100%;
        padding: 10px;
        font-size: 0.8rem;
    }

    /* Wrapper con toggle */
    .psc-list-wrapper {
        overflow: hidden;
        transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
        flex: none;
    }

    .psc-list-group {
        flex-direction: column;
        gap: 8px;
        padding-bottom: 0;
    }

    .psc-tab-item:not(.landing-item) {
        min-width: unset;
        width: 100%;
        flex-shrink: 0;
        padding: 10px 14px;
        min-height: 50px;
    }

    .psc-sidebar-logo-box img {
        width: 32px;
        height: 24px;
    }
    .psc-tab-item .psc-name {
        font-size: 0.8rem;
    }
    .sidebar-heading {
        font-size: 0.7rem;
        margin-bottom: 12px;
    }
    

    /* Alturas colapsado/expandido para VERTICAL */
    @media (orientation: portrait) {
        .psc-list-wrapper {
            max-height: 160px;
        }
        .psc-list-wrapper.expanded {
            max-height: 600px;
        }
    }

    /* Alturas colapsado/expandido para HORIZONTAL (más compacto) */
    @media (orientation: landscape) {
        .psc-list-wrapper {
            max-height: 120px;
        }
        .psc-list-wrapper.expanded {
            max-height: 450px;
        }

        /* Elementos más compactos en landscape */
        .psc-tab-item:not(.landing-item) {
            padding: 6px 10px;
            min-height: 38px;
            gap: 8px;
        }
        .psc-sidebar-logo-box img {
            width: 28px;
            height: 20px;
        }
        .psc-tab-item .psc-name {
            font-size: 0.7rem;
        }
        .psc-content-panel {
            padding: 12px !important;
        }
        .psc-compact-info-bar .row {
            flex-direction: row;
            flex-wrap: wrap;
        }
        .psc-compact-info-bar .col-md-7,
        .psc-compact-info-bar .col-md-5 {
            flex: 0 0 50% !important;
            max-width: 50% !important;
        }
        .psc-tiles-container {
            grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
            gap: 8px;
        }
        .subitem-tile {
            padding: 10px;
        }
        .subitem-tile i {
            font-size: 1.1rem;
        }
        .subitem-tile h6 {
            font-size: 0.7rem;
        }
    }

    /* Ajustes de contenido comunes para móviles/tablets (ambas orientaciones) */
    .psc-content-panel .d-flex.align-items-center {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
    }
    .psc-content-panel .d-flex.align-items-center .d-flex.gap-2 {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    .psc-content-panel .d-flex.align-items-center .d-flex.gap-2 .btn {
        font-size: 0.75rem;
        padding: 6px 14px;
        flex: 1 1 auto;
        min-width: 80px;
        text-align: center;
    }
    .psc-compact-info-bar {
        padding: 12px !important;
    }
    .psc-compact-info-bar .row {
        flex-direction: column;
        gap: 8px;
    }
    .psc-compact-info-bar .col-md-7,
    .psc-compact-info-bar .col-md-5 {
        padding: 0 !important;
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
    .psc-compact-info-bar .col-md-7 .d-flex.flex-wrap {
        flex-direction: column;
        gap: 6px;
    }
    .info-block {
        width: 100%;
    }
    .info-block small {
        font-size: 0.6rem;
    }
    .info-block span {
        font-size: 0.8rem;
        word-break: break-word;
    }
    .contact-list div {
        font-size: 0.78rem;
        margin-bottom: 4px;
        word-break: break-word;
    }
    .contact-list i {
        min-width: 16px;
        font-size: 0.85rem;
    }
    .psc-tiles-container {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 12px;
    }
    .subitem-tile {
        padding: 14px 12px;
    }
    .subitem-tile i {
        font-size: 1.5rem;
        margin-bottom: 8px;
    }
    .subitem-tile h6 {
        font-size: 0.78rem;
    }
    .subitem-tile .badge {
        font-size: 0.65rem;
        padding: 4px 8px;
    }
    .psc-content-panel h3.fw-bold {
        font-size: 1.2rem !important;
        word-break: break-word;
    }
    .psc-content-panel .text-uppercase.text-muted {
        font-size: 0.6rem !important;
    }
}

/* ----- MÓVILES MUY PEQUEÑOS (≤ 400px) ----- */
@media (max-width: 400px) {
    .psc-content-panel {
        padding: 12px !important;
    }
    .psc-tab-item:not(.landing-item) {
        padding: 8px 12px;
        min-height: 44px;
    }
    .psc-sidebar-logo-box img {
        width: 28px;
        height: 20px;
    }
    .psc-tab-item .psc-name {
        font-size: 0.75rem;
    }
    .psc-list-wrapper {
        max-height: 140px;
    }
    .psc-list-wrapper.expanded {
        max-height: 500px;
    }
    .psc-tiles-container {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .subitem-tile {
        padding: 10px 8px;
    }
    .subitem-tile i {
        font-size: 1.2rem;
        margin-bottom: 4px;
    }
    .subitem-tile h6 {
        font-size: 0.7rem;
        margin-bottom: 4px;
    }
    .subitem-tile .badge {
        font-size: 0.6rem;
        padding: 2px 6px;
    }
    .info-block span {
        font-size: 0.7rem;
    }
}

/* =====================================
   ANIMACIONES Y UTILIDADES
   ===================================== */
.psc-panel-content {
    animation: fadeInPsc 0.4s ease-out forwards;
}
@keyframes fadeInPsc {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ===== FIX PARA iOS ===== */
@supports (-webkit-touch-callout: none) {
    .psc-detail-view,
    .psc-sidebar-nav,
    .psc-content-panel,
    .psc-tab-item {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
    .psc-list-group {
        -webkit-overflow-scrolling: touch;
    }
}