/* ==========================================================================
   1. Variables Globales y Estilos Base
   ========================================================================== */

:root {
    --primary-color: #0066cc;
    --secondary-color: #004080;
    --accent-color: #ff9900;
    --accent-color2: #0066cc; /* Usada para la línea en el menú de usuario */
    --light-bg: #f8f9fa;
    --dark-text: #212529;
    --line-color: #ccc; /* Usada en el organigrama */
}

body {
    font-family: 'Montserrat', sans-serif;
    padding-top: 65px;
    background-color: var(--light-bg); /* Aplicado globalmente */
}

/* ==========================================================================
   2. Barra de Navegación (Navbar)
   ========================================================================== */

.navbar {
    background-color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.navbar-brand img {
    height: 60px;
}

.nav-link {
    font-weight: 500;
    color: var(--dark-text);
    transition: all 0.3s ease;
    margin: 0 5px;
    position: relative;
}

.nav-link:hover {
    color: var(--primary-color);
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* Contenedor especial para links de usuario en la navbar */
.user-nav-container {
    padding: 0.8rem;
    border-radius: 8px;
    width: 100%;
}

/* Estilo para el menú en PÁGINAS DE DISPOSICIONES (Botones grandes) */
.page-disposiciones .user-nav-container .nav-links-row {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.page-disposiciones .user-nav-container .nav-link-law {
    display: inline-block;
    padding: 8px 15px;
    color: var(--dark-text);
    transition: color 0.3s ease, background-color 0.3s ease;
    border-radius: 5px;
    font-size: 1rem;
    text-decoration: none;
    min-width: 150px;
    text-align: center;
    font-weight: 500;
}

/* Estilo para el menú en PÁGINA DE LEY DE ADMIN. FINANCIERA (Links compactos) */
.page-ldaf .user-nav-container .nav-links-row {
    display: flex;
    justify-content: center; /* Centra el grupo de botones */
    flex-wrap: nowrap; /* <-- CAMBIO: Evita que los botones se separen de su fila */
    gap: 8px;
    width: 100%;
    margin-bottom: 5px;
}

.page-ldaf .user-nav-container .nav-link-law {
    padding: 8px 10px; /* Ajuste ligero en el padding horizontal */
    color: var(--dark-text);
    background-color: transparent;
    border-radius: 5px;
    text-decoration: none;
    text-align: center;
    white-space: nowrap;
    font-weight: 500;
    font-size: 0.8rem;
    transition: all 0.3s ease; /* Transición para todos los cambios */
}

/* ==========================================================================
   NUEVO: Reglas para adaptar el menú en pantallas más angostas
   ========================================================================== */
@media (max-width: 1300px) {
    .page-ldaf .user-nav-container .nav-links-row {
        gap: 5px; /* Reducimos el espacio entre botones */
    }

    .page-ldaf .user-nav-container .nav-link-law {
        font-size: 0.75rem; /* Hacemos la fuente un poco más pequeña */
        padding: 7px 8px;  /* Hacemos los botones un poco más compactos */
    }
}

/* Estilos comunes para HOVER y ACTIVO en ambos menús */
.user-nav-container .nav-link-law:hover {
    color: white;
    background-color: var(--primary-color);
    text-decoration: none;
}

.user-nav-container .nav-link-law.active-secondary {
    color: white;
    background-color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

/* Efecto hover para el contenedor en la página principal */
#navbarNav .user-nav-container:hover {
    background-color: #f8f9fa;
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#navbarNav .user-nav-container:hover .navbar-text {
    color: var(--primary-color);
    font-weight: 600;
    transition: color 0.3s ease;
}


/* ==========================================================================
   3. Estilos de Páginas Secundarias (Leyes, Decretos, etc.)
   ========================================================================== */

/* LOS ESTILOS DEL MENÚ QUE ESTABAN AQUÍ FUERON ELIMINADOS
   PARA EVITAR CONFLICTOS. LOS CORRECTOS ESTÁN ARRIBA EN LA SECCIÓN 2.
*/


/* ==========================================================================
   4. Secciones de Contenido
   ========================================================================== */

.section-title {
    text-align: center;
    margin-bottom: 40px;
    font-weight: 700;
    color: var(--primary-color);
    position: relative;
    padding-bottom: 15px;
    /*margin-top: 30px; */
}

.section-title::after {
    content: '';
    position: absolute;
    width: 80px;
    height: 3px;
    background-color: var(--accent-color);
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* Sección de contenido dinámico para páginas secundarias */
#dynamic-content-section {
    padding-top: 30px;
    padding-bottom: 50px;
    min-height: 80vh;
}


#dynamic-content-section h1,
#dynamic-content-section h2,
#dynamic-content-section h3,
#dynamic-content-section h4 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

#dynamic-content-section a {
    color: var(--primary-color);
    text-decoration: none;
}

#dynamic-content-section a:hover {
    text-decoration: underline;
}

#loaded-content .section-title {
    scroll-margin-top: 150px; /* Margen superior para compensar el menú fijo */
}

