/* Definición de Variables CSS */
:root {
    --primary-color: rgb(0, 179, 104); /* Azul oscuro similar al teal */
    --secondary-color: #00796b; /* Verde teal */
    --accent-color: #80cbc4; /* Teal claro / aguamarina */
    --light-bg: #f4f7f6; /* Fondo claro */
    --white: #fff;
    --dark-text: #333;
    --light-text: #e0f2f1; /* Texto claro */
    --shadow: rgba(0, 0, 0, 0.1);
    --border-radius-card: 8px;
    --border-radius-btn: 5px;
}

/* General Body and Typography */
body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    background-color: var(--light-bg);
    color: var(--dark-text);
    line-height: 1.6;
}

.container {
    max-width: 1280px; /* Ajustado para más espacio */
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 15px 0;
    box-shadow: 0 2px 8px var(--shadow);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.logo {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.8rem;
    margin: 0;
    font-weight: 700;
    color: var(--light-text);
}

/* Navigation */
.nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

.nav li {
    margin: 0 15px;
}

.nav a {
    color: var(--light-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 5px 0;
    position: relative;
    transition: color 0.3s ease;
}

.nav a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background-color: var(--accent-color);
    transition: width 0.3s ease;
}

.nav a:hover,
.nav a.active {
    color: var(--accent-color);
}

.nav a:hover::after,
.nav a.active::after {
    width: 100%;
}

.map-indicator {
    font-size: 0.8em;
    vertical-align: super;
    margin-left: 3px;
    color: var(--accent-color);
}

/* Admin Link */
.admin-link {
    background-color: var(--secondary-color);
    color: var(--white);
    padding: 8px 15px;
    border-radius: var(--border-radius-btn);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.admin-link:hover {
    background-color: #004d40;
}

/* Main Content Layout */
.main-content {
    display: flex;
    flex-direction: column; /* Apila las secciones verticalmente: top-section y luego chart */
    gap: 30px; /* Espacio entre la top-section y la gráfica */
    padding: 30px 0;
}

.top-section {
    display: flex;
    flex-wrap: wrap; /* Permite que los paneles se envuelvan */
    gap: 30px; /* Espacio entre map-panel y data-panel */
    width: 100%; /* Ocupa todo el ancho del main-content */
    align-items: flex-start; /* Alinea los paneles en la parte superior */
}

.map-panel, .data-panel {
    background-color: var(--white);
    padding: 25px;
    border-radius: var(--border-radius-card);
    box-shadow: 0 4px 12px var(--shadow);
    box-sizing: border-box; /* Incluir padding en el ancho */
}

.map-panel {
    flex: 2; /* El panel del mapa toma 2 partes del espacio */
    min-width: 400px; /* Ancho mínimo para el mapa */
    display: flex;
    flex-direction: column;
}

.data-panel {
    flex: 3; /* El panel de datos toma 3 partes del espacio */
    min-width: 450px; /* Ancho mínimo para la tabla */
    max-height: 700px; /* Ajustar según la altura del mapa para que queden alineados */
    overflow-y: auto; /* Permite scroll vertical para la tabla si es muy larga */
}


/* Títulos de Paneles */
.data-panel h2, .map-panel h3 {
    font-family: 'Montserrat', sans-serif;
    color: #004d40; /* Usar un color más específico para títulos */
    font-size: 1.7rem;
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--light-text);
    padding-bottom: 10px;
}

.map-panel p {
    font-size: 0.95rem;
    color: #555;
    margin-bottom: 20px;
}

/* Download Buttons */
.download-options {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    justify-content: center; /* Centrar botones */
}

.download-btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--border-radius-btn);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background-color 0.3s ease, transform 0.2s ease;
    text-align: center;
}

.excel-btn {
    background-color: #28a745; /* Green for Excel */
    color: var(--white);
}

.excel-btn:hover {
    background-color: #218838;
    transform: translateY(-2px);
}

