/* =====================================================
   mapa.css - Monitor de Viviendas Turísticas (pisos1)
   Tema oscuro premium con acentos coral/naranja
   ===================================================== */

:root {
    --bg-dark: #0d1117;
    --bg-panel: rgba(22, 27, 34, 0.97);
    --bg-card: rgba(30, 36, 46, 0.95);
    --accent1: #ff6b35;
    --accent2: #f7c59f;
    --accent3: #4ecdc4;
    --text-primary: #e6edf3;
    --text-muted: #8b949e;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    --radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* =========== MAPA =========== */
#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* =========== PANEL CONTROL =========== */
.control-panel {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 310px;
    max-height: calc(100vh - 30px);
    overflow-y: auto;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    z-index: 1000;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    scrollbar-width: thin;
    scrollbar-color: var(--accent1) transparent;
}

.control-panel::-webkit-scrollbar {
    width: 4px;
}

.control-panel::-webkit-scrollbar-track {
    background: transparent;
}

.control-panel::-webkit-scrollbar-thumb {
    background: var(--accent1);
    border-radius: 2px;
}

/* Header */
.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.panel-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--accent1), #ff8c42);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.panel-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.panel-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Selects */
.selector-group {
    margin-bottom: 10px;
}

.selector-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.sel-custom {
    width: 100%;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%238b949e'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.sel-custom:focus {
    outline: none;
    border-color: var(--accent1);
}

.sel-custom:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sel-custom option {
    background: #1e2432;
}

/* Divisor */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

/* Mode switch */
.mode-switch {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.mode-btn {
    flex: 1;
    padding: 7px 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.mode-btn:hover {
    border-color: var(--accent1);
    color: var(--text-primary);
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--accent1), #ff8c42);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 3px 12px rgba(255, 107, 53, 0.4);
}

/* Selector de indicador */
.indicator-select {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 12px;
}

.ind-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 11px;
    color: var(--text-muted);
}

.ind-btn:hover {
    border-color: var(--accent1);
    color: var(--text-primary);
}

.ind-btn.active {
    border-color: var(--accent1);
    background: rgba(255, 107, 53, 0.12);
    color: var(--text-primary);
}

.ind-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Leyenda */
.legend-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 12px;
}

.legend-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}

.legend-gradient {
    height: 10px;
    border-radius: 5px;
    margin-bottom: 4px;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
}

/* KPIs del municipio */
.kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 12px;
}

.kpi-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    text-align: center;
}

.kpi-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent1);
    line-height: 1.2;
}

.kpi-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

/* Stats panel */
#stats-panel {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-top: 2px;
}

.stats-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent1);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 5px;
    margin-bottom: 10px;
}

.stat-item {
    text-align: center;
    padding: 6px 4px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
}

.stat-val {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-lbl {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.variation-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
}

.var-up {
    background: rgba(231, 76, 60, 0.18);
    color: #e74c3c;
}

.var-down {
    background: rgba(39, 174, 96, 0.18);
    color: #27ae60;
}

.var-neutral {
    background: rgba(149, 165, 166, 0.18);
    color: #95a5a6;
}

.rank-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
}

.rank-row:last-child {
    border-bottom: none;
}

/* Chart */
.chart-wrapper {
    height: 130px;
    position: relative;
}

/* Btn ayuda */
.btn-help {
    width: 100%;
    padding: 7px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-help:hover {
    border-color: var(--accent3);
    color: var(--accent3);
}

/* ========== CONTROLES DE MAPA (opacidad + toggle) ========== */
.map-controls-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 4px;
}

.opacity-control {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.opacity-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.opacity-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 4px;
    background: linear-gradient(to right, var(--accent1), var(--accent1)) no-repeat, rgba(255, 255, 255, 0.1);
    background-size: 70% 100%;
    border-radius: 2px;
    cursor: pointer;
    border: none;
    outline: none;
    padding: 0;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--accent1);
    cursor: pointer;
    box-shadow: 0 0 4px rgba(255, 107, 53, 0.5);
}

.opacity-val {
    font-size: 10px;
    color: var(--accent1);
    font-weight: 700;
    min-width: 30px;
    text-align: right;
}

.btn-basemap {
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    padding: 0;
}

.btn-basemap:hover {
    border-color: var(--accent1);
    background: rgba(255, 107, 53, 0.12);
}


/* ========== TOOLTIP LEAFLET ========== */
.leaflet-tooltip {
    background: rgba(13, 17, 23, 0.92) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    border-radius: 7px !important;
    font-size: 12px !important;
    padding: 6px 10px !important;
    backdrop-filter: blur(6px);
}

/* ========== MODAL ========== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 540px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent1);
}

.modal-close {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(255, 107, 53, 0.2);
    color: var(--accent1);
}

.modal-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

.modal-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

.modal-card h6 {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--accent1);
}

.modal-card p,
.modal-card ul {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
}

.modal-card ul {
    padding-left: 14px;
}

.modal-card li {
    margin-bottom: 3px;
}

/* Loading spinner */
.loading-overlay {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 22px;
    z-index: 2000;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Spinner */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent1);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
.control-panel{max-width:calc(100vw - 30px)}
#history-table th,#history-table td{padding:5px;border-bottom:1px solid var(--border);text-align:right}#history-table th:first-child,#history-table td:first-child{text-align:left}
.ind-btn:focus-visible,select:focus-visible,a:focus-visible,summary:focus-visible{outline:2px solid var(--accent2);outline-offset:2px}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}
