/* ==========================================================================
   Vital Maps - Plugin CSS v4.1
   
   Diseño profesional y limpio inspirado en vitalseguro.com
   Estilos para aplicación completa de mapas con marcadores filtrados
   
   Componentes principales:
   - Contenedores y wrapper responsive
   - Sistema de selectores con Choices.js
   - Mapa Google Maps integrado y fullwidth
   - Sidebar con listado de ubicaciones
   - Estados de carga, error y vacío
   - Responsive design para móviles
   
   @author BK Modules / Vital Maps Team
   @version 4.1
   @since 0.1.0
   ========================================================================== */

/* Divi theme fix: el módulo et_pb_code tiene overflow:hidden que corta los dropdowns */
.et_pb_code:has(.vital-maps-container),
.et_pb_code:has(.vital-maps-hub) {
    overflow: visible !important;
}

/* Reset and Base Styles */
.vital-maps-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.vital-maps-container *,
.vital-maps-container *::before,
.vital-maps-container *::after {
    box-sizing: inherit;
}

/* Combined Hub Widget */
.vital-maps-hub {
    max-width: 1320px;
    margin: 0 auto;
    padding: 28px 20px 12px;
}

.vital-maps-hub__inner {
    max-width: 980px;
    margin: 0 auto;
    text-align: center;
}

/* Secciones del hub lado a lado en desktop */
.vital-maps-hub__sections-row {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-top: 28px;
}

.vital-maps-hub__sections-row .vital-maps-hub__section {
    margin-top: 0;
    flex: 0 1 auto;
}

.vital-maps-hub__header {
    margin-bottom: 28px;
}

.vital-maps-hub__title {
    margin: 0 0 16px;
    color: #1b2b70;
    font-size: clamp(2.2rem, 3vw, 3rem);
    line-height: 1.05;
    font-weight: 700;
}

.vital-maps-hub__description {
    max-width: 1180px;
    margin: 0 auto;
    color: #334155;
    font-size: 1.02rem;
    line-height: 1.58;
}

.vital-maps-hub__section {
    margin-top: 28px;
}

.vital-maps-hub__section-title {
    display: none; /* Oculto por petición del cliente */
}

.vital-maps-hub__grid {
    display: grid;
    justify-content: center;
    gap: 18px;
}

.vital-maps-hub__grid.is-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: 420px;
    margin: 0 auto;
}

.vital-maps-hub__grid.is-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 286px;
    margin: 0 auto;
}

.vital-maps-hub__grid.is-one {
    grid-template-columns: minmax(134px, 134px);
    max-width: 134px;
    margin: 0 auto;
}

.vital-maps-hub__card {
    min-height: 124px;
    padding: 18px 14px 16px;
    border: 2px solid #d8dde6;
    border-radius: 12px;
    background: #fff;
    color: #242b37;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.vital-maps-hub__card:hover,
.vital-maps-hub__card.is-active {
    transform: translateY(-2px);
    border-color: #0a8fe8;
    box-shadow: 0 10px 24px rgba(10, 143, 232, 0.12);
}

.vital-maps-hub__card-icon {
    display: inline-flex;
    width: 48px;
    height: 48px;
    color: #1493e7;
}

.vital-maps-hub__card-icon svg,
.vital-maps-hub__footer-icon svg {
    width: 100%;
    height: 100%;
}

.vital-maps-hub__card-label {
    display: block;
    max-width: 118px;
    min-height: 3.3em;
    font-size: 0.98rem;
    line-height: 1.08;
    font-weight: 600;
    white-space: pre-line;
    text-align: center;
}

.vital-maps-hub__footer {
    margin: 34px auto 0;
    padding-top: 28px;
    border-top: 1px solid #d8dde6;
    display: none; /* Oculto por petición del cliente */
    justify-content: center;
    gap: 16px;
    max-width: 480px;
}

.vital-maps-hub__footer-button {
    min-width: 168px;
    min-height: 56px;
    padding: 12px 20px;
    border: 2px solid #1d77d3;
    border-radius: 8px;
    background: #fff;
    color: #1d77d3;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
}

.vital-maps-hub__footer-button.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.vital-maps-hub__footer-icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
}

.vital-maps-hub__map-shell {
    margin-top: 32px;
}

.vital-maps-hub__map-loader,
.vital-maps-hub__error {
    max-width: 980px;
    margin: 0 auto 20px;
    padding: 28px 20px;
    border: 1px solid #d8dde6;
    border-radius: 14px;
    background: #fff;
    text-align: center;
}

.vital-maps-hub__error h3 {
    margin: 0 0 8px;
    color: #b42318;
}

.vital-maps-hub__error p {
    margin: 0;
    color: #475467;
}

/* Main Container - Expandido para ser más ancho */
.vital-maps-wrapper {
    max-width: 1400px; /* Aumentado de 1200px */
    margin: 0 auto 40px; /* Espaciado fijo inferior siempre presente */
    padding: 20px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: visible;
    z-index: 1001; /* Por encima del mapa fullwidth (1000) para que los dropdowns no queden tapados; debajo del header de Divi (10010) */
}

