/* ==========================================================================
   Planificación España - Hojas de Estilo Premium
   ========================================================================== */

/* --- Importación de Fuentes Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --bg-main: #f0f4f8;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --card-bg: rgba(255, 255, 255, 0.9);
    --card-border: rgba(226, 232, 240, 0.8);
    --sgs-red: #E30613;
    --sgs-red-hover: #b8050f;
    --shadow-premium: 0 10px 30px -5px rgba(0, 0, 0, 0.05), 0 4px 12px -2px rgba(0, 0, 0, 0.03);
    --shadow-inset: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition-smooth: all 0.08s ease-out;
}

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

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Se controlará de forma responsiva en #app-container */
}

h1, h2, h3, h4 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* ==========================================================================
   1. Pantalla de Inicio de Sesión (Login Portal)
   ========================================================================== */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-main);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.login-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1), 0 0 1px 1px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 440px;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.login-logo-img {
    height: 60px;
    margin-bottom: 20px;
    object-fit: contain;
}

.header-logo-img {
    height: 64px;
    object-fit: contain;
    margin-right: 8px;
    transition: var(--transition-smooth);
}

.login-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 30px;
    text-align: center;
}

.form-group {
    width: 100%;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.form-label {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
}

.input-container {
    position: relative;
    width: 100%;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    outline: none;
    transition: var(--transition-smooth);
    color: var(--text-primary);
    background-color: #f8fafc;
}

.form-input:focus {
    border-color: var(--sgs-red);
    box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.1);
    background-color: #ffffff;
}

.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    background: none;
    border: none;
    outline: none;
}

.password-toggle:hover {
    color: var(--text-primary);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    background-color: var(--sgs-red);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-top: 10px;
    box-shadow: 0 4px 12px rgba(227, 6, 19, 0.2);
}

.btn-primary:hover {
    background-color: var(--sgs-red-hover);
    box-shadow: 0 6px 16px rgba(227, 6, 19, 0.3);
}

.login-error {
    width: 100%;
    background-color: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 20px;
    display: none;
    align-items: center;
    gap: 8px;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}


/* ==========================================================================
   2. Interfaz Principal (Dashboard App)
   ========================================================================== */
#app-container {
    display: none; /* Se activa tras login */
    flex-direction: column;
    height: 100vh; /* Ocupa exactamente la pantalla */
    padding: 0; /* Sin paddings externos para maximizar a pantalla completa */
    max-width: 100%;
    margin: 0;
    box-sizing: border-box;
    overflow: hidden; /* Sin scroll de página general */
}

/* Cabecera Superior Fija, Translúcida y Pinned a la parte superior */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    padding: 4px 24px; /* Cabecera compacta con 24px de padding interno */
    border-bottom: 1px solid var(--card-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    position: sticky;
    top: 0;
    z-index: 200;
    flex-shrink: 0; /* No se encoge */
    width: 100%;
    border-radius: 0 !important; /* Pinned sin esquinas redondeadas */
}

.header-title-container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
}

.badge-mode {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 50px;
    text-transform: uppercase;
}

.badge-mode.admin {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fee2e2;
}

.badge-mode.user {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #dcfce7;
}

.badge-sync {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 50px;
    text-transform: uppercase;
    display: none !important;
    align-items: center;
    gap: 5px;
    margin-left: 8px;
    transition: all 0.08s ease-out;
}

.badge-sync.online {
    background-color: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.badge-sync.offline {
    background-color: #f8fafc;
    color: #475569;
    border: 1px solid #cbd5e1;
}

/* Punto indicador con animación de pulso sutil */
.badge-sync::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.badge-sync.online::before {
    background-color: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    animation: sync-pulse 2s infinite;
}

.badge-sync.offline::before {
    background-color: #94a3b8;
}

@keyframes sync-pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.user-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-secondary {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
    color: var(--text-primary);
}

.btn-outline-red {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--sgs-red);
    background-color: transparent;
    border: 1px solid var(--sgs-red);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-outline-red:hover {
    background-color: #fef2f2;
}

/* Barra de Filtros y Secciones Superior (Estilo SaaS Premium) */
.section-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 24px; /* Barra de filtros compacta con 24px de padding interno */
    margin-bottom: 8px;
    border-bottom: 1px solid #cbd5e1;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 12px;
    background-color: var(--bg-main) !important;
    position: sticky;
    top: 54px; /* Altura ajustada a cabecera de 54px */
    z-index: 150;
    width: 100%;
}