.csv-btn {
    background-color: #17a2b8; /* Cyan for CSV */
    color: var(--white);
}

.csv-btn:hover {
    background-color: #138496;
    transform: translateY(-2px);
}

/* Excel Display Table */
.excel-content-display {
    overflow-x: auto; /* Allow horizontal scrolling for wide tables */
    margin-top: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    background-color: #fdfdfd;
}

.excel-display-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 0.9rem;
}

.excel-display-table th,
.excel-display-table td {
    border: 1px solid #eee;
    padding: 12px 15px;
    text-align: left;
    white-space: nowrap; /* Prevent text wrapping in cells */
}

.excel-display-table th {
    background-color: #e0f2f1; /* Light teal for headers */
    color: #004d40;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    position: sticky; /* Fixed header */
    top: 0;
    z-index: 1; /* Asegura que el encabezado esté sobre el contenido al hacer scroll */
}

.excel-display-table tbody tr:nth-child(even) {
    background-color: #f8fcfc;
}

.excel-display-table tbody tr:hover {
    background-color: #e6f7f6;
}

.row-info {
    font-size: 0.9rem;
    color: #666;
    text-align: right;
    margin-bottom: 10px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 30px;
    padding: 10px 0;
    border-top: 1px solid #eee;
}

.page-link {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #b2dfdb;
    border-radius: var(--border-radius-btn);
    text-decoration: none;
    color: #004d40;
    background-color: var(--white);
    transition: all 0.3s ease;
    font-size: 0.9rem;
    min-width: 40px;
    text-align: center;
}

.page-link:hover {
    background-color: #e0f2f1;
    border-color: #004d40;
    color: #004d40;
}

.page-link.active {
    background-color: #004d40;
    color: var(--white);
    border-color: #004d40;
    font-weight: 600;
    pointer-events: none;
}

.info-message {
    padding: 20px;
    background-color: #e0f7fa;
    border-left: 5px solid #00acc1;
    color: #004d40;
    border-radius: var(--border-radius-btn);
    margin-top: 20px;
    font-size: 1rem;
}

/* Map Panel */
#map {
    height: 450px; /* Altura fija para el mapa */
    width: 100%;
    border-radius: 6px;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.05);
    background-color: #f0f0f0;
    border: 1px solid #ddd; /* Asegura un borde visible */
    flex-grow: 1; /* Permite que el mapa crezca dentro de su contenedor flex */
}

/* Chart Container Card */
.chart-container-card {
    background-color: var(--white);
    border-radius: var(--border-radius-card);
    box-shadow: 0 4px 12px var(--shadow);
    padding: 25px;
    width: 100%; /* Ocupa todo el ancho disponible */
    height: 450px; /* Altura fija para la tarjeta de la gráfica */
    display: flex;
    flex-direction: column; /* Organiza el título y el canvas verticalmente */
    justify-content: flex-start; /* Alinea elementos al inicio */
    align-items: center; /* Centra horizontalmente el contenido si es más estrecho */
}

.chart-container-card h4 { /* Cambié h3 a h4 según tu HTML */
    color: #004d40;
    font-family: 'Montserrat', sans-serif; /* Usar Montserrat para headings */
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
}

#myChart {
    max-width: 100% !important;
    height: 350px !important; /* Altura fija para el canvas de la gráfica */
    width: 100% !important;
    display: block;
    box-sizing: border-box;
}