/* Header Section */
.vital-maps-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.vital-maps-title {
    font-size: 2.2rem;
    font-weight: 600;
    color: #001da1;
    margin: 0 0 10px 0;
    letter-spacing: -0.025em;
}

.vital-maps-subtitle {
    font-size: 1.1rem;
    color: #666;
    margin: 0;
    font-weight: 400;
}

/* Controls Section */
.vital-maps-controls {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 6px;
    margin-bottom: 25px;
    border: 1px solid #e9ecef;
    position: relative;
    overflow: visible;
    z-index: 10; /* Dentro del wrapper, por encima del contenido */
}

.vital-maps-controls-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: end;
    overflow: visible;
}

/* Form Groups */
.vital-maps-form-group {
    margin-bottom: 0;
    min-width: 0; /* Avoid overflow when grid animates */
    overflow: visible;
}

.vital-maps-label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

/* Evita saltos verticales en títulos de los controles durante la animación */
.vital-maps-controls .vital-maps-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Custom Select with Search */
/* Basic select styling - Choices.js will handle the rest */
.vital-maps-select {
    width: 100%;
    min-width: 200px;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 1rem;
    background: #ffffff;
    color: #333;
    transition: all 0.2s ease;
}

/* Texto libre - filtro UX */
.vital-maps-textfilter-group {
    position: relative;
}

.vital-maps-textfilter-icon {
    position: absolute;
    left: 14px;
    bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 14px;
    color: #5b6b7a;
    opacity: 0.8;
    pointer-events: none;
}