.section-bar-title-group {
    display: flex;
    flex-direction: column;
}

.section-bar-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.section-bar-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.section-bar-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Botón premium de restablecimiento de filtros */
.btn-clear-all {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    outline: none;
    flex-shrink: 0;
}

.btn-clear-all:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.btn-clear-all:active {
    transform: translateY(0);
}

/* Botón de texto Limpiar Todos estilo SaaS de la referencia */
.btn-clear-all-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    height: 34px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    border: 1px solid #cbd5e1;
    transition: var(--transition-smooth);
    outline: none;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

/* Estado inactivo - Grisáceo atenuado */
.btn-clear-all-text.inactive {
    background-color: #f8fafc;
    color: #94a3b8;
    border-color: #e2e8f0;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Estado activo - Disponible para clic */
.btn-clear-all-text.active {
    background-color: #f1f5f9;
    color: #334155;
    border-color: #cbd5e1;
    cursor: pointer;
}

.btn-clear-all-text.active:hover {
    background-color: #e2e8f0;
    color: #1e293b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.btn-clear-all-text.active:active {
    transform: translateY(0);
}

/* Botón de Exportar a PDF (Premium rojo corporativo suave) [NUEVO] */
.btn-pdf-export {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    height: 34px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    border: 1px solid #fca5a5;
    background-color: #fef2f2;
    color: #991b1b;
    cursor: pointer;
    transition: var(--transition-smooth);
    outline: none;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    gap: 6px;
}

.btn-pdf-export:hover {
    background-color: #fee2e2;
    color: #7f1d1d;
    border-color: #f87171;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.08);
}

.btn-pdf-export:active {
    transform: translateY(0);
}

/* Área de Trabajo Principal (Dos Columnas - Siempre lado a lado) */
/* Contenedor del Canvas Principal Premium (Panel Único Unificado con Bordes Redondeados y Sombra) */
.main-canvas {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: #ffffff;
    border-radius: 8px; /* Bordes redondeados elegantes como en la referencia */
    border: 1px solid #cbd5e1; /* Borde completo gris claro */
    box-shadow: 0 12px 20px -8px rgba(0, 0, 0, 0.08), 0 4px 12px -2px rgba(0, 0, 0, 0.03); /* Sombra elegante proyectada hacia abajo */
    padding: 12px 24px; /* Relleno alineado con cabecera y filtros */
    margin: 12px 24px 12px 24px; /* Margen para separarlo de los bordes y el copyright inferior */
    position: relative;
    z-index: 10; /* Asegura que la sombra se proyecte por encima de la zona inferior */
}

.main-grid {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    flex: 1;
    min-height: 0;
    width: 100%;
    margin-bottom: 0; /* Sin margen inferior ya que el copyright está fuera */
    gap: 0; /* Controlado por el resizer de panel */
}

/* Subpanel del Mapa (Columna Izquierda) */
.map-card {
    background: #ffffff;
    padding: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
    min-height: 0;
    flex: 1;
    min-width: 200px;
    overflow: hidden; /* Muy importante para evitar que el zoom expanda el panel */
}

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

.map-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.map-wrapper {
    width: 100%;
    display: flex;
    position: relative;
    overflow: auto !important; /* Muestra barras de deslizamiento cuando no cabe o hay zoom */
    flex: 1;
    min-height: 0;
}

/* ==========================================================================
   3. Estilos Interactivos para el SVG del Mapa
   ========================================================================== */
svg#svg3609 {
    margin: auto; /* Centrado perfecto si es menor, scrollable top-left si es mayor (bugfix de desborde) */
    flex-shrink: 0; /* Evita que se encoja por debajo del tamaño calculado */
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.3)) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.22)); /* Sombra general del mapa intensificada y profunda */
}

/* Configuración de Paths y Círculos de Provincias */
svg#svg3609 g {
    cursor: pointer;
}

