/* modal.css */

/* Overlay y Modal Base */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 35, 126, 0.2);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px 0;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.final-results-modal {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 900px;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 48px -12px rgba(26, 35, 126, 0.18);
}

.final-results-modal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Header */
.modal-header {
    background: linear-gradient(135deg, #1a237e, #0d47a1);
    color: white;
    padding: 1.5rem 2rem;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    position: sticky;
    top: 0;
    z-index: 2;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-title svg {
    width: 24px;
    height: 24px;
}

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

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* Content */
.modal-content {
    padding: 2rem;
}

.report-section {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.section-title {
    color: #1a237e;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 1.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-title svg {
    width: 20px;  /* Ajustado el tamaño de los iconos */
    height: 20px;
    stroke: currentColor;
}

/* Gini Section */
/* Estilos para la sección del coeficiente de Gini */
.gini-section {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.gini-meter {
    margin: 1.5rem 0;
}

.gini-value {
    font-size: 2rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 1rem;
}

/* Contenedor de la barra de medición */
.gini-gauge {
    position: relative;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    margin: 2rem 0 1.5rem; /* Aumentado el margen superior e inferior */
}

.gauge-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Etiquetas de la escala */
.gini-labels {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-top: -0.75rem; /* Ajustado para acercar al gauge */
}

/* Contenedor para cada extremo de la escala */
.gini-label-end {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    width: 80px; /* Ancho fijo para mejor control */
}

.gini-label-end::before {
    content: '';
    width: 2px;
    height: 6px;
    background: #666;
    margin-bottom: 0.5rem;
}

.gini-label-end span {
    font-size: 0.75rem;
    color: #666;
    text-align: center;
    white-space: nowrap;
}

/* Específico para cada extremo */
.gini-label-start {
    align-items: flex-start;
}

.gini-label-end {
    align-items: flex-end;
}

.inequality-level {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: #666;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
}

/* Distribution Bars */
.stacked-bars {
    margin: 1.5rem 0;
}

.bar-group {
    margin-bottom: 1rem;
}

.bar-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.stacked-bar {
    height: 24px;
    display: flex;
    border-radius: 6px;
    overflow: hidden;
}

.bar-segment {
    height: 100%;
    transition: width 0.5s ease;
}

.bar-segment.rich { background: rgba(39, 174, 96, 0.8); }
.bar-segment.middle { background: rgba(52, 152, 219, 0.8); }
.bar-segment.poor { background: rgba(231, 76, 60, 0.8); }

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.metric-card {
    background: white;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.metric-card h4 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.metric-values {
    display: grid;
    gap: 0.75rem;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.metric-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.metric-label {
    color: #666;
    font-size: 0.9rem;
}

.metric-value {
    font-weight: 600;
    color: #2c3e50;
}

/* Analysis Content */
.analysis-content {
    line-height: 1.6;
    color: #2c3e50;
    font-size: 0.95rem;
}

/* Comparison Scale */

/* Estilos para la sección de comparación internacional */
/* Añadir o actualizar en modal.css */

/* Contenedor principal de la sección de comparación */
.comparison-section {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Ajuste del título para mantener consistencia */
.comparison-section .section-title {
    color: #1a237e;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 1.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.comparison-section .section-title svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* Ajuste del contenedor de la escala */
.comparison-scale {
    position: relative;
    padding: 2rem;
    margin: 1.5rem 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Ajuste del análisis de comparación */
.comparison-analysis {
    margin-top: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.comparison-analysis p {
    color: #2c3e50;
    line-height: 1.6;
    margin: 0;
}

.scale-bar {
    position: relative;
    height: 4px;
    background: linear-gradient(to right, #27ae60, #f1c40f, #e74c3c);
    border-radius: 2px;
    margin: 2rem 0;
}


/* Etiqueta de simulación */
.simulation-label {
    position: absolute;
    width: 100%;
    text-align: center;
    color: #e74c3c;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 0.5rem;
    white-space: nowrap;
    transform: translateX(-50%);
    left: 50%;
}

/* Marcadores más compactos */
.country-marker {
    position: absolute;
    transform: translateX(-50%);
    cursor: pointer;
}

.marker-dot {
    width: 8px;
    height: 8px;
    background: #34495e;
    border-radius: 50%;
    display: block;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

/* Tooltip mejorado */

.simulation-marker .marker-tooltip {
    bottom: calc(100% + 10px);
}


.marker-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: #2c3e50;
    color: white;
    padding: 0.5rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    white-space: nowrap;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    pointer-events: none;
}

.marker-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 4px;
    border-style: solid;
    border-color: #2c3e50 transparent transparent transparent;
}

/* Efecto hover en los marcadores */
.country-marker:hover .marker-dot {
    transform: scale(1.5);
    background: #2c3e50;
}



.country-marker:hover .marker-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-4px);
}

.simulation-marker {
    position: absolute;
    transform: translateX(-50%);
    bottom: -32px;  /* Ajustado para dar espacio a la etiqueta */
    text-align: center;
}

.marker-dot.current {
    width: 12px;
    height: 12px;
    background: #e74c3c;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #e74c3c;
    margin: 0 auto;
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

/* Etiquetas de los extremos de la escala */
.scale-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
    font-size: 0.75rem;
    color: #666;
}

/* Contenedor de la leyenda */
.scale-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #666;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Buttons */
.export-button,
.restart-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0.5rem;
    color: white;
    font-size: 0.95rem;
}

.export-button svg,
.restart-button svg {
    width: 18px;  /* Ajustado el tamaño de los iconos de los botones */
    height: 18px;
}

.export-button {
    background: #27ae60;
}

.restart-button {
    background: #3498db;
}

.export-button:hover,
.restart-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Scrollbar */
.final-results-modal::-webkit-scrollbar {
    width: 8px;
}

.final-results-modal::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.final-results-modal::-webkit-scrollbar-thumb {
    background: #c5cae9;
    border-radius: 4px;
}

.final-results-modal::-webkit-scrollbar-thumb:hover {
    background: #9fa8da;
}

/* Responsive */
@media (max-width: 768px) {
    .final-results-modal {
        width: 95%;
        margin: 10px;
    }

    .modal-content {
        padding: 1rem;
    }

    .section-title {
        font-size: 1.1rem;
    }

    .gini-value {
        font-size: 2rem;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .export-button,
    .restart-button {
        width: 100%;
        margin: 0.5rem 0;
    }

    .country-name {
        font-size: 0.7rem;
    }
}