.vital-maps-textfilter-input {
    padding-left: 44px;
    background: linear-gradient(135deg, #f7f9fc 0%, #ffffff 45%);
    border-color: #d8dde3;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.vital-maps-textfilter-input:focus {
    border-color: #001da1;
    box-shadow: 0 0 0 3px rgba(0, 29, 161, 0.12);
    background: #ffffff;
}

.vital-maps-textfilter-input::placeholder {
    color: #6b7280;
}

/* Campo + botón «Buscar» en una fila */
.vital-maps-textfilter-row {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.vital-maps-textfilter-row .vital-maps-textfilter-icon {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
}

.vital-maps-textfilter-row .vital-maps-textfilter-input {
    flex: 1 1 auto;
    min-width: 0;
    width: auto !important;
    -webkit-appearance: none;
    appearance: none;
}

/* Sin la «x» nativa de type=search: el usuario borra como en cualquier campo */
.vital-maps-textfilter-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.vital-maps-textfilter-button {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 22px;
    border: 0;
    border-radius: 6px;
    background: #001da1;
    color: #ffffff;
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.vital-maps-textfilter-button:hover {
    background: #00137a;
}

.vital-maps-textfilter-button:focus-visible {
    outline: 3px solid rgba(0, 29, 161, 0.35);
    outline-offset: 2px;
}

.vital-maps-textfilter-button.is-busy {
    cursor: progress;
    background: #3349b3;
}

.vital-maps-textfilter-button-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: vital-maps-spin 0.8s linear infinite;
}

.vital-maps-textfilter-button.is-busy .vital-maps-textfilter-button-spinner {
    display: inline-block;
}

.vital-maps-textfilter-hint {
    margin: 6px 0 0;
    font-size: 0.9rem;
    color: #b42318;
    line-height: 1.4;
}

@media (prefers-reduced-motion: reduce) {
    .vital-maps-textfilter-button-spinner {
        animation-duration: 2s;
    }
}

.vital-maps-helper {
    margin: 6px 0 0;
    font-size: 0.9rem;
    color: #60708a;
    line-height: 1.4;
}

/* Ensure all text content in point items wraps properly */
.vital-maps-point-item * {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

/* Choices.js styling - z-index debajo del header Divi (10010) */
.vital-maps-controls .choices {
    position: relative;
    z-index: 1;
    overflow: visible;
}

.vital-maps-controls .choices__list--dropdown {
    position: absolute;
    z-index: 500 !important;
    width: 100%;
    /* Sin límite de alto aquí: dentro van el buscador y la lista, y si se acota
       la caja exterior, el final de la lista queda tapado. El alto lo limita la
       lista interior, que es la que hace scroll. */
    max-height: none;
}

.vital-maps-controls .choices__list--dropdown .choices__list {
    max-height: min(280px, calc(100vh - 200px));
    overflow-y: auto;
}

.vital-maps-controls .choices[data-type*="select-one"] .choices__inner {
    position: relative;
}

/* Cuando el dropdown está abierto, el form-group sube por encima de los demás */
.vital-maps-form-group:has(.choices.is-open) {
    z-index: 100 !important;
}

.vital-maps-form-group--dropdown-open {
    z-index: 100 !important;
}

.vital-maps-controls .choices.is-open {
    z-index: 200 !important;
}

.vital-maps-controls .choices.is-open .choices__list--dropdown {
    z-index: 500 !important;
}

/* Forzar desplegable hacia abajo (evitar apertura arriba) */
.vital-maps-controls .choices[data-type*="select-one"] .choices__list--dropdown {
    top: 100% !important;
    bottom: auto !important;
    margin-top: 4px;
}

.vital-maps-controls .choices.is-flipped .choices__list--dropdown,
.vital-maps-controls .choices.is-open.is-flipped .choices__list--dropdown {
    top: 100% !important;
    bottom: auto !important;
    margin-top: 0;
    margin-bottom: 4px;
}

/* Button */
.vital-maps-btn {
    background: #001da1;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
    height: 48px;
}

.vital-maps-btn:hover {
    background: #0016cc;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 29, 161, 0.3);
}

.vital-maps-btn:active {
    transform: translateY(0);
}

.vital-maps-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Map Container - Estructura completamente independiente */
.vital-maps-content {
    background: #ffffff;
    border-radius: 8px;
    overflow: visible;
    border: 1px solid #e9ecef;
    min-height: 200px; /* Reduced for controls only */
}

/* Controls grid - animated layout */
.vital-maps-controls-grid {
    --vm-col1: 1fr;
    --vm-col2: 0fr;
    --vm-col3: 0fr;
    display: grid !important;
    grid-template-columns: var(--vm-col1) var(--vm-col2) var(--vm-col3) !important;
    gap: 16px !important;
    align-items: end !important;
    transition: grid-template-columns 0.8s ease-in-out !important;
    overflow: visible;
}

/* Z-index hierarchy for form groups - simplified */
#vital-maps-category-form-group,
#vital-maps-locality-form-group,
#vital-maps-textfilter-form-group {
    position: relative;
    z-index: 1; /* Base z-index, dropdowns will override */
}

/* Hidden fields with animation */
#vital-maps-locality-form-group,
#vital-maps-textfilter-form-group {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
    pointer-events: none;
}

/* Show fields when grid is expanded */
.vital-maps-controls-grid.expanded #vital-maps-locality-form-group,
.vital-maps-controls-grid.expanded #vital-maps-textfilter-form-group {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

/* Text filter input specific styling for theme compatibility */
.vital-maps-container .vital-maps-textfilter-input,
.vital-maps-textfilter-input {
    background: #fff !important;
    color: #333 !important;
    border: 2px solid #e1e5e9 !important;
    border-radius: 6px !important;
    padding: 12px 16px 12px 44px !important;
    font-size: 1rem !important;
    min-height: 48px !important;
    box-sizing: border-box !important;
    width: 100% !important;
}

.vital-maps-container .vital-maps-textfilter-input:focus,
.vital-maps-textfilter-input:focus {
    border-color: #001da1 !important;
    box-shadow: 0 0 0 3px rgba(0, 29, 161, 0.1) !important;
    outline: none !important;
}

.vital-maps-container .vital-maps-textfilter-input::placeholder,
.vital-maps-textfilter-input::placeholder {
    color: #999 !important;
    opacity: 1 !important;
}

/* Responsive: 2 columns on medium screens */
@media (max-width: 1024px) {
    .vital-maps-hub__grid.is-three {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .vital-maps-controls-grid,
    .vital-maps-controls-grid.expanded {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* Responsive: 1 column on small screens */
@media (max-width: 767px) {
    .vital-maps-hub {
        padding: 24px 12px 8px;
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        margin-left: 50% !important;
        transform: translateX(-50%);
    }

    .vital-maps-hub__description {
        font-size: 0.96rem;
    }

    .vital-maps-hub__sections-row {
        gap: 12px;
    }

    .vital-maps-hub__grid.is-three,
    .vital-maps-hub__grid.is-two,
    .vital-maps-hub__grid.is-one {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-width: 320px;
    }

    .vital-maps-hub__card:last-child:nth-child(odd) {
        grid-column: 1 / -1;
        justify-self: center;
        width: 134px;
    }

    .vital-maps-hub__footer {
        flex-direction: column;
        max-width: 220px;
    }

    .vital-maps-controls-grid,
    .vital-maps-controls-grid.expanded {
        grid-template-columns: 1fr !important;
    }
    
    #vital-maps-locality-form-group,
    #vital-maps-textfilter-form-group {
        transform: translateY(10px);
    }
    
    .vital-maps-controls-grid.expanded #vital-maps-locality-form-group,
    .vital-maps-controls-grid.expanded #vital-maps-textfilter-form-group {
        transform: none;
    }
}

/* Independent full-width map container - Responsive */
.vital-maps-fullwidth-container {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 20px 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    background: white;
    overflow: visible;
    position: relative;
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease;
}

/* Animation when container becomes visible */
.vital-maps-fullwidth-container.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Fade out original wrapper */
.vital-maps-wrapper.fading-out {
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.4s ease;
}

.vital-maps-map-container {
    position: relative;
    width: 100%;
    height: 700px;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: visible;
}

/* Main layout for the independent map - Responsive */
.vital-maps-main-layout {
    display: flex;
    height: 700px;
    gap: 0;
    border-radius: 12px;
    overflow: visible;
    width: 100%;
    max-width: 100%;
    flex-direction: row; /* Desktop: side by side */
    min-width: 0;
    column-gap: 8px; /* small gap to avoid overlap */
}

#vital-maps-map {
    flex: 1 1 52%;
    min-width: 0;
    height: 100%;
    min-height: 700px;
    border-radius: 12px 0 0 12px;
    position: relative;
    overflow: hidden;
}

/* Override min-height for mobile - this is critical */
@media (max-width: 767px) {
    #vital-maps-map {
        min-height: 200px !important;
    }
}