svg#svg3609 path,
svg#svg3609 circle {
    stroke: #475569 !important; /* Gris oscuro elegante para las divisiones por defecto */
    stroke-width: 0.35px !important; /* Aún más fina para un aspecto ultra-limpio */
    transition: fill 0.05s ease-out, filter 0.05s ease-out, stroke-width 0.05s ease-out, stroke 0.05s ease-out;
}

/* Efectos de Hover en las provincias */
svg#svg3609 g:hover path,
svg#svg3609 g:hover circle {
    filter: brightness(1.08) drop-shadow(0px 8px 20px rgba(0, 0, 0, 0.45));
    stroke: #000000 !important; /* El mismo color de borde pero intensificado a negro puro al pasar el ratón */
    stroke-width: 1.8px !important;
}

/* Evitar que las etiquetas de texto del SVG interfieran en la interactividad */
svg#svg3609 text,
svg#svg3609 tspan {
    pointer-events: none !important;
    user-select: none !important;
    font-family: 'Inter', sans-serif !important;
    font-weight: 600 !important;
    font-size: 8.5px !important;
    fill: #27272a !important;
    text-shadow: 0px 0px 3px rgba(255, 255, 255, 0.9), 0px 0px 1px rgba(255, 255, 255, 0.9);
}

/* Clases de Relleno Dinámico por Planificadora (fallback) */
.provincia-default {
    fill: #e2e8f0;
}

/* Leyenda del Mapa (Columna Derecha) */
.legend-card {
    background: #ffffff;
    padding: 0 0 0 16px; /* Spacing para separarse del split handle */
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    height: 100%;
    min-height: 0;
    width: 480px; /* Ancho inicial ampliado para evitar recortes */
    min-width: 200px;
    flex-shrink: 0;
    overflow: hidden;
}

/* Divisor de Resizer Arrastrable (Split Pane Divider) */
.split-divider {
    width: 10px;
    background-color: #fafafa;
    border-left: 1px solid #cbd5e1;
    border-right: 1px solid #cbd5e1;
    cursor: col-resize;
    position: relative;
    transition: background-color 0.2s, border-color 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    user-select: none;
    margin: 0 8px;
    border-radius: 4px;
}

.split-divider:hover,
.split-divider.dragging {
    background-color: var(--sgs-red) !important;
    border-color: var(--sgs-red) !important;
}

.split-divider::after {
    content: "⋮";
    color: #94a3b8;
    font-size: 14px;
    font-weight: bold;
}

.split-divider:hover::after,
.split-divider.dragging::after {
    color: #ffffff;
}

.legend-title {
    font-size: 20px;
    font-weight: 800; /* Extra bold para intensificar la presencia */
    color: #0f172a; /* Slate 900 súper oscuro e intenso */
    padding-bottom: 12px;
    border-bottom: 2px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.legend-table-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto; /* Permite scroll horizontal si las columnas se estiran */
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    background-color: #ffffff;
    box-shadow: var(--shadow-inset);
}

.legend-table {
    width: 100%;
    min-width: 100%; /* Evita huecos vacíos cuando el panel se agranda */
    border-collapse: collapse;
    text-align: left;
    table-layout: fixed; /* Necesario para que el ajuste de columnas funcione */
}

/* Anchos iniciales de columnas */
.legend-table th:nth-child(1) { width: 200px; }
.legend-table th:nth-child(2) { width: 110px; }
.legend-table th:nth-child(3) { width: 100px; }
.legend-table th:nth-child(4) { width: 75px; }

.legend-table th {
    position: relative;
    user-select: none;
}

.resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 30;
    user-select: none;
}

.resize-handle:hover,
.resize-handle.active {
    background-color: var(--sgs-red);
    width: 3px;
}

.legend-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.legend-table th {
    position: relative; /* Necesario para posicionar el pseudo-elemento divisor */
    background-color: #475569 !important; /* Gris pizarra oscuro exacto de la referencia */
    color: #ffffff !important;
    font-family: 'Inter', sans-serif; /* Usar Inter como en la referencia (sans-serif de interfaz limpia) */
    font-weight: 600; /* Peso de letra semi-bold de la referencia */
    font-size: 11px;
    padding: 10px 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #2e3a47; /* Línea de base 3D inferior */
    border-left: none;
    border-right: none;
    user-select: none;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: visible; /* Permitir ver el pseudo-elemento divisor vertical */
}

