/* ═══════════════ GRAFICO.CSS — Página del Gráfico Interactivo ═══════════════ */
/* Paleta: hereda variables de styles.css */

/* ── Page Hero compacto ── */
.page-hero--compact {
    padding: 110px 0 36px;
}

/* ── Controles ── */
.graph-controls {
    padding: 14px 0;
    border-bottom: 1px solid var(--gray-100);
    background: var(--white);
    position: sticky;
    top: 70px;
    z-index: 10;
}
.controls-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.control-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-600);
    white-space: nowrap;
}
.control-select {
    padding: 5px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: var(--font-body);
    color: var(--gray-700);
    background: var(--white);
    cursor: pointer;
    max-width: 200px;
}
.control-select:focus {
    outline: none;
    border-color: var(--verde-pref);
    box-shadow: 0 0 0 2px rgba(26, 86, 50, 0.1);
}
.control-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: var(--white);
    font-size: 0.8rem;
    font-family: var(--font-body);
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.15s;
}
.control-btn:hover {
    border-color: var(--verde-pref);
    color: var(--verde-pref);
}

/* ── Sección del grafo ── */
.graph-section {
    position: relative;
    background: var(--off-white);
}
.graph-wrapper {
    position: relative;
    width: 100%;
    height: calc(100vh - 230px);
    min-height: 500px;
}
.graph-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}
.graph-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--gray-500);
    font-size: 0.9rem;
}
.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--verde-pref);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Zoom hint overlay ── */
.zoom-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 46, 26, 0.85);
    color: var(--white);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 8;
    white-space: nowrap;
}
.zoom-hint--visible {
    opacity: 1;
}

/* ── Controles de zoom flotantes ── */
.zoom-controls {
    position: absolute;
    bottom: 16px;
    left: 16px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.zoom-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--gray-600);
    box-shadow: var(--shadow-sm);
    transition: all 0.15s;
}
.zoom-btn:hover {
    border-color: var(--verde-pref);
    color: var(--verde-pref);
    background: var(--gray-50);
}

/* ── Leyenda flotante ── */
.graph-legend {
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 5;
}
.legend-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--white);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    color: var(--verde-pref);
    transition: all 0.2s;
}
.legend-toggle:hover {
    background: var(--verde-pref);
    color: var(--white);
}
.legend-body {
    position: absolute;
    bottom: 48px;
    right: 0;
    width: 280px;
    background: var(--white);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    padding: 16px;
    display: none;
    max-height: 60vh;
    overflow-y: auto;
}
.legend-body--open {
    display: block;
}
.legend-body h4 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--verde-pref);
    margin: 10px 0 6px;
    font-weight: 700;
}
.legend-body h4:first-child {
    margin-top: 0;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 0.78rem;
    color: var(--gray-700);
}
.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.legend-line {
    width: 20px;
    height: 0;
    border-bottom: 2px dashed;
    flex-shrink: 0;
}
.legend-note {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
    font-size: 0.72rem;
    color: var(--gray-500);
    line-height: 1.5;
}

/* ── Modal Popup ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 46, 26, 0.5);
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal-overlay--open {
    display: flex;
}
.modal {
    background: var(--white);
    border-radius: var(--r-lg);
    max-width: 560px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: modalIn 0.25s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-50);
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}
.modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 24px 0;
    border-left: 4px solid var(--verde-pref);
    margin-left: 20px;
}
.modal-code {
    color: var(--white);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.modal-prio {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 10px;
}
.prio-maxima, .prio-alta { background: var(--oro-pale); color: var(--oro-deep); }
.prio-media { background: #e8f5e9; color: #2e7d32; }
.prio-baja { background: var(--gray-100); color: var(--gray-600); }

.modal-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    color: var(--gray-800);
    padding: 10px 24px 0;
    line-height: 1.3;
}
.modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 24px;
}
.modal-meta span {
    background: var(--gray-50);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.76rem;
    color: var(--gray-600);
    border: 1px solid var(--gray-100);
}
.modal-meta strong {
    color: var(--verde-pref);
}
.modal-body {
    padding: 0 24px 20px;
}
.modal-section {
    margin-bottom: 10px;
}
.modal-section h4 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--verde-pref);
    margin: 0 0 4px;
    font-weight: 700;
}
.modal-section p {
    font-size: 0.84rem;
    color: var(--gray-700);
    line-height: 1.5;
    margin: 0;
}
.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.modal-tag {
    background: var(--gray-50);
    color: var(--verde-pref);
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
    border: 1px solid var(--gray-100);
}
.modal-tag--red {
    background: rgba(198, 160, 48, 0.1);
    color: var(--oro-deep);
    border-color: rgba(198, 160, 48, 0.2);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .graph-wrapper {
        height: calc(100vh - 280px);
        min-height: 400px;
    }
    .controls-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .graph-controls {
        top: 60px;
    }
    .graph-legend {
        bottom: 10px;
        right: 10px;
    }
    .zoom-controls {
        bottom: 10px;
        left: 10px;
    }
    .zoom-hint {
        font-size: 0.72rem;
        padding: 8px 14px;
    }
    .legend-body {
        width: 240px;
    }
    .modal {
        max-width: 100%;
        max-height: 90vh;
    }
}
