/* Variables según Figma */
:root {
    --dcp-primary: #1565C0;
    /* Blue for tabs border, bars */
    --dcp-header-blue: #2389e6;
    /* Blue for filter bar */
    --dcp-text-primary: #212121;
    --dcp-text-secondary: #757575;
    --dcp-bg: #f9f9f9;
    --dcp-border: #E0E0E0;
    --dcp-blue-light: #52c1f5;
    --dcp-blue-dark: #3754d4;
    --dcp-purple: #9f5cf4;
    --dcp-green: #4caf50;
    --dcp-teal: #26a69a;
}

.dcp-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--dcp-text-primary);
    background-color: #FFFFFF;
    box-sizing: border-box;
    
    /* Breakout to full screen width */
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    max-width: 100vw !important;
}

.dcp-header {
    padding: 20px 20px 5px 20px;
    background: #FFFFFF;
}

/* ======================================================
   GeneratePress: Anular el max-width del .grid-container
   para que la página del dashboard ocupe todo el ancho.
   Este CSS solo se carga en páginas con el shortcode,
   por lo que no afecta al resto del sitio.
   ====================================================== */
#page.grid-container,
.site-content .grid-container,
.grid-container {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Fondo blanco completo para toda la zona de contenido */
body,
#page,
#content.site-content,
.site-main,
.site-main article,
header.entry-header {
    background: #FFFFFF !important;
}

/* Padding lateral para el título para que no quede pegado al borde */
header.entry-header {
    padding-left: 40px !important;
    padding-right: 40px !important;
}

/* Alinear el título a la izquierda */
h1.entry-title {
    text-align: left !important;
}

.dcp-header h1 {
    margin: 0 0 5px 0;
    font-size: 20px;
    color: var(--dcp-text-primary);
    font-weight: 600;
}

.dcp-header p.dcp-header-subtitle {
    margin: 0;
    font-size: 13px;
    color: var(--dcp-text-secondary);
}

/* Tabs */
.dcp-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 0 20px;
    background: transparent;
}

.dcp-tab {
    padding: 10px 5px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--dcp-text-secondary);
    transition: all 0.2s;
    outline: none;
}

.dcp-tab:hover {
    color: var(--dcp-primary) !important;
    background-color: transparent !important;
    opacity: 0.7;
}

.dcp-tab.active {
    color: var(--dcp-primary) !important;
    border-bottom: 3px solid var(--dcp-primary) !important;
    background-color: transparent !important;
    opacity: 1;
}

/* Filters */
.dcp-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    background: var(--dcp-header-blue);
    padding: 15px 20px;
    align-items: flex-end;
    justify-content: center;
}

.dcp-filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
}

.dcp-filter-group label {
    display: block !important;
    visibility: visible !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #FFFFFF !important;
    margin-bottom: 0px;
    position: relative !important;
    width: auto !important;
    height: auto !important;
    clip: auto !important;
    overflow: visible !important;
}

.dcp-filter-group select {
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 4px;
    font-size: 14px;
    background: #FFFFFF;
    color: var(--dcp-text-primary);
    min-height: 40px;
}

.dcp-filter-group select:focus {
    outline: none;
}

/* Special RUT search input */
/* ========================================
   INPUT RUT - Mejoras de UX
   ======================================== */
.dcp-search-input {
    display: flex;
    align-items: center;
    background: #FFFFFF;
    border-radius: 6px;
    overflow: hidden;
    padding: 0 12px;
    min-height: 42px;
    border: 1.5px solid transparent;
    transition: all 0.2s ease;
}

.dcp-search-input:focus-within {
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

.dcp-search-input.error {
    border-color: #E53935;
    box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.15);
}

.dcp-search-icon {
    margin-right: 8px;
    color: #757575;
    transition: color 0.2s ease;
}

.dcp-search-input:focus-within .dcp-search-icon {
    color: #4CAF50;
}

.dcp-search-input input {
    border: none;
    outline: none;
    width: 100%;
    padding: 10px 0;
    font-size: 14px;
    font-family: inherit;
    color: #212121;
    letter-spacing: 0.3px;
}