/* Sidebar Panel - 40% width with better minimum width on desktop */
.vital-maps-sidebar {
    flex: 1 1 48%;
    min-width: 240px;
    max-width: none;
    background: #ffffff;
    border-left: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    max-height: 700px;
    overflow: visible; /* Changed from hidden to visible to prevent cutting */
    border-radius: 0 12px 12px 0;
    box-sizing: border-box; /* Ensure padding doesn't cause overflow */
}

.vital-maps-sidebar-header {
    padding: 25px 30px; /* Increased padding for better spacing to match point items */
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.vital-maps-sidebar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #001da1;
    margin: 0 0 5px 0;
}

.vital-maps-sidebar-count {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
}

.vital-maps-sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden; /* avoid horizontal bleed that can hide scrollbar */
    padding: 0 6px 0 0; /* reserve space for scrollbar */
    scroll-behavior: auto; /* wheel scrolling must feel immediate */
    scrollbar-width: thin; /* visible on Firefox */
    scrollbar-color: #b5bdc9 #f1f3f5;
    overscroll-behavior: contain; /* prevent body scroll when inside list */
    max-width: 100%;
    word-wrap: break-word;
}

/* Visible scrollbar on WebKit/Blink */
.vital-maps-sidebar-content::-webkit-scrollbar {
    width: 8px;
}

.vital-maps-sidebar-content::-webkit-scrollbar-track {
    background: #f1f3f5;
}

.vital-maps-sidebar-content::-webkit-scrollbar-thumb {
    background: #c6ccd6;
    border-radius: 6px;
}

.vital-maps-sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #aab2c0;
}

/* Aviso legal de la especialidad, justo encima del listado de marcadores */
.vital-maps-category-notice {
    margin: 12px 12px 4px;
    padding: 10px 14px;
    background: #fff8e1;
    border: 1px solid #f0d78c;
    border-left: 4px solid #d4a017;
    border-radius: 6px;
    font-size: 0.82rem;
    line-height: 1.45;
    color: #6b5400;
}

.vital-maps-category-notice p {
    margin: 0;
}

/* Improve point items to use full width without overflow */
.vital-maps-point-item {
    padding: 16px 16px; /* tighter to fit more text without overflow */
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: block;
    width: 100%;
    box-sizing: border-box; /* Include padding in width calculation */
    min-height: 70px; /* Increased minimum height for touch targets */
    overflow: hidden; /* Prevent any horizontal overflow */
    word-wrap: break-word; /* Force long words to break */
    overflow-wrap: break-word; /* Modern browsers */
}

.vital-maps-point-item:hover {
    background-color: #f8f9fa;
    transform: translateX(2px);
}

.vital-maps-point-item.active {
    background-color: #001da1 !important;
    color: #ffffff !important;
}

/* Sobre el azul corporativo TODO el texto de la ficha va en blanco. Se aplica a
   cualquier descendiente para que no se quede ningún dato en gris oscuro
   (subtítulo, horario, notas, detalle por especialidad, enlaces de teléfono…),
   incluidos los que se añadan más adelante. */
.vital-maps-point-item.active,
.vital-maps-point-item.active * {
    color: #ffffff !important;
}

.vital-maps-point-title {
    font-weight: 600;
    color: #333;
    margin: 0 0 6px 0;
    font-size: 1rem; /* Slightly larger font */
    line-height: 1.3;
    word-wrap: break-word; /* Prevent text overflow */
    overflow-wrap: break-word; /* Modern browsers */
    hyphens: auto; /* Better line breaking */
    max-width: 100%; /* Ensure it doesn't exceed container */
    white-space: normal; /* Allow text wrapping */
}

.vital-maps-point-address {
    color: #666;
    font-size: 0.9rem; /* Slightly larger for better readability */
    margin: 0 0 8px 0;
    word-wrap: break-word; /* Prevent text overflow */
    overflow-wrap: break-word; /* Modern browsers */
    word-break: break-word; /* Ensure wrap even with long tokens */
    white-space: normal !important; /* Force wrap overriding theme */
    text-overflow: initial; /* Avoid ellipsis if applied elsewhere */
    max-width: 100%;
    width: 100%;
    display: block;
    line-height: 1.4; /* Better line spacing */
}

