/* ============================================
   PREMIUM WORLD MAP WITH LOCATION PINS
   Interactive Global Network Visualization
   75% Map + 25% Legend Layout
   ============================================ */

/* ===== MAIN CONTAINER (75-25 LAYOUT) ===== */
.world-map-main-container {
    display: flex;
    gap: 24px;
    width: 100%;
    margin-bottom: 40px;
}

/* ===== WORLD MAP CONTAINER (75%) ===== */
.world-map-container {
    flex: 0 0 75%;
    background: linear-gradient(135deg, #f8faf9 0%, #ffffff 100%);
    border-radius: 24px;
    padding: 32px 32px 0 32px; /* Remove bottom padding */
    height: auto;
    min-height: 0;
    box-shadow: 
        0 4px 24px rgba(127, 166, 155, 0.08),
        0 0 0 1px rgba(127, 166, 155, 0.08);
    position: relative;
    overflow: hidden;
}

.world-map-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: radial-gradient(circle at 50% 0%, rgba(127, 166, 155, 0.03) 0%, transparent 70%);
    pointer-events: none;
}

.world-map-wrapper {
    position: relative;
    width: 100%;
    /* Natural height (driven by the map image) to avoid any bottom whitespace */
    height: auto;
    min-height: 0;
    overflow: hidden;
    border-radius: 12px;
}

/* ===== SVG WORLD MAP STYLING ===== */
.world-map-svg {
    position: relative;
    width: 100%;
    height: auto;
    z-index: 1;
    display: block;
    line-height: 0; /* Remove potential bottom gap from inline-block display */
}

.world-map-svg img,
.world-map-svg svg,
.world-map-svg object {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    object-position: center;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.05));
    transform: scale(1.02); /* Slight scale to ensure full coverage */
}

/* Ensure the map image can never leave empty space below it */
#worldMapImage {
    width: 100% !important;
    height: auto !important;
    display: block !important;
}

.world-map-svg svg path {
    fill: #e8f0ed;
    stroke: #7FA69B;
    stroke-width: 0.5;
    transition: all 0.3s ease;
}

.world-map-svg svg path:hover {
    fill: #d4e6df;
    stroke: #6b9186;
    stroke-width: 0.8;
}