/* Divisor 3D ultra-nítido de 1px sombra + 1px brillo para emular la ranura en bajorrelieve */
.legend-table th::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.28) 50%, rgba(255, 255, 255, 0.1) 50%);
    z-index: 5;
    pointer-events: none; /* Permite arrastrar el tirador resize-handle sin obstrucciones */
}

/* Evitar el divisor vertical en la última columna */
.legend-table th:last-child::after {
    display: none;
}

.legend-table tbody tr {
    transition: transform 0.05s ease-out, 
                box-shadow 0.05s ease-out, 
                background-color 0.05s ease-out,
                border-left-color 0.05s ease-out;
    cursor: pointer;
    position: relative;
}

.legend-table tbody tr:hover {
    background-color: #cbd5e1 !important; /* Gris notablemente más intenso al hacer hover */
    transform: translateY(-2px) scale(1.015);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
    z-index: 10;
}

.legend-table tbody tr:hover td {
    background-color: #cbd5e1 !important;
    color: #0f172a !important; /* Slate 900 */
}

/* Efecto de resaltado bidireccional y relieve de ficha premium en hover/selección */
.legend-table tbody tr.highlighted {
    transform: translateY(-3px) scale(1.02); /* Mayor relieve sobresaliente 3D */
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12), 0 3px 6px rgba(0, 0, 0, 0.06);
    border-left: 5px solid var(--sgs-red) !important;
    z-index: 15;
}

.legend-table tbody tr.highlighted td {
    background-color: #94a3b8 !important; /* Gris slate distinguido e intenso para selección */
    color: #ffffff !important; /* Contraste blanco premium */
    font-weight: 700 !important;
}

/* Correcciones de visibilidad para elementos secundarios dentro de la fila seleccionada */
.legend-table tbody tr.highlighted .legend-email,
.legend-table tbody tr.highlighted .legend-phone {
    color: #f1f5f9 !important;
}

.legend-table tbody tr.highlighted td strong {
    color: #ffffff !important;
}

.legend-table tbody tr.highlighted td[style*="color:#b45309"] {
    color: #fef08a !important; /* Contraste amarillo claro para unidades en fondo gris oscuro */
}

.legend-table td {
    padding: 10px 12px;
    font-size: 12.5px;
    color: var(--text-primary);
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.legend-color-indicator {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
    border: 1px solid rgba(0,0,0,0.1);
}

/* Estilo para Scrollbar de la Leyenda Tabular */
.legend-table-container::-webkit-scrollbar {
    width: 6px;
}
.legend-table-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}
.legend-table-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* ==========================================================================
   4. Componente de Tooltip Flotante (Hover de Provincias)
   ========================================================================== */
.custom-tooltip {
    position: fixed;
    background: rgba(33, 37, 41, 0.62) !important; /* Tema oscuro con mayor transparencia para un efecto glassmorphism premium */
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    padding: 14px 18px;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    z-index: 500;
    display: none; /* Inicialmente oculto */
    min-width: 250px;
    max-width: 380px;
    transform: translate(15px, 15px);
    transition: opacity 0.15s ease;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif !important;
}

.tooltip-provincia {
    font-size: 16px; /* Escalado un pelín más grande para mayor legibilidad */
    font-weight: 700;
    color: #ffffff !important;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
    padding-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tooltip-row {
    font-size: 14px; /* Escalado un pelín más grande para mayor legibilidad */
    margin-bottom: 5px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
}

.tooltip-label {
    font-weight: 600;
    color: #adb5bd !important; /* Muted text de referencia */
    font-size: 13px; /* Escalado un pelín más grande */
}

.tooltip-value {
    color: #f8f9fa !important; /* Light text de referencia */
    font-weight: 500;
    font-size: 13.5px; /* Escalado un pelín más grande */
}

.tooltip-value.planner-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
}

.tooltip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* Buscador de Provincias */
.search-container {
    margin-top: 12px;
}