/* Subtítulo del punto: nombre del centro cuando el título es el profesional */
.vital-maps-point-subtitle {
    color: #333;
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    line-height: 1.35;
    word-break: break-word;
}

/* Horario de visita */
.vital-maps-point-schedule {
    color: #555;
    font-size: 0.85rem;
    margin: 6px 0 0 0;
    line-height: 1.35;
}

.vital-maps-point-schedule-label {
    font-weight: 600;
}

/* Nota final del punto (TextPlus tardío en el origen, p. ej. «Desp. 223») */
.vital-maps-point-note {
    color: #555;
    font-size: 0.85rem;
    font-style: italic;
    margin: 6px 0 0 0;
    line-height: 1.35;
}

.vital-maps-popup-note {
    color: #555;
    font-size: 0.9rem;
    font-style: italic;
    margin: 6px 0 0 0;
}

/* Horarios/notas que varían según la especialidad dentro de una misma ficha:
   se lista cada valor indicando a qué especialidad(es) corresponde. */
.vital-maps-point-schedule-detail {
    color: #555;
    font-size: 0.82rem;
    line-height: 1.35;
    margin: 2px 0 0 20px;
}

.vital-maps-point-schedule-esp {
    font-weight: 600;
    color: #333;
}

.vital-maps-popup-schedule-detail {
    color: #555;
    font-size: 0.85rem;
    line-height: 1.35;
    margin: 2px 0 0 18px;
}

/* ============================================================
   Bloque de centro: una sola tarjeta por clínica, con sus
   profesionales agrupados debajo bajo cada especialidad.
   ============================================================ */
.vital-maps-center-group {
    border-bottom: 1px solid #e9ecef;
}

.vital-maps-center-head {
    padding: 16px;
    background: #f6f8fd;
    border-left: 4px solid #001da1;
}

.vital-maps-center-head--clickable {
    cursor: pointer;
}

.vital-maps-center-head--clickable:hover {
    background: #eef2fb;
}

.vital-maps-center-title {
    font-weight: 700;
    color: #001da1;
    font-size: 1rem;
    line-height: 1.3;
    margin-bottom: 6px;
}

/* Las fichas de dentro se distinguen con una sangría sutil */
.vital-maps-center-members .vital-maps-point-item {
    padding-left: 26px;
    background: #ffffff;
}

/* Subgrupo por especialidad. Sin tarjeta de centro delante, esta cabecera es
   quien estructura el listado, así que lleva su mismo peso visual: fondo azulado
   y barra azul a la izquierda. */
.vital-maps-specialty-subhead {
    padding: 11px 16px 11px 12px;
    background: #f6f8fd;
    border-left: 4px solid #001da1;
    border-top: 1px solid #e9ecef;
    font-size: 0.95rem;
    line-height: 1.3;
    font-weight: 700;
    color: #001da1;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.vital-maps-popup-subtitle {
    color: #333;
    font-weight: 600;
    font-size: 0.95rem;
    margin: 2px 0 6px 0;
}

.vital-maps-popup-schedule {
    color: #555;
    font-size: 0.88rem;
    margin: 6px 0 0 0;
}

.vital-maps-point-categories {
    margin-top: 6px;
    font-size: 0.9rem;
    line-height: 1.45;
}

.vital-maps-point-categories-label {
    font-weight: 700;
    color: #555;
}

.vital-maps-point-categories-value {
    color: #666;
}

.vital-maps-point-category {
    background: #e3f2fd;
    color: #001da1;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
}