/* ===== MAP MARKERS OVERLAY ===== */
.map-markers-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* ===== LOCATION MARKER STYLES ===== */
.location-marker {
    position: absolute;
    pointer-events: all;
    cursor: pointer;
    z-index: 10;
    transform: translate(-50%, -50%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    will-change: transform;
}

.location-marker:hover {
    z-index: 100;
}

/* ===== MARKER PIN ===== */
.marker-pin {
    position: relative;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: relative;
    z-index: 2;
    box-shadow: 
        0 0 0 2px rgba(255, 255, 255, 0.9),
        0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.location-marker:hover .marker-dot {
    transform: scale(1.3);
    box-shadow: 
        0 0 0 3px rgba(255, 255, 255, 1),
        0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ===== PULSING ANIMATION ===== */
.marker-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    opacity: 0;
    animation: marker-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes marker-pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.8;
    }
    50% {
        opacity: 0.4;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* ===== HIGHLIGHTED MARKER STATE ===== */
.location-marker.highlighted {
    z-index: 100 !important;
}

.location-marker.highlighted .marker-dot {
    transform: scale(1.4);
    box-shadow: 
        0 0 0 3px rgba(255, 255, 255, 1),
        0 0 20px rgba(127, 166, 155, 0.6),
        0 4px 16px rgba(0, 0, 0, 0.3);
}

.location-marker.highlighted .marker-pulse {
    animation: marker-pulse-highlight 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes marker-pulse-highlight {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

/* ===== LEGEND HOVER STATE ON MARKERS ===== */
.location-marker.legend-hover .marker-dot {
    transform: scale(1.3);
    box-shadow: 
        0 0 0 3px rgba(255, 255, 255, 1),
        0 0 15px rgba(127, 166, 155, 0.5),
        0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ===== MARKER COLORS BY TYPE ===== */
/* Head Quarter - Gold */
.hq-marker .marker-dot {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
}

.hq-marker .marker-pulse {
    background: radial-gradient(circle, #FFD700 0%, transparent 70%);
}

/* Corporate - Blue */
.corporate-marker .marker-dot {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
}

.corporate-marker .marker-pulse {
    background: radial-gradient(circle, #4A90E2 0%, transparent 70%);
}

/* Manufacturing - Red */
.manufacturing-marker .marker-dot {
    background: linear-gradient(135deg, #E74C3C 0%, #C0392B 100%);
}

.manufacturing-marker .marker-pulse {
    background: radial-gradient(circle, #E74C3C 0%, transparent 70%);
}

/* Warehouse - Green/Sage */
.warehouse-marker .marker-dot {
    background: linear-gradient(135deg, #7FA69B 0%, #6b9186 100%);
}

.warehouse-marker .marker-pulse {
    background: radial-gradient(circle, #7FA69B 0%, transparent 70%);
}

/* Sourcing - Purple */
.sourcing-marker .marker-dot {
    background: linear-gradient(135deg, #9B59B6 0%, #8E44AD 100%);
}

.sourcing-marker .marker-pulse {
    background: radial-gradient(circle, #9B59B6 0%, transparent 70%);
}

/* ===== MARKER TOOLTIP ===== */
.marker-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 18px;
    border-radius: 12px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 0 0 1px rgba(127, 166, 155, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    white-space: nowrap;
    z-index: 1000;
}

.marker-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(255, 255, 255, 0.98);
}

.location-marker:hover .marker-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-16px);
}

.tooltip-header {
    font-weight: 600;
    font-size: 0.875rem;
    color: #2d3748;
    margin-bottom:15px;
}

.tooltip-location {
    font-size: 0.75rem;
    color: #7FA69B;
    font-weight: 500;
}

/* ===== PREMIUM LEGEND ===== */
.network-legend-premium {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    padding: 24px 28px;
    box-shadow: 
        0 4px 24px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(127, 166, 155, 0.08);
    margin-top: 32px;
}

.legend-title {
    font-weight: 600;
    font-size: 1rem;
    color: #2d3748;
    margin-bottom: 20px;
    letter-spacing: -0.02em;
}

.legend-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.legend-item-premium {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(248, 250, 249, 0.8);
    border-radius: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

.legend-item-premium:hover {
    background: rgba(127, 166, 155, 0.08);
    border-color: rgba(127, 166, 155, 0.2);
    transform: translateY(-2px);
}

.legend-marker {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Legend marker colors */
.legend-item-premium[data-type="headquarters"] .legend-dot {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
}

.legend-item-premium[data-type="corporate"] .legend-dot {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
}

.legend-item-premium[data-type="manufacturing"] .legend-dot {
    background: linear-gradient(135deg, #E74C3C 0%, #C0392B 100%);
}

.legend-item-premium[data-type="warehouse"] .legend-dot {
    background: linear-gradient(135deg, #7FA69B 0%, #6b9186 100%);
}

.legend-item-premium[data-type="sourcing"] .legend-dot {
    background: linear-gradient(135deg, #9B59B6 0%, #8E44AD 100%);
}

.legend-text {
    font-size: 0.875rem;
    color: #4a5568;
    font-weight: 500;
}

/* ===== LEGEND SIDEBAR (25%) ===== */
.network-legend-sidebar {
    flex: 0 0 25%;
    background: linear-gradient(135deg, #ffffff 0%, #f8faf9 100%);
    border-radius: 24px;
    padding: 32px 24px;
    box-shadow: 
        0 4px 24px rgba(127, 166, 155, 0.08),
        0 0 0 1px rgba(127, 166, 155, 0.08);
    display: flex;
    flex-direction: column;
}

.legend-sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.legend-sidebar-content .legend-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 8px;
    font-family: 'Exo 2', sans-serif;
}

.legend-sidebar-content .legend-subtitle {
    font-size: 0.875rem;
    color: #718096;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 2px solid rgba(127, 166, 155, 0.15);
}

.legend-items-vertical {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
}

.legend-items-vertical .legend-item-premium {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: white;
    border-radius: 12px;
    border: 2px solid rgba(127, 166, 155, 0.1);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.legend-items-vertical .legend-item-premium:hover {
    background: rgba(127, 166, 155, 0.05);
    border-color: rgba(127, 166, 155, 0.25);
    transform: translateX(4px);
}

.legend-items-vertical .legend-item-premium.active {
    background: rgba(127, 166, 155, 0.1);
    border-color: #7FA69B;
}

.legend-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.legend-info .legend-text {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #2d3748;
}

.legend-info .legend-count {
    font-size: 0.75rem;
    color: #718096;
    font-weight: 500;
}

.legend-footer {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid rgba(127, 166, 155, 0.15);
}

.legend-note {
    font-size: 0.8125rem;
    color: #718096;
    text-align: center;
    margin: 0;
    font-style: italic;
}

/* ===== RESPONSIVE - TABLET ===== */
@media (max-width: 1024px) {
    .world-map-main-container {
        flex-direction: column;
        gap: 24px;
    }
    
    .world-map-container,
    .network-legend-sidebar {
        flex: 0 0 100%;
    }
    
    .world-map-container {
        padding: 36px 36px 0 36px;
        height: auto;
        min-height: 0;
    }
    
    .network-legend-sidebar {
        padding: 24px;
    }
    
    .legend-items-vertical {
        gap: 16px;
    }
    
    .marker-pin {
        width: 24px;
        height: 24px;
    }
    
    .marker-dot {
        width: 12px;
        height: 12px;
    }
}

/* ===== RESPONSIVE - MOBILE ===== */
@media (max-width: 768px) {
    .world-map-main-container {
        flex-direction: column;
        gap: 16px;
        margin-bottom: 24px;
    }
    
    .world-map-container,
    .network-legend-sidebar {
        flex: 0 0 100%;
        height: auto !important; /* Ensure container shrinks to content */
    }
    
    .world-map-container {
        padding: 20px 20px 0 20px;
        min-height: 0 !important;
        height: auto !important;
        border-radius: 18px;
    }
    
    .network-legend-sidebar {
        padding: 20px 16px;
        border-radius: 18px;
    }
    
    .legend-sidebar-content .legend-title {
        font-size: 1.25rem;
        margin-bottom: 16px;
    }
    
    .legend-items-vertical {
        gap: 10px;
    }
    
    .legend-items-vertical .legend-item-premium {
        padding: 10px 12px;
    }
    
    .legend-info .legend-text {
        font-size: 0.875rem;
    }
    
    .world-map-wrapper {
        height: auto;
    }
    
    .world-map-svg img {
        height: 100%;
    }
    
    .marker-pin {
        width: 18px;
        height: 18px;
    }
    
    .marker-dot {
        width: 10px;
        height: 10px;
        box-shadow: 
            0 0 0 2px rgba(255, 255, 255, 0.9),
            0 2px 6px rgba(0, 0, 0, 0.12);
    }
    
    .marker-pulse {
        width: 20px;
        height: 20px;
    }
    
    .marker-tooltip {
        padding: 10px 14px;
        border-radius: 10px;
        font-size: 0.8rem;
    }
    
    .tooltip-header {
        font-size: 0.8rem;
    }
    
    .tooltip-location {
        font-size: 0.7rem;
    }
    
    .network-legend-premium {
        padding: 20px 20px;
        border-radius: 14px;
        margin-top: 24px;
    }
    
    .legend-title {
        font-size: 0.95rem;
        margin-bottom: 16px;
    }
    
    .legend-items-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .legend-item-premium {
        padding: 12px 14px;
    }
    
    .legend-text {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .world-map-container {
        padding: 20px 20px 0 20px;
        min-height: 0 !important;
        height: auto !important;
        border-radius: 16px;
    }
    
    .marker-pin {
        width: 18px;
        height: 18px;
    }
    
    .marker-dot {
        width: 9px;
        height: 9px;
    }
    
    .network-legend-premium {
        padding: 18px 16px;
    }
    
    .legend-title {
        font-size: 0.9rem;
    }
    
    .legend-item-premium {
        padding: 10px 12px;
    }
}

/* ===== RESPONSIVE - SMALL MOBILE ===== */
@media (max-width: 480px) {
    .world-map-main-container {
        gap: 12px;
        margin-bottom: 20px;
    }
    
    .world-map-container {
        padding: 16px 16px 16px 16px; /* Balanced padding */
        border-radius: 16px;
        height: auto !important; /* Force auto height */
        min-height: 0 !important;
    }
    
    .world-map-wrapper {
        min-height: 0 !important;
        height: auto !important;
        margin-bottom: 0 !important;
    }
    
    .network-legend-sidebar {
        padding: 16px 12px;
        border-radius: 16px;
    }
    
    .legend-sidebar-content .legend-title {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }
    
    .legend-items-vertical {
        gap: 8px;
    }
    
    .legend-items-vertical .legend-item-premium {
        padding: 8px 10px;
        gap: 10px;
    }
    
    .legend-marker {
        width: 20px;
        height: 20px;
    }
    
    .legend-info .legend-text {
        font-size: 0.8rem;
    }
    
    .legend-info .legend-count {
        font-size: 0.7rem;
    }
    
    .world-map-wrapper {
        aspect-ratio: 16 / 7;
        height: auto;
    }
    
    .world-map-svg img {
        height: 100%;
    }
    
    .marker-pin {
        width: 16px;
        height: 16px;
    }
    
    .marker-dot {
        width: 8px;
        height: 8px;
    }
    
    .marker-tooltip {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    .marker-pulse {
        animation: none;
    }
    
    .location-marker,
    .marker-dot,
    .marker-tooltip {
        transition: none;
    }
}

/* ===== INTERACTIVE STATES ===== */
.legend-item-premium.active {
    background: rgba(127, 166, 155, 0.12);
    border-color: rgba(127, 166, 155, 0.3);
}

.location-marker.highlighted {
    z-index: 101;
}

.location-marker.highlighted .marker-dot {
    transform: scale(1.3);
    animation: marker-highlight 1s ease-in-out infinite;
}

@keyframes marker-highlight {
    0%, 100% {
        box-shadow: 
            0 0 0 4px rgba(255, 255, 255, 1),
            0 0 16px currentColor;
    }
    50% {
        box-shadow: 
            0 0 0 6px rgba(255, 255, 255, 1),
            0 0 24px currentColor;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .world-map-container {
        box-shadow: none;
        border: 1px solid #e2e8f0;
    }
    
    .marker-pulse {
        display: none;
    }
    
    .marker-tooltip {
        display: none;
    }
}