.dcp-search-input input::placeholder {
    color: #BDBDBD;
    font-style: italic;
}

/* Filter Action Buttons */
.dcp-filter-actions {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 0 0 0 15px;
    margin-left: 10px;
    border-left: 2px solid rgba(255, 255, 255, 0.2);
}

.dcp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    min-height: 42px;
    white-space: nowrap;
    line-height: 1.2;
    letter-spacing: 0.2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dcp-btn svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

/* ========================================
   BOTÓN BUSCAR - Acción Principal (PREMIUM)
   ======================================== */
.dcp-btn-buscar {
    background: #ffffff !important;
    color: var(--dcp-primary) !important;
    border: 1px solid transparent !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12) !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.dcp-btn-buscar:hover {
    background: #f8fbff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.2) !important;
}

.dcp-btn-buscar:active {
    background: #e3f2fd !important;
    transform: translateY(0) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.dcp-btn-buscar:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.45) !important;
}

/* Loading state */
.dcp-btn-buscar:disabled {
    background: rgba(255, 255, 255, 0.5) !important;
    color: rgba(21, 101, 192, 0.5) !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

/* ========================================
   BOTÓN LIMPIAR - Acción Secundaria (PREMIUM)
   ======================================== */
.dcp-btn-limpiar {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
    border: 1.5px solid rgba(255, 255, 255, 0.4) !important;
    box-shadow: none !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.dcp-btn-limpiar:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: #ffffff !important;
    transform: translateY(-2px) !important;
}

.dcp-btn-limpiar:active {
    background: rgba(255, 255, 255, 0.25) !important;
    transform: translateY(0) !important;
}

.dcp-btn-limpiar:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2) !important;
}

/* ========================================
   RESPONSIVE - Botones
   ======================================== */
@media (max-width: 900px) {
    .dcp-filter-actions {
        width: 100%;
        margin-left: 0;
        margin-top: 15px;
        padding-left: 0;
        border-left: none;
        border-top: 2px solid rgba(255, 255, 255, 0.2);
        padding-top: 15px;
    }
    
    .dcp-btn {
        flex: 1;
        min-width: 120px;
    }
}

@media (max-width: 600px) {
    .dcp-btn {
        padding: 10px 16px;
        font-size: 13px;
        min-height: 44px; /* Touch-friendly */
    }
    
    .dcp-btn svg {
        width: 18px;
        height: 18px;
    }
}

.dcp-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 600px;
}

@media (min-width: 900px) {
    .dcp-container {
        flex-direction: row;
        height: 750px; /* Fixed height for desktop to stabilize layout */
        border-bottom: 1px solid var(--dcp-border);
    }
}

/* Map Section */
.dcp-map-section {
    flex: 0 0 50%;
    position: relative;
    border-right: 1px solid var(--dcp-border);
    min-height: 500px;
    height: 100%;
}

#dcp-map {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* Content Section (Right) */
.dcp-content-section {
    flex: 1;
    padding: 24px;
    background: var(--dcp-bg);
    height: 100%;
    overflow-y: auto;
}

/* Scrollbar styling for a premium look */
.dcp-content-section::-webkit-scrollbar {
    width: 6px;
}

.dcp-content-section::-webkit-scrollbar-track {
    background: transparent;
}

.dcp-content-section::-webkit-scrollbar-thumb {
    background: #cccccc;
    border-radius: 10px;
}

.dcp-content-section::-webkit-scrollbar-thumb:hover {
    background: #aaaaaa;
}

.dcp-section-title {
    font-size: 18px;
    margin: 0 0 5px 0;
    color: var(--dcp-text-primary);
}

.dcp-section-subtitle {
    font-size: 13px;
    color: var(--dcp-text-secondary);
    margin: 0 0 20px 0;
}

/* KPIs */
.dcp-kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.dcp-kpi-card {
    border: 1px solid var(--dcp-border);
    padding: 15px;
    border-radius: 6px;
    text-align: left;
    background: #FFFFFF;
}