.vital-maps-point-item.active .vital-maps-point-category {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.vital-maps-point-item.active .vital-maps-point-categories-label,
.vital-maps-point-item.active .vital-maps-point-categories-value {
    color: white;
}

.vital-maps-sidebar-empty {
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

.vital-maps-sidebar-empty-icon {
    font-size: 2rem;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* Map without sidebar */
.vital-maps-map-container.no-sidebar #vital-maps-map {
    border-radius: 8px;
}

.vital-maps-map-container.no-sidebar .vital-maps-sidebar {
    display: none;
}

/* Loading State */
.vital-maps-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
    padding: 40px 20px;
}

/* Initial State (no category selected) */
.vital-maps-initial {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.vital-maps-initial-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.6;
}

.vital-maps-initial-title {
    color: #333;
    margin: 0 0 15px 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.vital-maps-initial-text {
    color: #666;
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
}

.vital-maps-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #001da1;
    border-radius: 50%;
    animation: vital-maps-spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.vital-maps-loading-text {
    font-size: 1.1rem;
    color: #666;
    margin: 0;
}

/* Empty States */
.vital-maps-empty {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.vital-maps-empty-icon {
    font-size: 3rem;
    color: #ddd;
    margin-bottom: 20px;
}

.vital-maps-empty-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 10px 0;
}

.vital-maps-empty-text {
    font-size: 1rem;
    color: #666;
    margin: 0;
}

/* Error States */
.vital-maps-error {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 6px;
    padding: 20px;
    margin: 20px 0;
    color: #c53030;
    text-align: center;
}

.vital-maps-error-title {
    font-weight: 600;
    margin: 0 0 8px 0;
}

.vital-maps-error-text {
    margin: 0;
    font-size: 0.95rem;
}

/* Success Messages */
.vital-maps-success {
    background: #f0fff4;
    border: 1px solid #9ae6b4;
    border-radius: 6px;
    padding: 15px;
    margin: 15px 0;
    color: #276749;
}

/* Info Messages */
.vital-maps-info {
    background: #ebf8ff;
    border: 1px solid #90cdf4;
    border-radius: 6px;
    padding: 15px;
    margin: 15px 0;
    color: #2c5282;
}

/* Select2 Integration */
.vital-maps-container .select2-container {
    width: 100% !important;
}

.vital-maps-container .select2-selection {
    border: 2px solid #e1e5e9 !important;
    border-radius: 6px !important;
    height: 48px !important;
    line-height: 48px !important;
    padding: 0 12px !important;
}

.vital-maps-container .select2-selection__rendered {
    color: #333 !important;
    line-height: 44px !important;
    padding: 0 !important;
}

.vital-maps-container .select2-selection:focus,
.vital-maps-container .select2-container--open .select2-selection {
    border-color: #001da1 !important;
    box-shadow: 0 0 0 3px rgba(0, 29, 161, 0.1) !important;
}

.vital-maps-container .select2-dropdown {
    border: 2px solid #001da1 !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.vital-maps-container .select2-results__option--highlighted {
    background-color: #001da1 !important;
}

/* Map Info Window Styles */
.vital-maps-info-window {
    max-width: 300px;
    padding: 15px;
    font-family: inherit;
}

.vital-maps-info-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #001da1;
    margin: 0 0 8px 0;
}

.vital-maps-info-content {
    font-size: 0.95rem;
    color: #666;
    line-height: 1.5;
    margin: 0;
}

.vital-maps-map-popup {
    max-width: 310px;
    padding: 12px 12px 10px;
    line-height: 1.35;
}

.vital-maps-popup-title {
    margin: 0 28px 8px 0;
    color: #001da1;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
}

.vital-maps-popup-address,
.vital-maps-popup-phone {
    margin: 0;
    color: #5f6675;
    font-size: 13px;
}

.vital-maps-popup-phone {
    margin-top: 8px;
}

.vital-maps-popup-phone-link {
    color: #001da1;
    text-decoration: none;
}

.vital-maps-popup-section {
    margin-top: 10px;
}

.vital-maps-popup-label {
    margin: 0;
    color: #5f6675;
    font-size: 13px;
}

.vital-maps-popup-specialties {
    margin-top: 4px;
    max-height: 74px;
    overflow-y: auto;
    padding-right: 3px;
    color: #5f6675;
    font-size: 13px;
}

.vital-maps-popup-actions {
    margin-top: 10px;
}

.vital-maps-popup-directions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 12px;
    border-radius: 6px;
    background: #001da1;
    color: #fff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 29, 161, 0.25);
}

.vital-maps-popup-directions:hover {
    background: #0a32bf;
    color: #fff;
}

/* Search Box */
.vital-maps-search {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 1rem;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

.vital-maps-search:focus {
    outline: none;
    border-color: #001da1;
    box-shadow: 0 0 0 3px rgba(0, 29, 161, 0.1);
}

.vital-maps-search::placeholder {
    color: #999;
}

/* Stats Counter */
.vital-maps-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

.vital-maps-stats-item {
    text-align: center;
}

.vital-maps-stats-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: #001da1;
    display: block;
}

.vital-maps-stats-label {
    font-size: 0.85rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===================================
 * RESPONSIVE DESIGN - MOBILE FIRST
 * =================================*/

/* Tablets and small desktops */
@media (min-width: 768px) {
    .vital-maps-fullwidth-container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: visible;
    }
    
    .vital-maps-main-layout {
        overflow: visible;
    }
}

/* Medium desktops */
@media (min-width: 1024px) {
    .vital-maps-fullwidth-container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: visible;
    }
    
    .vital-maps-main-layout {
        overflow: visible;
    }
}

/* Large desktops */
@media (min-width: 1200px) {
    .vital-maps-fullwidth-container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: visible;
    }
    
    .vital-maps-main-layout {
        overflow: visible;
    }
}

/* Extra large screens */
@media (min-width: 1400px) {
    .vital-maps-fullwidth-container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: visible;
    }
    
    .vital-maps-main-layout {
        overflow: visible;
    }
    
    .vital-maps-main-layout {
        height: 800px; /* Taller on large screens */
    }
    
    #vital-maps-map {
        min-height: 800px;
    }
    
    .vital-maps-sidebar {
        max-height: 800px;
    }
}