/* Footer */
.footer {
    background-color: rgb(0, 179, 104);
    color: var(--light-bg);
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
    font-size: 0.85rem;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .top-section {
        flex-direction: column; /* Apila los paneles verticalmente */
        align-items: center; /* Centra los paneles apilados */
    }

    .map-panel, .data-panel {
        min-width: unset; /* Elimina min-width para más flexibilidad */
        width: 100%; /* Ocupan todo el ancho disponible */
        max-height: unset; /* Permitir que el panel de datos se expanda */
    }

    #map {
        height: 350px; /* Ajuste para pantallas más pequeñas */
    }

    .chart-container-card {
        height: 400px; /* Ajuste para pantallas más pequeñas */
    }

    #myChart {
        height: 300px !important; /* Ajuste para pantallas más pequeñas */
    }

    .header .container {
        flex-direction: column;
        gap: 15px;
    }

    .nav ul {
        width: 100%;
        justify-content: center;
        gap: 10px;
    }

    .nav li {
        margin: 0 8px;
    }

    .admin-link {
        margin-top: 10px;
    }
}

@media (max-width: 576px) {
    .logo {
        font-size: 1.5rem;
    }

    .nav a {
        font-size: 0.85rem;
        padding: 3px 0;
    }

    .download-options {
        flex-direction: column;
        align-items: stretch;
    }

    .excel-display-table th,
    .excel-display-table td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
}
/* Footer Styles */
footer {
    background-color: rgb(0, 179, 104); /* El color de fondo azul oscuro que define tu diseño */
    color: white; /* Color del texto blanco */
    text-align: center; /* Centra el texto */
    padding: 20px; /* Espaciado interno */
    font-size: 0.9rem; /* Tamaño de fuente ligeramente más pequeño */
    margin-top: 60px; /* Margen superior para separarlo del contenido principal */
}
/* --- START OF SPIN EFFECT STYLES --- */

.map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    padding: 20px 0;
}

.map-card-spin {
    width: 300px;
    height: 350px; /* Adjust height as needed for content + image */
    position: relative;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    overflow: hidden; /* Ensures content stays within rounded corners */
    transition: box-shadow 0.3s ease;
    cursor: pointer;
    background-color: #fff; /* Fallback background */
}

.map-card-spin:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.map-card-content {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d; /* Essential for 3D transforms */
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1); /* Smooth spinning transition */
}

/* Initial state: No rotation */
.map-card-spin:hover .map-card-content {
    transform: rotateY(15deg); /* A slight spin on hover */
}

.map-main-image {
    width: 100%;
    height: 100%; /* Image fills the entire card */
    object-fit: cover; /* Cover the area, cropping if necessary */
    display: block;
    border-radius: 8px; /* Rounded corners for the image */
    backface-visibility: hidden; /* Hides the back of the image during spin */
    position: absolute; /* Allows info to overlay */
    top: 0;
    left: 0;
}

.map-info-spin {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    box-sizing: border-box;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%); /* Gradient for subtle overlay */
    color: #fff;
    text-align: left;
    transform: translateY(100%); /* Start hidden below the card */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1); /* Smooth slide-up transition */
    border-radius: 0 0 8px 8px;
    z-index: 1; /* Ensure text is above image */
    /* Adjust text styles for readability */
    opacity: 0; /* Initially invisible */
}

/* When hovering, reveal info and slightly spin the card */
.map-card-spin:hover .map-info-spin {
    transform: translateY(0); /* Slide up to be visible */
    opacity: 1; /* Fully visible */
}

.map-info-spin h3 {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 1.2rem;
    color: #fff;
}

.map-info-spin p {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.4;
}

.map-info-spin strong {
    color: #add8e6; /* Light blue for strong text */
}

/* Adjust general elements to fit the new design if needed */
.no-maps {
    text-align: center;
    font-size: 1.2rem;
    color: #59df6b;
    padding: 50px;
    background-color: #f5f5f5;
    border-radius: 8px;
    border: 1px dashed #ddd;
    grid-column: 1 / -1; /* Make it span all columns in the grid */
}

.back-link {
    display: block;
    text-align: center;
    margin-top: 30px;
    font-size: 1.1rem;
    color: #007bff;
    text-decoration: none;
    transition: color 0.3s ease;
}
.back-link:hover {
    color: #0056b3;
    text-decoration: underline;
}
/* --- END OF SPIN EFFECT STYLES --- */