.dcp-kpi-card h4 {
    margin: 0 0 2px 0;
    color: var(--dcp-text-primary);
    font-size: 14px;
    font-weight: 600;
}

.dcp-kpi-subtitle {
    display: block;
    color: var(--dcp-text-secondary);
    font-size: 12px;
    margin-bottom: 20px;
}

.dcp-kpi-val {
    font-size: 26px;
    font-weight: 300;
    color: var(--dcp-text-secondary);
    display: block;
}

/* Charts Grids */
.dcp-chart-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.dcp-chart-card,
.dcp-chart-card-full {
    border: 1px solid var(--dcp-border);
    padding: 15px;
    border-radius: 6px;
    background: #FFFFFF;
}

.dcp-chart-card h4,
.dcp-chart-card-full h4 {
    margin: 0 0 2px 0;
    font-size: 14px;
}

.dcp-chart-card-full {
    margin-bottom: 20px;
}

.dcp-chart-wrapper-pie {
    position: relative;
    height: 180px;
    width: 100%;
}

.dcp-chart-wrapper-bar-h,
.dcp-chart-wrapper-bar-v {
    position: relative;
    height: 250px;
    width: 100%;
}

/* ========================================
   POPUP DEL MAPA - Estilos
   ======================================== */

.dcp-map-popup-container .maplibregl-popup-content {
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 320px;
}

.dcp-map-popup-container .maplibregl-popup-close-button {
    font-size: 20px;
    padding: 6px 10px;
    color: #555555;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    border-top-right-radius: 8px;
    transition: all 0.2s ease;
}

.dcp-map-popup-container .maplibregl-popup-close-button:hover {
    background: rgba(0, 0, 0, 0.08) !important;
    color: #000000;
}

.dcp-popup {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-width: 280px;
}

.dcp-popup-title {
    font-size: 15px;
    font-weight: 600;
    color: #1565C0;
    margin: 0;
    padding: 12px 16px;
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    border-bottom: 1px solid #90CAF9;
    border-radius: 8px 8px 0 0;
}

.dcp-popup-content {
    padding: 12px 16px;
}

.dcp-popup-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 6px 0;
    border-bottom: 1px solid #E0E0E0;
}

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

.dcp-popup-label {
    font-size: 12px;
    font-weight: 600;
    color: #757575;
    min-width: 100px;
}

.dcp-popup-value {
    font-size: 13px;
    color: #212121;
    text-align: right;
    flex: 1;
    word-break: break-word;
}

.dcp-popup-number {
    font-weight: 500;
    color: #2E7D32;
}

.dcp-popup-divider {
    height: 1px;
    background: #E0E0E0;
    margin: 8px 0;
}

.dcp-popup-total {
    background: #E8F5E9;
    padding: 8px 0;
    margin: 0 -16px;
    padding: 8px 16px;
    border-radius: 0 0 8px 8px;
}

.dcp-popup-total .dcp-popup-label {
    color: #2E7D32;
    font-weight: 700;
}

.dcp-popup-total .dcp-popup-value {
    color: #1B5E20;
    font-weight: 700;
    font-size: 14px;
}

/* Estilos para clusters en el mapa */
.maplibregl-popup-tip {
    border-top-color: #fff;
}

/* Responsive para móviles */
@media (max-width: 600px) {
    .dcp-map-popup-container .maplibregl-popup-content {
        max-width: 280px;
    }
    
    .dcp-popup {
        min-width: 240px;
    }
    
    .dcp-popup-title {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .dcp-popup-content {
        padding: 10px 12px;
    }
}

/* Global Loader */
.dcp-global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.85);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
    pointer-events: all; /* Actively block clicks underneath */
}

.dcp-loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--dcp-border);
    border-top: 4px solid var(--dcp-primary);
    border-radius: 50%;
    animation: dcp-spin 1s linear infinite;
    margin-bottom: 12px;
}

.dcp-loader-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--dcp-primary);
}

@keyframes dcp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}