/* Ultra-wide screens */
@media (min-width: 1800px) {
    .vital-maps-main-layout {
        height: 900px;
    }
    
    #vital-maps-map {
        /* Sin reparto propio: se mantiene el 52/48 de la regla base. Antes aquí
           el mapa pasaba a 75% y la barra lateral a 25%, así que al cruzar los
           1800px la barra se encogía de golpe a la mitad. */
        min-height: 900px;
    }
    
    .vital-maps-sidebar {
        max-height: 900px;
    }
}

/* ================================
 * MOBILE LAYOUT (up to 768px) - REFACTORED
 * =================================*/

@media (max-width: 767px) {
    /* Basic wrapper adjustments */
    .vital-maps-wrapper {
        padding: 15px;
        margin: 0 auto;
        max-width: 100%;
        width: calc(100% - 20px);
    }
    
    .vital-maps-title {
        font-size: 1.8rem;
    }
    
    .vital-maps-controls-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Container adjustments for mobile */
    .vital-maps-fullwidth-container {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 10px 0 !important;
        border-radius: 8px;
        overflow: hidden !important;
    }
    
    .vital-maps-fullwidth-container.visible {
        transform: translateY(0) !important;
    }
    
    /* Main layout - simple column stack */
    .vital-maps-main-layout {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: auto !important;
        border-radius: 8px;
        width: 100% !important;
        max-width: 100% !important;
        gap: 0 !important;
        overflow: hidden !important;
    }
    
    /* Map container - MUST be flex to enable order property on children */
    .vital-maps-map-container {
        display: flex !important;
        flex-direction: column !important;
        position: static !important;
        height: auto !important; /* Auto height to contain both map and sidebar */
        width: 100% !important;
        border-radius: 8px !important;
        overflow: visible !important;
    }

    /* Map - compact mobile sizing - ORDER 1 (appears first) 
       Apply to #vital-maps-map regardless of parent container */
    #vital-maps-map {
        flex: none !important;
        width: 100% !important;
        height: clamp(290px, 46vh, 360px) !important;
        min-height: 290px !important;
        max-height: 360px !important;
        border-radius: 8px 8px 0 0 !important;
        order: 1 !important; /* MAP FIRST */
        position: relative !important; /* Necesario para que overflow:hidden recorte tiles de Google Maps */
        margin: 0 !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    
    /* Force Google Maps internal container to match parent height */
    #vital-maps-map .gm-style {
        height: clamp(290px, 46vh, 360px) !important;
        max-height: 360px !important;
    }
    
    #vital-maps-map .gm-style > div:first-child {
        height: clamp(290px, 46vh, 360px) !important;
        max-height: 360px !important;
    }
    
    /* Sidebar inside main-layout - ORDER 2 (appears second) */
    .vital-maps-main-layout > .vital-maps-sidebar {
        flex: none !important;
        width: 100% !important;
        min-width: auto !important;
        height: 400px !important;
        max-height: 400px !important;
        border-left: none !important;
        border-top: 2px solid #001da1 !important;
        border-radius: 0 0 8px 8px !important;
        order: 2 !important; /* SIDEBAR SECOND */
        background: #ffffff;
        position: relative !important;
        margin: 0 !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Sidebar inside map-container - ORDER 2 (appears second) */
    .vital-maps-map-container > .vital-maps-sidebar {
        flex: none !important;
        width: 100% !important;
        min-width: auto !important;
        height: 400px !important;
        max-height: 400px !important;
        border-left: none !important;
        border-top: 2px solid #001da1 !important;
        border-radius: 0 0 8px 8px !important;
        order: 2 !important; /* SIDEBAR SECOND */
        background: #ffffff;
        position: relative !important;
        margin: 0 !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* General sidebar rules for mobile (fallback) */
    .vital-maps-sidebar {
        flex: none !important;
        width: 100% !important;
        min-width: auto !important;
        height: 400px !important;
        max-height: 400px !important;
        border-left: none !important;
        border-top: 2px solid #001da1 !important;
        border-radius: 0 0 8px 8px !important;
        order: 2 !important;
        background: #ffffff;
        position: relative !important;
        margin: 0 !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .vital-maps-sidebar-header {
        padding: 12px 15px; /* Reduced padding for more space */
        background: #f8f9fa;
        border-bottom: 1px solid #e9ecef;
        flex-shrink: 0;
    }

    .vital-maps-sidebar-content {
        flex: 1;
        overflow-y: auto;
        padding: 0;
    }

    .vital-maps-point-item {
        padding: 12px 15px !important; /* Optimized padding for 4+ items */
        border-bottom: 1px solid #f0f0f0;
        cursor: pointer;
        transition: all 0.2s ease;
        word-wrap: break-word;
    }

    .vital-maps-point-item:hover {
        background-color: #f8f9fa;
    }

    .vital-maps-point-name {
        font-size: 0.9rem; /* Slightly smaller for more compact layout */
        font-weight: 500;
        line-height: 1.2; /* Tighter line height */
    }

    .vital-maps-point-address {
        font-size: 0.8rem; /* Smaller address text */
        color: #666;
        margin-top: 3px; /* Reduced margin */
        line-height: 1.2;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .vital-maps-fullwidth-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 5px 0 !important;
        border-radius: 6px;
    }
    
    /* Keep consistent with 767px media query - no override needed here */
    /* The 200px height from 767px media query works fine for small devices */
    
    .vital-maps-wrapper {
        padding: 10px;
        margin: 0 auto;
        width: calc(100% - 10px); /* Prevent overflow */
    }
    
    .vital-maps-title {
        font-size: 1.6rem;
    }
    
    .vital-maps-controls {
        padding: 15px;
    }

    #vital-maps-map {
        height: clamp(250px, 42vh, 300px) !important;
        min-height: 250px !important;
        max-height: 300px !important;
    }

    #vital-maps-map .gm-style,
    #vital-maps-map .gm-style > div:first-child {
        height: clamp(250px, 42vh, 300px) !important;
        max-height: 300px !important;
    }
    
    .vital-maps-point-item {
        padding: 18px 15px !important; /* Slightly less padding on tiny screens but still more than before */
        overflow: hidden; /* Prevent any horizontal overflow on small screens */
        word-wrap: break-word; /* Force long words to break on small screens */
    }
}

