/* Estilos Generales */
html, body {
    height: 100%; /* Asegura que html y body ocupen toda la altura disponible */
    margin: 0 !important; /* Forzar eliminación de margen */
    padding: 0 !important; /* Forzar eliminación de padding */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
}

main {
    background-color: #ffffff;
    padding: 25px; 
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    text-align: center;
    width: 100%; /* Asegura que ocupe todo el ancho disponible */
    box-sizing: border-box; /* Incluye padding y border en el ancho/alto */
}

h1 {
    color: #1c6fb1;
    font-size: 2.5em;
    margin-bottom: 20px;
    margin-top: 0; /* Asegura que no haya margen superior en h1 */
    font-weight: 600;
}

/* Estilos para el Banner de Cabecera */
.header-banner {
    background: linear-gradient(135deg, #1c6fb1 0%, #2596be 100%);
    color: #ffffff;
    padding: 30px 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

.header-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 70%);
    transform: rotate(45deg);
    animation: subtle-shine 5s infinite linear;
}

@keyframes subtle-shine {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.header-banner h1 {
    color: #ffffff;
    font-size: 2.8em;
    margin: 0 0 10px 0;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.header-banner p {
    font-size: 1.1em;
    margin: 0;
    opacity: 0.9;
}



/* Contenedor principal para mapa y panel de información */
#content-wrapper {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Mapa ocupa 2/3, panel 1/3 */
    gap: 20px;
    max-width: 1200px; /* Ancho máximo para el contenedor */
    margin: 20px auto; /* Centrar el contenedor */
    align-items: stretch; /* Alinea los elementos para que tengan la misma altura */
}

/* Contenedor del Mapa */
#map-container {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    padding: 15px; /* Añadir padding interno */
    background-color: #fdfdfd;
}

#cityList {
    max-height: 520px;
    overflow-y: scroll;
}

#map svg {
    width: 100%;
    height: 550px;
    display: block; /* Elimina espacio extra debajo del SVG */
}

/* Estilos de los Departamentos */
.dept {
    stroke: #ffffff;
    stroke-width: 0.8px;
    transition: fill 0.3s ease, stroke-width 0.3s ease, filter 0.3s ease; /* Añadir filter a la transición */
}

.dept:focus {
  outline: none; /* quita el recuadro negro */
}

.dept--active {
    /* fill color is set dynamically via JavaScript */
    cursor: pointer;
}

.dept--active:hover, .dept--active:focus {
    filter: brightness(1.1); /* Aclara el color al pasar el ratón */
    stroke-width: 1.5px;
}

.dept--disabled {
    fill: #cccccc; /* Gris para deshabilitados */
    cursor: not-allowed;
}

.dept--selected {
    filter: brightness(0.8); /* Oscurece el color cuando está seleccionado */
    stroke: #ffffff;
    stroke-width: 2px;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.3)); /* Sombra sutil */
}

/* Panel de Información (Aside) */
#infoPanel {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    overflow-y: auto; /* Scroll si el contenido es largo */
    max-height: calc(100vh - 40px); /* Limitar altura para que no se salga de la pantalla */
}

#infoPanel h2 {
    color: #1c6fb1;
    font-size: 1.8em;
    margin-top: 0;
    margin-bottom: 15px;
    text-align: center;
}

#infoPanel .instruction-text {
    font-size: 0.9em;
    color: #777;
    margin-bottom: 20px;
    text-align: center;
}

/* Lista de Ciudades (Acordeón) */
.city-item {
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    margin-bottom: 10px;
    overflow: hidden;
}

.city-header {
    background-color: #f8f8f8;
    padding: 12px 15px;
    cursor: pointer;
    font-weight: 600;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.city-header:hover {
    background-color: #f0f0f0;
}

.city-header.active {
    background-color: #1c6fb1;
    color: #ffffff;
}

.city-header .arrow {
    font-size: 1.2em;
    transition: transform 0.2s;
}

.city-header.active .arrow {
    transform: rotate(90deg);
}

.office-content {
    padding: 0 15px; /* Padding horizontal, vertical 0 */
    background-color: #ffffff;
    border-top: 1px solid #eee;
    max-height: 0; /* Oculto por defecto con max-height */
    overflow: hidden; /* Oculta el contenido que se desborda */
    transition: max-height 0.3s ease-out, padding 0.3s ease-out, opacity 0.3s ease-out, visibility 0.3s ease-out; /* Added opacity and visibility to transition */
    opacity: 0; /* Initially invisible */
    visibility: hidden; /* Initially hidden */
    display: block; /* Keep display block for scrollHeight calculation */
}

.office-content.active {
    padding-top: 15px; /* Añadir padding cuando está activo */
    padding-bottom: 15px; /* Añadir padding cuando está activo */
    opacity: 1; /* Visible */
    visibility: visible; /* Visible */
    /* max-height se establecerá en JS */
}

.office-details {
    margin-bottom: 15px; /* Espacio entre oficinas si hay varias */
    padding: 10px; /* Added padding for better spacing */
    border: 1px solid #f0f0f0; /* Subtle border */
    border-radius: 5px; /* Rounded corners */
    background-color: #fdfdfd; /* Slightly different background */
}

.office-details:last-child {
    margin-bottom: 0; /* No hay margen en la última oficina */
}

.office-details h3 {
    color: #1c6fb1;
    font-size: 1.2em;
    margin-top: 0;
    margin-bottom: 10px;
}

.office-details p {
    font-size: 0.95em;
    line-height: 1.5;
    margin-bottom: 8px;
}

.office-details p strong {
    color: #555;
}

.office-details a {
    color: #1c6fb1;
    text-decoration: none;
    transition: color 0.2s;
}

.office-details a:hover {
    text-decoration: underline;
    color: #155a96;
}

.office-details .button {
    margin-top: 15px;
    padding: 8px 15px;
    font-size: 0.9em;
}

.office-separator {
    border: 0;
    height: 1px;
    background-color: #e0e0e0;
    margin: 15px 0;
}

/* Controles (bottom section) */
.controls {
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.instruction-text {
    font-size: 1em;
    color: #555;
    margin-bottom: 10px;
}

.department-display {
    font-size: 1.2em;
    font-weight: 600;
    color: #1c6fb1;
    margin-bottom: 0px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #content-wrapper {
        grid-template-columns: 1fr; /* Stack map and info panel vertically */
        gap: 20px;
    }
    main {
        padding: 15px;
        margin: 0;
        border-radius: 0;
    }
    h1 {
        font-size: 2em;
    }
    #infoPanel {
        max-height: 50vh; /* Adjust max-height for mobile info panel */
    }
    .modal-content {
        padding: 20px;
        max-height: 90vh;
    }
    .modal-content h2 {
        font-size: 1.5em;
    }
    .modal-content p {
        font-size: 1em;
    }
    .button {
        padding: 10px 20px;
        font-size: 1em;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.8em;
    }
    #map-container {
        margin: 20px auto;
    }
    .modal-content {
        width: 95%;
        padding: 15px;
    }
}