/* ==========================================================================
   5. Estilos de la Página Principal (index.html)
   ========================================================================== */

/* --- Hero Section --- */
.hero {
    position: relative;
    height: 100vh;
    overflow: hidden;
    text-align: center;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bg-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
    filter: brightness(0.7);
}

.hero-content {
    position: relative;
    z-index: 1;
    padding: 20px;
}

.hero h1 {
    font-size: 2.8rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.hero h2 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

/* --- Misión y Funciones --- */
#mision-y-funciones {
    background-color: var(--light-bg);
}

.mision-card {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.mision-icon {
    font-size: 3.5rem;
    color: var(--accent-color);
    margin-bottom: 15px;
}

.mision-card h3 {
    font-size: 1.8rem;
    color: var(--secondary-color);
    font-weight: 700;
    margin-bottom: 15px;
}

.funciones-list {
    list-style: none;
    padding: 0;
    margin: 0;
    column-count: 2;
    column-gap: 30px;
}

.funciones-list li {
    position: relative;
    padding-left: 28px;
    margin-bottom: 15px;
    font-size: 0.95rem;
    break-inside: avoid-column;
}

.funciones-list li::before {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: 0;
    top: 4px;
    color: var(--primary-color);
    font-size: 1rem;
}

/* --- Organigrama --- */
.organigrama-wrapper {
    overflow-x: auto;
    padding: 20px 0;
    text-align: center;
}

.org-chart {
    display: inline-block;
}

.org-chart ul {
    padding-top: 20px;
    position: relative;
    display: inline-flex;
    align-items: stretch;
}

.org-chart li {
    list-style-type: none;
    position: relative;
    padding: 20px 5px 0 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
}

.org-chart li::before, .org-chart li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid var(--line-color);
    width: 50%;
    height: 20px;
}

.org-chart li::after {
    right: auto;
    left: 50%;
    border-left: 2px solid var(--line-color);
}

.org-chart li:only-child { padding-top: 0; }
.org-chart li:only-child::before, .org-chart li:only-child::after { display: none; }
.org-chart li:first-child::before, .org-chart li:last-child::after { border: 0 none; }
.org-chart li:last-child::before { border-right: 2px solid var(--line-color); border-radius: 0 5px 0 0; }
.org-chart li:first-child::after { border-radius: 5px 0 0 0; }
.org-chart ul ul::before { content: ''; position: absolute; top: 0; left: 50%; border-left: 2px solid var(--line-color); width: 0; height: 20px; }

.org-chart li div {
    border: 1px solid var(--primary-color);
    padding: 10px 15px;
    text-decoration: none;
    color: var(--dark-text);
    background-color: #ffffff;
    font-size: 0.85rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    height: 70px;
}

.org-chart li div:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    border-color: var(--secondary-color);
}

.org-chart > ul > li > div { background-color: var(--primary-color); color: white; font-weight: 600; font-size: 1rem; }
.org-chart > ul > li > ul > li > div { background-color: #e3f2fd; border-color: #90caf9; }
.org-chart > ul > li > ul > li > ul > li > div { background-color: var(--light-bg); border-color: #e0e0e0; }
.org-chart > ul > li > ul > li > ul > li > ul > li > div { background-color: #fffde7; border-color: #fff59d; }

.secretaria-hacienda {
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--secondary-color);
    position: relative;
}

.secretaria-hacienda::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 40px;
    background-color: var(--line-color);
}

/* --- Sección Ciudadanos --- */
#ciudadanos {
    position: relative;
    background-image: url('../assets/CiudadHistorica.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
}

#ciudadanos::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 70, 128, 0.65);
    z-index: 1;
}