/* Accessibility */
.vital-maps-container *:focus {
    outline: 2px solid #001da1;
    outline-offset: 2px;
}

.vital-maps-container button:focus,
.vital-maps-container select:focus,
.vital-maps-container input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 29, 161, 0.3);
}

/* Screen Reader Only */
.vital-maps-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .vital-maps-container {
        border: 2px solid;
    }
    
    .vital-maps-btn {
        border: 2px solid;
    }
}

/* Google Maps Info Window Improvements */
.gm-style .gm-style-iw-c {
    max-width: min(320px, calc(100vw - 28px)) !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    border-radius: 12px !important;
}

.gm-style .gm-style-iw-d {
    overflow: visible !important;
    max-height: none !important;
    padding: 0 !important;
}

.gm-style .gm-ui-hover-effect {
    top: 4px !important;
    right: 4px !important;
    opacity: 1 !important;
}

.gm-style .gm-style-iw-ch {
    padding-top: 0 !important;
}

.gm-style .gm-style-iw-chr {
    margin: 0 !important;
    padding-top: 2px !important;
}

/* Mobile specific info window adjustments */
@media (max-width: 767px) {
    /* Permitir que el contenido de vital maps se expanda fuera de la columna Divi */
    .et_pb_code:has(.vital-maps-hub),
    .et_pb_code:has(.vital-maps-container) {
        overflow: visible !important;
    }

    /* Container: dentro del hub ya expandido, debe ocupar 100% natural */
    .vital-maps-container {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        transform: none !important;
    }

    .vital-maps-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 40px 0 !important; /* Espaciado fijo inferior siempre */
        padding: 14px !important;
    }

    /* Contenedor fullwidth: expandir al ancho disponible en mobile */
    .vital-maps-fullwidth-container {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .vital-maps-fullwidth-container .vital-maps-main-layout {
        overflow: hidden !important;
    }

    .gm-style .gm-style-iw-c {
        max-width: calc(100vw - 24px) !important;
        min-width: 0 !important;
    }
    
    .gm-style .gm-style-iw-d {
        overflow: visible !important;
        max-height: none !important;
    }
    
    .vital-maps-map-popup {
        max-width: min(320px, calc(100vw - 24px));
        padding: 10px 10px 9px;
    }

    .vital-maps-popup-title {
        margin-right: 24px;
        font-size: 14px;
    }

    .vital-maps-popup-address,
    .vital-maps-popup-specialties,
    .vital-maps-popup-phone {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .vital-maps-sidebar {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .vital-maps-sidebar-content {
        padding: 0 !important;
    }

    .vital-maps-point-item {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 14px 14px !important;
        box-sizing: border-box !important;
    }

    .vital-maps-sidebar-header {
        padding: 14px 14px !important;
    }

    .vital-maps-point-title,
    .vital-maps-point-address,
    .vital-maps-point-categories,
    .vital-maps-point-phone {
        width: 100%;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .vital-maps-popup-directions {
        min-height: 38px;
        width: 100%;
        touch-action: manipulation;
        font-size: 13px;
        font-weight: 700;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .vital-maps-popup-actions {
        display: block !important;
        margin-top: 8px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .vital-maps-container * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ================================
 * HIDDEN STATE - cuando el contenedor independiente está activo
 * =================================*/

/* Clase para ocultar COMPLETAMENTE el contenedor original cuando el fullwidth está activo */
.vital-maps-content.hidden-by-fullwidth,
.vital-maps-content.hidden-by-fullwidth *,
.vital-maps-content.hidden-by-fullwidth .vital-maps-main-layout,
.vital-maps-content.hidden-by-fullwidth .vital-maps-sidebar {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

/* Print Styles */
@media print {
    .vital-maps-wrapper {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .vital-maps-btn {
        display: none;
    }
    
    .vital-maps-map-container {
        border: 1px solid #ccc;
        background: #f9f9f9;
    }
}
