/**
 * ISPO Interactive Maps Styles
 */

/* ==========================================================================
   Map Wrapper & Layout
   ========================================================================== */

.ispo-map-wrapper {
    display: flex;
    position: relative;
    width: 100%;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ispo-map-container {
    flex: 1;
    min-height: 400px;
    height: 100%;
    z-index: 1;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.ispo-map-sidebar {
    width: 320px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
    z-index: 10;
    position: relative;
    flex-shrink: 0;
}

.ispo-map-sidebar.collapsed {
    margin-left: -320px;
}

/* Toggle button - high specificity to override Elementor */
.ispo-map-wrapper button.ispo-sidebar-toggle {
    position: absolute;
    left: 320px;
    top: 90px;
    right: auto;
    bottom: auto;
    width: 28px;
    height: 48px;
    min-width: 28px;
    min-height: 48px;
    background: #fff;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-left: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    z-index: 15;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    padding: 0;
    margin: 0;
    line-height: 1;
    transition: left 0.3s ease;
}

.ispo-map-wrapper.sidebar-collapsed button.ispo-sidebar-toggle {
    left: 0;
    border-left: 1px solid #e0e0e0;
}

.ispo-map-wrapper button.ispo-sidebar-toggle:hover, .ispo-map-wrapper button.ispo-sidebar-toggle:focus {
    background: #f5f5f5;
    background-color: #f5f5f5;
}

.ispo-toggle-icon {
    display: block;
    transition: transform 0.3s ease;
    line-height: 1;
    color: #666;
}

.ispo-map-wrapper.sidebar-collapsed .ispo-toggle-icon {
    transform: rotate(180deg);
}

.ispo-sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ispo-sidebar-header {
    display: none;
}

.ispo-sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

/* ==========================================================================
   Search Box
   ========================================================================== */

.ispo-search-box {
    padding: 15px;
    background: #34308f;
    display: flex;
    gap: 8px;
    align-items: center;
}

.ispo-search-input {
    flex: 1;
    padding: 10px 12px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    background: #fff;
}

.ispo-search-input::placeholder {
    color: #999;
}

.ispo-search-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   Filter Buttons
   ========================================================================== */

.ispo-filter-buttons {
    display: flex;
    gap: 8px;
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.ispo-filter-buttons .ispo-filter-btn {
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 20px;
    background: #fff;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #34308f;
}

.ispo-filter-buttons .ispo-filter-btn.active {
    background: #34308f;
    color: #fff;
    border-color: #34308f;
}

.ispo-filter-buttons .ispo-filter-btn[data-filter="clinical"].active {
    background: #3388ff;
    border-color: #3388ff;
}

.ispo-filter-buttons .ispo-filter-btn[data-filter="research"].active {
    background: #44bb44;
    border-color: #44bb44;
}

.ispo-filter-buttons .ispo-filter-btn[data-filter="both"].active {
    background: linear-gradient(90deg, #3388ff 50%, #44bb44 50%);
    border-color: #3388ff;
}

/* ==========================================================================
   Results List
   ========================================================================== */

.ispo-results-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.ispo-result-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
    border-left: 3px solid transparent;
}

.ispo-result-item:hover {
    background: #f5f9ff;
    border-left-color: #5B5FC7;
}

.ispo-result-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    background: #3388ff;
    color: #fff;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 12px;
}

.ispo-result-location {
    font-size: 14px;
    color: #333;
}

.ispo-result-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 12px;
    flex-shrink: 0;
}

.ispo-indicator-clinical {
    background: #3388ff;
}

.ispo-indicator-research {
    background: #44bb44;
}

.ispo-indicator-both {
    background: linear-gradient(90deg, #3388ff 50%, #44bb44 50%);
}

.ispo-result-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ispo-result-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ispo-result-info .ispo-result-location {
    font-size: 12px;
    color: #5B5FC7;
    margin-top: 2px;
}

.ispo-no-results,
.ispo-error {
    padding: 20px 15px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.ispo-error {
    color: #cc0000;
}

/* ==========================================================================
   Cluster Markers
   ========================================================================== */

.ispo-cluster-marker {
    background: transparent;
}

.ispo-cluster-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    border: 3px solid rgba(255, 255, 255, 0.8);
}

/* ==========================================================================
   Institution Markers
   ========================================================================== */

.ispo-marker {
    background: transparent;
}

.ispo-marker-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.ispo-marker-clinical {
    background: #3388ff;
}

.ispo-marker-research {
    background: #44bb44;
}

.ispo-marker-both svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* ==========================================================================
   Popups
   ========================================================================== */

.ispo-popup .leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0;
    overflow: hidden;
}

.ispo-popup .leaflet-popup-content {
    margin: 0;
    padding: 0;
    min-width: 200px;
}

.ispo-popup .leaflet-popup-close-button {
    display: none; /* Hide default close button, we'll use custom one */
}

.ispo-popup-header {
    background: #34308f;
    color: #fff;
    padding: 12px 15px;
    padding-right: 35px;
    position: relative;
}

.ispo-popup-content .ispo-popup-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.ispo-popup-content .ispo-popup-header button.ispo-popup-close {
    background: #fff;
    border: none;
    color: #34308f;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    position: absolute;
    top: 10px;
    right: 10px;
}

.ispo-popup-content .ispo-popup-header button.ispo-popup-close:hover {
    opacity: 1;
}

.ispo-popup-body {
    padding: 15px;
    background: #fff;
}

.ispo-popup-body .ispo-popup-contact-btn {
    margin-top: 15px;
}

.ispo-popup-location {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    font-size: 14px;
    color: #333;
}

.ispo-popup-location-icon {
    color: #5B5FC7;
    flex-shrink: 0;
}

.ispo-popup-content .ispo-popup-body .ispo-popup-website-btn {
    display: inline-block;
    background: #34308f;
    color: #fff;
    padding: 10px 24px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-top: 15px;
}

.ispo-popup-content .ispo-popup-body .ispo-popup-website-btn:hover {
    background: #4a45a8;
    color: #fff;
}

.ispo-popup-count {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #666;
}

.ispo-affiliation-list {
    margin: 0;
    padding: 0 0 0 20px;
    font-size: 13px;
}

.ispo-affiliation-list li {
    margin: 4px 0;
    color: #444;
}

.ispo-affiliation-list .ispo-more {
    color: #888;
    font-style: italic;
}

/* SIGUL Popup Specifics */
.ispo-type-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    margin-bottom: 10px;
}

