/* Organigrama Estructurado - Inspirado en Talca */

:root {
    --primary: #1565c0;
    --primary-dark: #1565c0;
    --primary-light: #ff5722;
    --secondary: #1976d2;
    --success: #388e3c;
    --background: #ffffff;
    --surface: #f8f9fa;
    --border: #e0e0e0;
    --text: #212121;
    --text-light: #757575;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 8px rgba(0, 0, 0, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background: #f5f5f5;
    color: var(--text);
    line-height: 1.4;
    min-height: 100vh;
}

/* Contenedor principal */
.organigrama-container {
    max-width: 1400px;
    margin: 20px auto;
    padding: 30px;
    min-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

/* Header */
.organigrama-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 25px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 10px;
    border: none;
    color: white;
    box-shadow: 0 4px 15px rgba(211, 47, 47, 0.3);
}

.organigrama-title {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.organigrama-subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    font-weight: 500;
}

/* Controles */
.organigrama-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.search-container {
    position: relative;
    max-width: 350px;
    width: 100%;
}

.search-box {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
    background: var(--background);
}

.search-box:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
}

.control-btn {
    padding: 12px 20px;
    border: 2px solid var(--secondary);
    border-radius: 6px;
    background: var(--secondary);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-btn:hover {
    background: #1565c0;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* Estadísticas */
.stats-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.stat-item {
    background: var(--secondary);
    color: white;
    border-radius: 8px;
    padding: 15px 25px;
    text-align: center;
    min-width: 100px;
    box-shadow: var(--shadow);
    border: 2px solid var(--secondary);
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

/* Grid principal */
.organigrama-grid {
    display: flex;
    flex-direction: column;
    gap: 25px;
    flex: 1;
}

/* Niveles organizados */
.nivel {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    position: relative;
}

.nivel-1 {
    margin-bottom: 20px;
}

.nivel-2 {
    gap: 40px;
    margin-bottom: 20px;
}

.nivel-3 {
    margin-bottom: 20px;
}

.nivel-4 {
    gap: 30px;
    margin-bottom: 20px;
}

.nivel-5 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.nivel-6 {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

/* Cargos estilo Talca */
.cargo {
    background: var(--secondary);
    color: white;
    border: 2px solid var(--secondary);
    border-radius: 8px;
    padding: 15px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 180px;
    max-width: 220px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

/* Flecha removida - comentada para referencia */
/*
.cargo::after {
    content: '>';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    font-weight: bold;
    opacity: 0.8;
}
*/

.cargo:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    background: #1565c0;
}

/* Variantes de cargos */
.cargo-principal {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    min-width: 200px;
    max-width: 250px;
    padding: 20px 25px;
}

.cargo-principal:hover {
    background: var(--primary);
}

.cargo-secundario {
    background: var(--secondary);
    border-color: var(--secondary);
}

.cargo-secundario:hover {
    background: #1565c0;
}

.cargo-departamento {
    background: var(--secondary);
    border-color: var(--secondary);
}

.cargo-departamento:hover {
    background: #1565c0;
}

/* Iconos */
.cargo-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
    opacity: 0.9;
}

/* Texto */
.cargo-text h4,
.cargo-text h5 {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0 0 5px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.cargo-text p {
    font-size: 0.8rem;
    margin: 0;
    opacity: 0.9;
    line-height: 1.3;
}

/* Departamentos */
.departamento {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* Sub-departamentos */
.sub-departamentos {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    margin-top: 8px;
}

.sub-depto {
    background: var(--success);
    color: white;
    border: 1px solid var(--success);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.sub-depto:hover {
    background: #2e7d32;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Líneas de conexión */
.nivel::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 15%;
    right: 15%;
    height: 2px;
    background: var(--border);
    z-index: -1;
}

.nivel-1::before {
    display: none;
}

.nivel-2::before {
    top: 100%;
    left: 20%;
    right: 20%;
}

.nivel-3::before {
    top: 100%;
    left: 30%;
    right: 30%;
}

.nivel-4::before {
    top: 100%;
    left: 25%;
    right: 25%;
}

/* Líneas verticales de conexión */
.nivel-1::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 20px;
    background: var(--border);
}

.nivel-2::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 20px;
    background: var(--border);
}

.nivel-3::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 20px;
    background: var(--border);
}

/* Animaciones */
@keyframes fadeInUp {
    from { 
        opacity: 0; 
        transform: translateY(30px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.cargo {
    animation: fadeInUp 0.5s ease forwards;
}

.nivel-1 .cargo { animation-delay: 0.1s; }
.nivel-2 .cargo { animation-delay: 0.2s; }
.nivel-3 .cargo { animation-delay: 0.3s; }
.nivel-4 .cargo { animation-delay: 0.4s; }
.nivel-5 .cargo { animation-delay: 0.5s; }
.nivel-6 .cargo { animation-delay: 0.6s; }

/* ===== MODALES MODERNOS ===== */

/* Modal Base */
.modern-modal {
    border: none;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header del Modal */
.modern-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    padding: 0;
    position: relative;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    width: 100%;
}

.modal-title {
    color: white;
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.municipality-logo {
    display: flex;
    align-items: center;
}

.logo-img {
    height: 50px;
    width: auto;
    filter: brightness(0) invert(1);
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Tabs de Navegación */
.modal-tabs {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.modern-tabs {
    border: none;
    margin: 0;
    padding: 0 20px;
}

.modern-tabs .nav-item {
    margin: 0;
}

.modern-tabs .nav-link {
    border: none;
    border-radius: 0;
    padding: 15px 20px;
    color: var(--text-light);
    font-weight: 600;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modern-tabs .nav-link i {
    font-size: 1rem;
}

.modern-tabs .nav-link.active {
    color: var(--primary);
    background: white;
    border-bottom: 3px solid var(--primary);
}

.modern-tabs .nav-link:hover {
    color: var(--primary);
    background: rgba(21, 101, 192, 0.05);
}

/* Cuerpo del Modal */
.modern-body {
    padding: 30px;
    background: white;
}

/* Contenido del Alcalde */
.alcalde-content {
    padding: 0;
}

.alcalde-info {
    padding-right: 30px;
}

.alcalde-title {
    color: var(--primary);
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.alcalde-name {
    color: var(--text);
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.2;
}

.alcalde-profession {
    color: var(--text-light);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 25px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.alcalde-description {
    color: var(--text);
    line-height: 1.6;
}

.alcalde-description p {
    margin-bottom: 15px;
    text-align: justify;
}

.alcalde-photo {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.photo-img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Contenido de Funciones */
.funciones-content {
    padding: 0;
}

.funciones-title {
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 25px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.funciones-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.funciones-list li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    line-height: 1.5;
    position: relative;
    padding-left: 25px;
}

.funciones-list li:before {
    content: '•';
    color: var(--primary);
    font-weight: bold;
    font-size: 1.2rem;
    position: absolute;
    left: 0;
    top: 12px;
}

.funciones-list li:last-child {
    border-bottom: none;
}

/* Responsive */
@media (max-width: 1200px) {
    .organigrama-container {
        padding: 20px;
        margin: 15px;
    }
    
    .nivel-5 {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .organigrama-container {
        padding: 15px;
        margin: 10px;
    }
    
    .organigrama-title {
        font-size: 1.6rem;
    }
    
    .nivel {
        gap: 15px;
    }
    
    .nivel-2 {
        gap: 25px;
    }
    
    .nivel-4 {
        gap: 20px;
    }
    
    .cargo {
        min-width: 150px;
        max-width: 180px;
        padding: 12px 15px;
    }
    
    .cargo-principal {
        min-width: 170px;
        max-width: 200px;
        padding: 15px 20px;
    }
    
    .nivel-5 {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
    }
    
    .stats-container {
        gap: 15px;
    }
    
    .stat-item {
        padding: 12px 20px;
        min-width: 80px;
    }

    /* Modal Responsive */
    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .modal-title {
        font-size: 1.5rem;
    }

    .modern-body {
        padding: 20px;
    }

    .alcalde-info {
        padding-right: 0;
        margin-bottom: 20px;
    }

    .alcalde-name {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .organigrama-container {
        padding: 12px;
        margin: 5px;
        border-radius: 8px;
    }
    
    .nivel {
        flex-direction: column;
        gap: 10px;
    }
    
    .nivel-2, .nivel-4 {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .cargo {
        min-width: 120px;
        max-width: 150px;
        padding: 10px 12px;
    }
    
    .cargo-text h4,
    .cargo-text h5 {
        font-size: 0.8rem;
    }
    
    .cargo-text p {
        font-size: 0.7rem;
    }
    
    .sub-depto {
        font-size: 0.6rem;
        padding: 3px 6px;
    }
    
    .nivel-5 {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Modal Responsive */
    .modern-body {
        padding: 15px;
    }

    .alcalde-name {
        font-size: 1.3rem;
    }

    .funciones-list li {
        padding: 10px 0;
        padding-left: 20px;
    }
}

/* Modo oscuro - Deshabilitado para mantener fondo blanco */
/*
@media (prefers-color-scheme: dark) {
    :root {
        --background: #121212;
        --surface: #1e1e1e;
        --border: #333333;
        --text: #ffffff;
        --text-light: #b0b0b0;
    }
}
*/

/* Accesibilidad */
.cargo:focus {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Impresión */
    @media print {
        .organigrama-controls {
            display: none;
        }
        
        .cargo {
            break-inside: avoid;
            box-shadow: none;
            border: 2px solid #000;
            color: #000;
            background: #fff;
        }
        
        /* Flecha ya removida */
    }

    /* Modal Backdrop */
    .modal-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1040;
    }

    .modal-backdrop.fade {
        opacity: 0;
        transition: opacity 0.15s linear;
    }

    .modal-backdrop.show {
        opacity: 1;
    }

    .modal-open {
        overflow: hidden;
    }

    .modal.show {
        display: block !important;
    }

    /* Asegurar que los modales estén por encima de todo */
    .modal {
        z-index: 1050 !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        outline: 0 !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    .modal-dialog {
        position: relative !important;
        width: auto !important;
        margin: 0.5rem !important;
        pointer-events: none !important;
    }

    @media (min-width: 576px) {
        .modal-dialog {
            max-width: 500px !important;
            margin: 1.75rem auto !important;
        }
    }

    @media (min-width: 992px) {
        .modal-dialog {
            max-width: 800px !important;
        }
    }

    .modal-content {
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        pointer-events: auto !important;
        background-color: #fff !important;
        background-clip: padding-box !important;
        border: 1px solid rgba(0, 0, 0, 0.2) !important;
        border-radius: 0.3rem !important;
        outline: 0 !important;
        box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.5) !important;
    }

    /* Mejorar accesibilidad de modales */
    .modal:focus {
        outline: 2px solid var(--primary) !important;
        outline-offset: 2px !important;
    }

    .modal.show {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Asegurar que los botones de cierre sean accesibles */
    .close, .close-btn {
        cursor: pointer !important;
        border: none !important;
        background: transparent !important;
        font-size: 1.5rem !important;
        line-height: 1 !important;
        padding: 0.5rem !important;
        margin: -0.5rem -0.5rem -0.5rem auto !important;
        opacity: 0.5 !important;
        transition: opacity 0.15s !important;
    }

    .close:hover, .close-btn:hover {
        opacity: 1 !important;
    }

    /* Mejorar contraste para accesibilidad */
    .modal-body {
        color: #333 !important;
        background: #fff !important;
    }

