/* 
 * Prolific Research - Light-Theme Panel Explorer Stylesheet
 * Custom CSS for interactive SVG World Map, B2B/Consumer Tabs, and country info layouts.
 */

/* Explorer Section Wrapper styles to manage dynamic vertical padding */
.explorer-section {
    padding-top: 5.5rem; /* mobile nav clearance */
    padding-bottom: 0 !important; /* remove padding below map */
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

@media (min-width: 992px) {
    .explorer-section {
        padding-top: 5rem; /* desktop nav clearance (80px) */
        padding-bottom: 0 !important; /* remove padding below map */
    }
}

/* Layout & Header Wrapper */
.explorer-header-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    width: 100%;
}

.explorer-header-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.explorer-header-text h2 {
    font-size: 2.25rem;
    font-weight: 800;
    margin-top: 0.5rem;
    margin-bottom: 0;
    color: var(--text-primary);
}

.explorer-header-text p {
    max-width: 650px;
    margin: 0.75rem auto 0 auto;
    color: var(--text-secondary);
    line-height: 1.6;
}

.explorer-header-action {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

@media (min-width: 992px) {
    .explorer-header-wrapper {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
        align-items: center;
        gap: 3rem;
        margin-bottom: 1rem;
    }

    .explorer-header-text {
        align-items: flex-start;
        width: auto;
    }

    .explorer-header-text p {
        margin: 0.5rem 0 0 0;
        text-align: left;
    }

    .explorer-header-action {
        justify-content: flex-end;
    }
}

.explorer-tabs {
    display: inline-flex;
    background: rgba(15, 23, 42, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.35rem;
    border-radius: var(--radius-md);
    margin-top: 2rem;
}

.explorer-tab-btn {
    background: transparent;
    border: none;
    padding: 0.75rem 2rem;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.explorer-tab-btn.active {
    background: var(--color-cyan);
    color: var(--color-white);
    box-shadow: 0 4px 10px rgba(0, 130, 200, 0.2);
}

.explorer-grid {
    display: flex;
    flex-direction: column;
    gap: 1.0rem;
    align-items: center;
    width: 100%;
    max-width: 100%;
    padding: 0 0.5rem 0 !important; /* remove padding below map */
}

@media (min-width: 768px) {
    .explorer-grid {
        padding: 0 1rem 0 !important; /* remove padding below map */
    }
}

/* World Map Card (Border-less, transparent container) */
.map-card {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0.5rem;
    overflow: visible;
    position: relative;
    box-shadow: none;
    width: 100%;
}

#world-svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(0px 10px 20px rgba(15, 23, 42, 0.03));
    overflow: visible !important;
}

/* SVG Map Countries styling */
#world-svg path {
    fill: #e2e8f0; /* light slate default - visible shape contours */
    stroke: #ffffff; /* crisp white border separator */
    stroke-width: 0.6;
    transition: fill 0.3s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.3s cubic-bezier(0.4, 0, 0.2, 1), filter 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
}

/* Highlighted Supported Countries */
#world-svg path.supported-country,
#world-svg g.supported-country path {
    fill: #e2e8f0; /* Map is in clear grey color by default */
    stroke: #ffffff;
    stroke-width: 0.8;
    cursor: pointer;
}

#world-svg path.supported-country:hover,
#world-svg g.supported-country:hover path {
    fill: var(--color-cyan) !important;
    stroke: #ffffff;
    stroke-width: 1.0;
    filter: drop-shadow(0px 4px 12px rgba(0, 130, 200, 0.45));
}

/* Active Highlighted Country - Neutralized to be grey when not hovered */
#world-svg path.active-country,
#world-svg g.active-country path {
    fill: #e2e8f0 !important;
    stroke: #ffffff;
    stroke-width: 0.8;
    filter: none;
    animation: none;
}

/* Hover effect for active country (needs to highlight cyan like other supported countries) */
#world-svg path.active-country:hover,
#world-svg g.active-country:hover path {
    fill: var(--color-cyan) !important;
    stroke: #ffffff;
    stroke-width: 1.0;
    filter: drop-shadow(0px 4px 12px rgba(0, 130, 200, 0.45));
}

/* Custom Floating Map Tooltip */
.map-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(15, 23, 42, 0.95); /* Sleek semi-transparent dark grey */
    color: #ffffff;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-md);
    font-family: var(--font-heading), sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    white-space: nowrap;
    transform: translate(-50%, -100%) translateY(-10px);
}

.map-tooltip.active {
    opacity: 1;
    transform: translate(-50%, -100%) translateY(-15px);
}

.map-tooltip-title {
    font-weight: 700;
    color: #ffffff;
}

.map-tooltip-stats {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.map-tooltip-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    font-size: 0.75rem;
    line-height: 1.2;
}

.map-tooltip-stat .lbl {
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
}

.map-tooltip-stat .val {
    color: var(--color-cyan);
    font-weight: 700;
}

.map-tooltip-status {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
}

@keyframes activePulse {
    0% {
        filter: drop-shadow(0px 4px 8px rgba(141, 198, 63, 0.45));
    }
    50% {
        filter: drop-shadow(0px 8px 20px rgba(141, 198, 63, 0.75));
    }
    100% {
        filter: drop-shadow(0px 4px 8px rgba(141, 198, 63, 0.45));
    }
}