.ispo-type-clinical {
    background: #e8f2ff;
    color: #3388ff;
}

.ispo-type-research {
    background: #e8f8e8;
    color: #2d882d;
}

.ispo-type-both {
    background: linear-gradient(90deg, #e8f2ff 50%, #e8f8e8 50%);
    color: #333;
}

.ispo-popup-body .ispo-department {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: #666;
    font-style: italic;
}

.ispo-popup-body .ispo-website {
    margin: 10px 0;
}

.ispo-popup-body .ispo-website a {
    color: #5B5FC7;
    text-decoration: none;
}

.ispo-popup-body .ispo-website a:hover {
    text-decoration: underline;
}

.ispo-popup-body .ispo-services,
.ispo-popup-body .ispo-research {
    margin: 10px 0;
    font-size: 13px;
}

.ispo-popup-body .ispo-services ul,
.ispo-popup-body .ispo-research ul {
    margin: 5px 0 0 0;
    padding: 0 0 0 20px;
}

.ispo-popup-body .ispo-services li,
.ispo-popup-body .ispo-research li {
    margin: 3px 0;
}

/* ==========================================================================
   Legend
   ========================================================================== */

.ispo-map-legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: #fff;
    padding: 12px 15px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    font-size: 12px;
}

.ispo-legend-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.ispo-legend-item {
    display: flex;
    align-items: center;
    margin: 5px 0;
}

.ispo-legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 8px;
}

.ispo-legend-label {
    color: #666;
}

/* ==========================================================================
   Loading Overlay
   ========================================================================== */

.ispo-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.ispo-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top-color: #3388ff;
    border-radius: 50%;
    animation: ispo-spin 0.8s linear infinite;
}

@keyframes ispo-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .ispo-map-wrapper {
        flex-direction: column;
    }

    .ispo-map-sidebar {
        width: 100%;
        max-height: 250px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        transition: max-height 0.3s ease;
    }

    .ispo-map-sidebar.collapsed {
        max-height: 0;
        margin-left: 0;
        overflow: hidden;
        border-bottom: none;
    }

    /* Toggle button - keep high specificity for mobile */
    .ispo-map-wrapper button.ispo-sidebar-toggle {
        left: auto;
        right: 10px;
        top: auto;
        bottom: -36px;
        width: 48px;
        height: 28px;
        min-width: 48px;
        min-height: 28px;
        border-radius: 0 0 4px 4px;
        border: 1px solid #e0e0e0;
        border-top: none;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .ispo-toggle-icon {
        transform: rotate(-90deg);
    }

    .ispo-map-wrapper.sidebar-collapsed .ispo-toggle-icon {
        transform: rotate(90deg);
    }

    .ispo-map-container {
        min-height: 350px;
    }

    .ispo-map-legend {
        bottom: 10px;
        right: 10px;
        padding: 8px 10px;
        font-size: 11px;
    }

    .ispo-filter-buttons {
        padding: 10px;
    }

    .ispo-filter-buttons .ispo-filter-btn {
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* ==========================================================================
   Admin Styles
   ========================================================================== */

.ispo-maps-admin-notice {
    padding: 10px 15px;
    margin: 10px 0;
    border-left: 4px solid #3388ff;
    background: #f0f6fc;
}

.ispo-maps-admin-notice.success {
    border-color: #44bb44;
    background: #f0fcf0;
}

.ispo-maps-admin-notice.error {
    border-color: #cc0000;
    background: #fcf0f0;
}