#ciudadanos .container {
    position: relative;
    z-index: 2;
}

#ciudadanos .section-title {
    color: #ffffff;
}

/* ==========================================================================
   6. Componentes (Tarjetas, Botones, Modales, etc.)
   ========================================================================== */

/* --- Tarjetas --- */
.service-card, .news-card {
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-bottom: 30px;
    height: 100%;
    border: none;
}

.service-card:hover, .news-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.service-card img, .news-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.service-card .card-body, .news-card .card-body {
    padding: 20px;
}

.service-card .card-title, .news-card .card-title {
    font-weight: 600;
    color: var(--primary-color);
}

/* --- Botones --- */
/*
 * REGLA CORREGIDA: Se aplica a los enlaces con clase .btn-primary
 * que están dentro de la sección dinámica para asegurar que la regla se aplique.
 */
#dynamic-content-section a.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white !important; /* Se usa !important como garantía final */
    padding: .25rem .5rem; /* Padding para .btn-sm */
    font-size: .875rem; /* Font-size para .btn-sm */
    border-radius: .2rem; /* Border-radius para .btn-sm */
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
}

#dynamic-content-section a.btn-primary:hover {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white !important;
    transform: translateY(-2px);
}


/* --- Tablas en Páginas Secundarias --- */
#search-bar-container {
    margin-bottom: 30px;
}

.table {
    border: 1px solid #dee2e6; /* Agregado para borde general */
}

.table-hover tbody tr:hover {
    background-color: #e9ecef;
}

.table th {
    color: var(--secondary-color);
}

.table .table-category-header {
    background-color: var(--primary-color) !important;
    color: white;
    font-weight: 600;
}

/* Estilos de la tabla de viáticos, por si se usa en otro lado */
.viaticos-table-container {
    overflow: auto;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 82, 156, 0.1);
    border: 1px solid #b3d4fc;
}
.viaticos-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
    font-size: 0.8rem;
}
.viaticos-table th,
.viaticos-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #d9e8f7;
    vertical-align: middle;
}
.viaticos-table thead th {
    background-color: #1976d2;
    color: #ffffff;
    font-weight: 600;
}
.viaticos-table tbody tr:hover {
    background-color: #e3f2fd;
}
.viaticos-table a {
    color: #0056b3;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}
.viaticos-table a:hover {
    color: #1e88e5;
    text-decoration: underline;
}

/* ==========================================================================
   7. Pie de Página (Footer)
   ========================================================================== */

footer {
    background-color: #212529;
    color: white;
    padding: 40px 0 20px;
}

.footer-links h5 {
    font-weight: 600;
    margin-bottom: 20px;
}

.footer-links ul {
    list-style: none;
    padding: 0;
}

.footer-links li {
    margin-bottom: 10px;
}

.footer-links ul li {
    font-size: 0.9rem;
    line-height: 1.5;
}

.footer-links a {
    color: #adb5bd;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: white;
}

.copyright {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    color: #adb5bd;
    font-size: 0.9rem;
}


/* ==========================================================================
   8. Media Queries (Diseño Responsivo)
   ========================================================================== */

@media (max-width: 991.98px) {
    .navbar-brand img {
        height: 50px;
    }

    .hero {
        height: 70vh;
    }
    .hero h1 {
        font-size: 1.7rem;
    }
    .hero h2 {
        font-size: 1.2rem;
    }

    .user-nav-container .nav-links-row {
        flex-wrap: wrap;
    }
    .user-nav-container .nav-link-law {
        font-size: 0.9rem;
        padding: 5px 10px;
        min-width: 120px;
    }
}

@media (max-width: 768px) {
    .funciones-list {
        column-count: 1;
    }
}

/* ==========================================================================
   9. Estilos Personalizados para Modales
   ========================================================================== */

.modal-header .modal-title {
    width: 100%;
    text-align: center;
    color: var(--primary-color); /* Usa el color azul principal */
    font-weight: 600; /* Le da un poco más de grosor al texto */
}

/* Opcional: Centra el botón de cerrar si es necesario */
.modal-header .btn-close {
    position: absolute;
    right: 1rem;
    top: 1rem;
}

/* === Corrección visual: deja siempre espacio debajo del menú === */
.page-ldaf #loaded-content {
    padding-top: 60px; /* Aumentá este valor si sigue tapado */
}