.search-input {
    width: 100%;
    padding: 8px 16px;
    font-size: 13px;
    border: 1px solid #e2e8f0;
    border-radius: 50px;
    outline: none;
    background-color: #ffffff;
    color: var(--text-primary);
    font-weight: 500;
    transition: var(--transition-smooth);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.search-input:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.search-input:focus {
    border-color: var(--sgs-red);
    box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.1);
    background-color: #ffffff;
}

/* Selector dropdown específico con flecha Apple/SGS premium */
select.search-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px;
    padding-right: 36px !important;
    cursor: pointer;
}


/* ==========================================================================
   5. Panel Lateral de Administración (Drawer Deslizable)
   ========================================================================== */
#admin-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 440px;
    height: 100vh;
    background: #ffffff;
    box-shadow: -10px 0 30px rgba(0,0,0,0.08);
    z-index: 900;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), width 0.05s ease-out; /* Transición para que sea fluido */
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--card-border);
}

/* Tirador de arrastre para el panel de administración lateral */
.drawer-resizer {
    position: absolute;
    top: 0;
    left: 0;
    width: 8px; /* Ancho cómodo de capturar con el ratón */
    height: 100%;
    cursor: col-resize;
    z-index: 950;
    transition: background-color 0.2s;
    border-left: 1px solid rgba(0, 0, 0, 0.05);
}

.drawer-resizer:hover,
.drawer-resizer.dragging {
    background-color: var(--sgs-red) !important;
}

#admin-drawer.open {
    transform: translateX(0);
}

.drawer-header {
    padding: 24px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fafafa;
}

.drawer-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.drawer-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
}

.drawer-close:hover {
    color: var(--text-primary);
}

.drawer-content {
    padding: 24px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.admin-card {
    background: #f8fafc;
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid #e2e8f0;
}

.preset-colors {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.color-option {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-inset);
}

.color-option.selected {
    border-color: #475569;
    transform: scale(1.15);
}

/* Menú de Asignación Rápida Flotante */
.assignment-popup {
    position: fixed;
    background: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: 0 15px 35px -5px rgba(0,0,0,0.15), 0 0 1px 1px rgba(0,0,0,0.05);
    border: 1px solid var(--card-border);
    padding: 18px;
    z-index: 600;
    display: none;
    min-width: 220px;
    animation: scaleUp 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleUp {
    from { transform: scale(0.9) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.popup-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.popup-select {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    outline: none;
    margin-bottom: 12px;
}

.popup-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-sm.primary {
    background-color: var(--sgs-red);
    color: white;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

.btn-sm.primary:hover {
    background-color: var(--sgs-red-hover);
}

/* Tabla del Panel Lateral (Lista de Planificadoras) */
.planners-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.planners-table th {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid #e2e8f0;
}

.planners-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    vertical-align: middle;
}

.btn-icon-danger {
    background: none;
    border: none;
    cursor: pointer;
    color: #ef4444;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition-smooth);
}

.btn-icon-danger:hover {
    background-color: #fef2f2;
}

/* --- Fondo desenfocado del modal admin --- */
#drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.15);
    backdrop-filter: blur(4px);
    z-index: 850;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#drawer-overlay.show {
    display: block;
    opacity: 1;
}

/* Botones flotantes de Zoom en el mapa */
.map-controls {
    position: absolute;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.map-control-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: #ffffff;
    border: 1px solid #cbd5e1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition-smooth);
    outline: none;
}

.map-control-btn:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
    border-color: #94a3b8;
}

/* Estilo para las etiquetas de provincia seleccionadas */
.region-prov-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    color: var(--text-primary);
    font-weight: 500;
    transition: var(--transition-smooth);
}

.region-prov-tag:hover {
    background-color: #e2e8f0;
}

.region-prov-tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #ef4444;
    font-size: 11px;
    padding: 0;
    display: flex;
    align-items: center;
    font-weight: bold;
}

.region-prov-tag-remove:hover {
    color: #b91c1c;
}

/* ==========================================================================
   Estilos de los Componentes de Multiselección Premium (Dropdowns)
   ========================================================================== */
.custom-multiselect {
    position: relative;
    display: inline-block;
}

.multiselect-btn {
    border-radius: 6px !important; /* Rectangulares suaves */
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: space-between;
    transition: var(--transition-smooth);
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    min-width: 140px;
    max-width: 220px;
    outline: none;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
}