/* Sidebar Info Card */
.info-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    color: var(--text-secondary);
    box-shadow: var(--shadow-lg);
    width: 100%;
}

.country-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
}

.country-meta h3 {
    font-size: 2.25rem;
    margin-bottom: 0;
    color: var(--text-primary);
}

/* Stats Summary Row (Business, Consumer, Healthcare) */
.stats-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    width: 100%;
}

.stat-box-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    transition: var(--transition-normal);
}

.stat-box-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.stat-box-item.stat-business {
    border-top: 4px solid var(--color-cyan);
}

.stat-box-item.stat-consumer {
    border-top: 4px solid var(--color-green);
}

.stat-box-item.stat-healthcare {
    border-top: 4px solid var(--color-orange);
}

.stat-box-lbl {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-box-val {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}

.explorer-detail-section {
    margin-bottom: 1.8rem;
}

.explorer-detail-title {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.explorer-detail-title svg {
    color: var(--color-cyan);
}

.explorer-detail-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.explorer-badge-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.explorer-badge {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
}

.explorer-badge-cyan {
    background: rgba(0, 130, 200, 0.06);
    color: var(--color-cyan);
    border: 1px solid rgba(0, 130, 200, 0.15);
}

.explorer-badge-green {
    background: rgba(141, 198, 63, 0.06);
    color: var(--color-green);
    border: 1px solid rgba(141, 198, 63, 0.15);
}

/* Fallback Dropdown Wrapper */
.fallback-selector-wrapper {
    display: none;
    margin-bottom: 1.5rem;
    text-align: center;
}

.fallback-selector {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 0.95rem;
    width: 100%;
    max-width: 320px;
    cursor: pointer;
}

.fallback-selector:focus {
    outline: none;
    border-color: var(--color-cyan);
}

/* Map Country Labels overlay color for light mode */
#world-svg text {
    fill: var(--text-primary) !important;
}

/* Responsive Overrides */
@media (max-width: 1024px) {
    .fallback-selector-wrapper {
        display: block;
    }
}

@media (max-width: 768px) {
    .stats-summary-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    
    .country-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}

/* ==========================================================================
   Country Stats Popup Modal
   ========================================================================== */

/* Full Viewport blur-backed dark transparent overlay */
.country-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.45); /* deep slate tint */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999; /* ensure it stays on top of sticky header */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    padding: 1.5rem;
}

.country-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Modal Content Card container */
.country-modal-content {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px; /* Small, focused box */
    position: relative;
    box-shadow: 0 30px 60px -15px rgba(15, 23, 42, 0.22);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.country-modal-overlay.active .country-modal-content {
    transform: translateY(0) scale(1);
}

/* Close Button (Premium cross icon) */
.modal-close-btn {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    background: rgba(15, 23, 42, 0.03);
    border: 1px solid rgba(15, 23, 42, 0.05);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.6rem;
    font-weight: 300;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s ease;
    z-index: 10;
    padding-bottom: 3px; /* visual center alignment */
}

.modal-close-btn:hover {
    background: rgba(245, 130, 32, 0.08); /* slight warm accent glow */
    color: var(--color-orange);
    border-color: rgba(245, 130, 32, 0.2);
    transform: rotate(90deg) scale(1.05);
}

/* Adjustments for nested .info-card inside modal */
.country-modal-content .info-card {
    border: none;
    box-shadow: none;
    background: transparent;
    padding: 2.5rem 1.5rem 1.5rem 1.5rem; /* more compact for smaller width */
    margin: 0;
}

/* Modal Title layout styling */
.country-modal-content .country-meta h3 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

/* Stats grid vertical stack layout */
.country-modal-content .stats-summary-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    width: 100%;
}

/* Stat Card specific modifications for popup appearance (flex horizontal row style) */
.country-modal-content .stat-box-item {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.01);
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    transition: var(--transition-normal);
}

.country-modal-content .stat-box-item:hover {
    transform: translateX(4px); /* subtle horizontal slide instead of vertical */
    box-shadow: 0 8px 16px -6px rgba(15, 23, 42, 0.06);
}

/* Color left indicators on rows instead of top border */
.country-modal-content .stat-box-item.stat-business {
    border-top: none;
    border-left: 4px solid var(--color-cyan);
}

.country-modal-content .stat-box-item.stat-consumer {
    border-top: none;
    border-left: 4px solid var(--color-green);
}

.country-modal-content .stat-box-item.stat-healthcare {
    border-top: none;
    border-left: 4px solid var(--color-orange);
}

/* Custom spacing overrides for clean row alignment inside modal */
.country-modal-content .stat-box-lbl {
    margin-bottom: 0;
    font-size: 0.75rem;
    max-width: 60%;
}

.country-modal-content .stat-box-val {
    font-size: 1.6rem;
    text-align: right;
}

/* Desktop screen height adjustments to fit everything on one page without scrolling */
@media (min-width: 1025px) {
    .map-card {
        height: calc(100vh - 230px);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }
    #world-svg {
        width: 100%;
        height: 100%;
        max-height: 100%;
    }
}
