/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #ffffff;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Header */
.header {
    flex-shrink: 0;
    /* background: rgb(255, 238, 238); */
    padding: 16px;
    border-radius: 2px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    /* gap: 16px; */
    /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
}

/* Drop-down Menu */
.drop-down-menu {
    display: flex;
    align-items: center;
}

.service-filter {
    padding: 10px 16px;
    border: 1px solid #D1D1E2;
    border-radius: 4px;
    font-size: 14px;
    color: #2D2D77;
    background: #ffffff;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease;
    min-width: 150px;
}

.service-filter:focus {
    border-color: #6A6AA2;
}

.service-filter:hover {
    border-color: #6A6AA2;
}

/* Search Bar */
.search-bar {
    position: relative;
    flex: 1;
    max-width: 400px;
}

#country-search {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid #D1D1E2;
    border-radius: 4px;
    font-size: 14px;
    color: #2D2D77;
    outline: none;
    transition: border-color 0.2s ease;
}

#country-search:focus {
    border-color: #6A6AA2;
}

#country-search::placeholder {
    color: #A0A0C0;
}

/* Search Results Dropdown */
.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #D1D1E2;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

.search-results.hidden {
    display: none;
}

.search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    color: #2D2D77;
    border-bottom: 1px solid #f0f0f0;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #F5F5FA;
}

.search-result-item.served {
    font-weight: 500;
}

.search-no-results {
    padding: 12px 16px;
    color: #999;
    font-style: italic;
    text-align: center;
}

/* Map Container */
.map-container {
    flex-shrink: 0;  /* Don't allow it to shrink */
    position: relative;
    overflow: hidden;
    border-radius: 2px;
    background: #ffffff;
    /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
    width: 100%;
    aspect-ratio: 2.4 / 1;  /* 360° longitude / 150° latitude = 2.4:1 */
    border: 2px solid #2d2d77;
}

/* SVG Map */
#map {
    width: 100%;
    height: 100%;
    display: block;
    cursor: default;
}

/* Footer */
.footer {
    flex-shrink: 0;
    /* background: rgb(239, 255, 243); */
    padding: 16px;
    border-radius: 2px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
}

.country-display {
    height: 28px;
    font-size: 28px;
    font-weight: 100;
    color: #2D2D77;
}

.service-display {
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: center;
    font-size: 16px;
    color: #2D2D77;
}

.service-label {
    font-size: 16px;
    font-weight: 200;
    font-style: italic;
    color: #2D2D77;
}

.service-badge {
    color: #ffffff;
    padding: 6px 16px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 14px;
}

.service-badge.ddu {
    background: #D5E47A;
}

.service-badge.ddp {
    background: #B05D7E;
}

/* Map Legend */
.map-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    backdrop-filter: blur(10px);
}

.map-legend h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #1e3a52;
    font-weight: 600;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-color {
    width: 24px;
    height: 16px;
    border-radius: 3px;
    margin-right: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.legend-color.served {
    background: #6ba3d0;
}

.legend-color.not-served {
    background: #e8ecef;
}

.legend-label {
    font-size: 14px;
    color: #333;
}

/* Country path styles */
.country {
    stroke: #ffffff;
    stroke-width: 0.5;
    transition: fill 0.2s ease, stroke-width 0.2s ease;
}

/* When a country is selected, make all non-active countries gray (default "Any Service" mode) */
body.has-selection.filter-any .country:not(.active) {
    fill: #D1D1E2;
}

/* When DDU filter is active and country is selected */
body.has-selection.filter-ddu .country.served-ddu:not(.active) {
    fill: #E8F1B7; /* Lighter green for non-selected DDU countries */
}

body.has-selection.filter-ddu .country.not-served:not(.active) {
    fill: #D1D1E2; /* Gray for countries without DDU */
}

/* When DDP filter is active and country is selected */
body.has-selection.filter-ddp .country.served-ddp:not(.active) {
    fill: #D9AFC0; /* Lighter mauve for non-selected DDP countries */
}

body.has-selection.filter-ddp .country.not-served:not(.active) {
    fill: #D1D1E2; /* Gray for countries without DDP */
}

/* Countries that are served by ACP */
.country.served {
    fill: #6A6AA2;
}

/* Countries with DDU service (when DDU filter is active) */
.country.served-ddu {
    fill: #D5E47A;
}

/* Countries with DDP service (when DDP filter is active) */
.country.served-ddp {
    fill: #B05D7E;
}

/* Only apply hover effects when no country is selected */
body:not(.has-selection) .country.served:hover,
body:not(.has-selection) .country.served-ddu:hover,
body:not(.has-selection) .country.served-ddp:hover {
    stroke: #2D2D77;
    stroke-width: 1;
    cursor: pointer;
}

.country.served.active {
    fill: #6A6AA2;
    stroke: #2D2D77;
    stroke-width: 1;
}

.country.served-ddu.active {
    fill: #D5E47A;
    stroke: #2D2D77;
    stroke-width: 1;
}

.country.served-ddp.active {
    fill: #B05D7E;
    stroke: #2D2D77;
    stroke-width: 1;
}

/* Countries not served */
.country.not-served {
    fill: #D1D1E2;
}

/* Only apply hover effects when no country is selected */
body:not(.has-selection) .country.not-served:hover {
    fill: #d0d8dd;
    stroke: #2D2D77;
    stroke-width: 1;
    cursor: pointer;
}

.country.not-served.active {
    fill: #D1D1E2;
    stroke: #2D2D77;
    stroke-width: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .map-legend {
        bottom: 15px;
        left: 15px;
        padding: 15px;
    }

    .map-legend h3 {
        font-size: 14px;
        margin-bottom: 10px;
    }

    .legend-label {
        font-size: 12px;
    }
}