.multiselect-btn:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.multiselect-btn:focus {
    border-color: #94a3b8;
    box-shadow: 0 0 0 2px rgba(30, 41, 59, 0.05);
}

/* Estilo Activo para los botones del filtro (estilo de la página de referencia) */
.multiselect-btn.active {
    background-color: #e2e8f0 !important;
    border-color: #94a3b8;
    color: #1e293b;
    font-weight: 600;
}

.multiselect-btn.active:hover {
    background-color: #cbd5e1 !important;
}

.multiselect-btn .multiselect-btn-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 165px;
}

.multiselect-btn .arrow {
    font-size: 10px;
    color: var(--text-secondary);
    transition: transform 0.25s ease;
}

.custom-multiselect.open .multiselect-btn .arrow {
    transform: rotate(180deg);
}

/* Botón de limpiar selección en el botón */
.multiselect-btn .clear-filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: rgba(30, 41, 59, 0.1);
    color: var(--text-primary);
    font-size: 8px;
    margin-left: 4px;
    transition: var(--transition-smooth);
    cursor: pointer;
    flex-shrink: 0;
}

.multiselect-btn .clear-filter:hover {
    background-color: rgba(227, 6, 19, 0.2);
    color: var(--sgs-red);
}

.multiselect-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    box-shadow: 0 12px 28px -5px rgba(0,0,0,0.12), 0 4px 12px -2px rgba(0,0,0,0.05);
    z-index: 250;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    min-width: 220px;
    max-height: 220px;
    overflow-y: auto;
    animation: scaleUp 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.custom-multiselect.open .multiselect-dropdown {
    display: flex;
}

.multiselect-dropdown::-webkit-scrollbar {
    width: 6px;
}
.multiselect-dropdown::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}
.multiselect-dropdown::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.multiselect-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-primary);
    transition: var(--transition-smooth);
    user-select: none;
    font-weight: 500;
}

.multiselect-dropdown-item:hover {
    background-color: #f1f5f9;
}

.multiselect-dropdown-item input[type="checkbox"] {
    cursor: pointer;
    width: 14px;
    height: 14px;
    accent-color: var(--sgs-red);
}

/* ==========================================================================
   Copyright centrado en la sombra del relieve
   ========================================================================== */
.footer-copyright {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    margin: 0;
    padding: 2px 0 10px 0; /* Relleno para que repose cómodamente en la franja gris */
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    flex-shrink: 0; /* Evita que el copyright se encoja */
    width: 100%;
    position: relative;
    z-index: 5; /* Colocado debajo de la sombra del canvas en la jerarquía visual */
}

/* ==========================================================================
   Estilos Premium para el Modal de Edición de Planificadoras (CRUD)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.35); /* Fondo desenfocado semi-transparente */
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    display: none; /* Inicialmente oculto */
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.modal-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15), 0 0 1px 1px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 460px;
    padding: 24px;
    border: 1px solid var(--card-border);
    animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScaleUp {
    from { transform: scale(0.92) translateY(15px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 16px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a; /* Slate 900 */
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
}

.modal-close:hover {
    color: var(--text-primary);
}

/* Iconos de edición en la tabla del panel de Admin */
.btn-icon-edit {
    background: none;
    border: none;
    cursor: pointer;
    color: #3b82f6; /* Azul */
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition-smooth);
    margin-right: 4px;
    font-size: 13px;
}

.btn-icon-edit:hover {
    background-color: #eff6ff;
}

.btn-icon-copy {
    background: none;
    border: none;
    cursor: pointer;
    color: #10b981; /* Verde esmeralda premium */
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition-smooth);
    margin-right: 4px;
    font-size: 13px;
}

.btn-icon-copy:hover {
    background-color: #ecfdf5;
}

.legend-email {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    margin-left: 18px;
    user-select: text !important;
    font-weight: 500;
}

.legend-phone {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 1px;
    margin-left: 18px;
    user-select: text !important;
    font-weight: 500;
}

/* Subtítulos de Secciones Estructuradas en el Drawer Lateral */
.admin-card-section-title {
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 16px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px dashed #cbd5e1;
    display: flex;
    align-items: center;
    gap: 6px;
}




