/* Map page specific styles */

.map-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height));
}

.map-page__controls {
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    flex-shrink: 0;
}

.map-container {
    flex: 1;
    min-height: 400px;
}

/* Override Leaflet theme */
.leaflet-container {
    background: var(--color-bg);
    font-family: var(--font-sans);
}

.leaflet-popup-content-wrapper {
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
}

.leaflet-popup-tip {
    background: var(--color-surface);
}

.leaflet-popup-content {
    margin: .875rem 1rem;
    font-size: .85rem;
    line-height: 1.5;
}

.leaflet-control-zoom a {
    background: var(--color-surface) !important;
    color: var(--color-text) !important;
    border-color: var(--color-border) !important;
}
.leaflet-control-zoom a:hover {
    background: var(--color-surface-2) !important;
}

.leaflet-control-attribution {
    background: var(--color-header-bg) !important;
    color: var(--color-text-muted) !important;
    font-size: .65rem !important;
}
.leaflet-control-attribution a {
    color: var(--color-text-secondary) !important;
}

/* Alert popup in map */
.alert-popup { min-width: 200px; max-width: 320px; overflow-wrap: anywhere; }
.alert-popup--cluster { min-width: 180px; text-align: center; }
.alert-popup--cluster h3 { font-size: 1rem; margin-bottom: .4rem; }
.alert-popup--cluster .detail-link { display: block; margin-top: .3rem; }
.alert-popup .severity-badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 4px;
    font-size: .7rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .35rem;
}
.alert-popup h3 {
    font-size: .9rem;
    font-weight: 600;
    margin-bottom: .25rem;
    color: var(--color-text);
}
.alert-popup .area {
    color: var(--color-text-secondary);
    font-size: .8rem;
    margin-bottom: .15rem;
}
.alert-popup .source {
    color: var(--color-text-muted);
    font-size: .75rem;
}
.alert-popup .time {
    color: var(--color-text-muted);
    font-size: .75rem;
    margin-bottom: .35rem;
}
.alert-popup .detail-link {
    display: inline-block;
    margin-top: .35rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--color-primary);
}

/* ============= Country selector ============= */
.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;
}

.country-selector {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: .5rem .75rem;
    flex-shrink: 0;
}
.country-selector__row {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}
.country-selector__input-wrap {
    position: relative;
    flex: 1 1 220px;
    min-width: 180px;
    max-width: 320px;
}
.country-selector__input {
    width: 100%;
    padding: .4rem .65rem;
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md, 6px);
    font-size: .85rem;
    line-height: 1.3;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.country-selector__input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, .2);
}
.country-selector__clear {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm, 4px);
    padding: .35rem .7rem;
    font-size: .75rem;
    cursor: pointer;
    opacity: 1;
    transition: background .15s, color .15s, border-color .15s, opacity .2s;
}
.country-selector__clear[hidden] {
    display: inline-block;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}
.country-selector__clear:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
    border-color: var(--color-text-secondary);
}

/* Autocomplete dropdown */
.country-suggest {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1100;
    margin: 0;
    padding: .25rem 0;
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md, 6px);
    box-shadow: var(--shadow-lg);
    max-height: 280px;
    overflow-y: auto;
}
.country-suggest__item {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .35rem .65rem;
    font-size: .82rem;
    color: var(--color-text);
    cursor: pointer;
    transition: background .1s;
}
.country-suggest__item.is-active,
.country-suggest__item:hover {
    background: var(--color-surface-2);
}
.country-suggest__flag { font-size: 1rem; line-height: 1; }
.country-suggest__name { flex: 1; }
.country-suggest__count {
    font-size: .7rem;
    color: var(--color-text-muted);
    padding: 0 .4rem;
    background: var(--color-bg);
    border-radius: 999px;
    font-weight: 600;
}
.country-suggest__empty {
    padding: .5rem .75rem;
    font-size: .8rem;
    color: var(--color-text-muted);
    text-align: center;
}

/* Quick presets */
.country-presets {
    display: flex;
    gap: .3rem;
    flex-wrap: wrap;
}
.country-preset {
    background: var(--color-bg);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: .3rem .7rem;
    font-size: .75rem;
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}
.country-preset:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
    border-color: var(--color-primary);
}

/* Chips */
.country-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .5rem;
}
.country-chips:empty { display: none; }
.country-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .55rem;
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: .76rem;
    line-height: 1.3;
    cursor: pointer;
    max-width: 220px;
    transition: background .15s, border-color .15s;
}
.country-chip:hover {
    background: var(--color-surface-2);
    border-color: var(--color-primary);
}
.country-chip:focus-visible,
.country-preset:focus-visible,
.country-selector__clear:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-color: var(--color-primary);
}
.country-chip__flag { font-size: .9rem; line-height: 1; }
.country-chip__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.country-chip__count {
    font-size: .68rem;
    color: var(--color-text-muted);
    padding: 0 .35rem;
    background: var(--color-surface-2);
    border-radius: 999px;
    font-weight: 600;
}
.country-chip:hover .country-chip__count { background: var(--color-bg); }
.country-chip__x {
    color: var(--color-text-muted);
    font-size: .95rem;
    line-height: 1;
    margin-left: .1rem;
}
.country-chip:hover .country-chip__x { color: var(--color-primary); }

@media (max-width: 640px) {
    .country-selector { padding: .5rem .5rem; }
    .country-selector__row { gap: .35rem; }
    .country-selector__input-wrap { flex: 1 1 100%; max-width: none; }
    .country-presets { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .2rem; }
    .country-preset { white-space: nowrap; flex-shrink: 0; }
}
