* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, #16213e 0%, #1a1a2e 100%);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
}

header h1 {
    font-size: 1.5rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

header h1::before {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #ff6b6b, #ffd93d, #6bcf63);
    border-radius: 50%;
}

.status {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#last-update {
    color: #888;
    font-size: 0.85rem;
}

#refresh-btn {
    background: #4a90d9;
    border: none;
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

#refresh-btn:hover {
    background: #357abd;
}

main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

#map-container {
    flex: 1;
    position: relative;
    min-width: 0;
    min-height: 600px;
}

#map {
    width: 100%;
    height: 100%;
    min-height: 600px;
    background: #b8d4e3;
}

#map-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem;
    border-radius: 8px;
    z-index: 1000;
    border: 1px solid #d0d7de;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#map-legend h4 {
    margin-bottom: 0.5rem;
    color: #57606a;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    margin: 0.3rem 0;
    color: #24292f;
}

.legend-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.legend-marker.warning {
    background: #bf8700;
}

.legend-marker.earthquake {
    background: #cf222e;
}

.legend-marker.volcano {
    background: #bc4c00;
}

.legend-marker.weather {
    background: #0969da;
}

.legend-marker.incident {
    background: #8250df;
}

.legend-marker.fire {
    background: #e53e3e;
}

.legend-marker.road {
    background: #2d3748;
}

/* District legend - bottom right */
#district-legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 0.75rem;
    border-radius: 8px;
    z-index: 1000;
    border: 1px solid #d0d7de;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-height: 280px;
    overflow-y: auto;
}

#district-legend h4 {
    margin-bottom: 0.4rem;
    color: #57606a;
    font-size: 0.7rem;
    text-transform: uppercase;
}

.district-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    color: #24292f;
    margin: 0.15rem 0;
}

.district-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    opacity: 0.7;
}

/* City tooltip styling */
.city-tooltip {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #d0d7de;
    border-radius: 4px;
    color: #24292f;
    font-size: 0.75rem;
    padding: 4px 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.city-tooltip::before {
    border-top-color: rgba(255, 255, 255, 0.95);
}

/* District tooltip styling */
.district-tooltip {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #d0d7de;
    border-radius: 4px;
    color: #24292f;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 4px 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#sidebar {
    width: 380px;
    background: #f6f8fa;
    overflow-y: auto;
    border-left: 1px solid #d0d7de;
}

.panel {
    border-bottom: 1px solid #d0d7de;
}

.panel h3 {
    background: #ffffff;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    color: #24292f;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.panel h3:hover {
    background: #e8f4fc;
}

.panel h3::after {
    content: '▼';
    font-size: 0.7rem;
    color: #57606a;
    transition: transform 0.3s;
    /* position the caret absolutely so it doesn't affect layout */
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.panel.collapsed h3::after {
    transform: rotate(-90deg);
}

.panel.collapsed .panel-content {
    display: none;
}

.panel.filter-active h3 {
    background: #ddf4ff;
    border-left: 3px solid #0969da;
}

.panel.filter-active h3::before {
    content: '◉ ';
    color: #0969da;
}

.count {
    background: #0969da;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    padding: 0.15rem 0;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-right: 8px; /* space before the caret */
}

.count.warning-count {
    background: #cf222e;
    animation: pulse-warning 2s infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

#warnings-panel {
    background: linear-gradient(135deg, rgba(207, 34, 46, 0.08) 0%, transparent 100%);
}

#warnings-panel h3 {
    background: rgba(207, 34, 46, 0.1);
}

.panel-content {
    padding: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
    background: #f6f8fa;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #57606a;
}

/* Alert Items */
.alert-item {
    background: #ffffff;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    border: 1px solid #d0d7de;
}

.alert-item:hover {
    background: #e8f4fc;
    transform: translateX(2px);
}

.alert-item.severity-high {
    border-left: 3px solid #cf222e;
}

.alert-item.severity-medium {
    border-left: 3px solid #bf8700;
}

.alert-item.severity-low {
    border-left: 3px solid #1a7f37;
}

.alert-item .title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: #24292f;
}

.alert-item .meta {
    font-size: 0.75rem;
    color: #57606a;
    display: flex;
    justify-content: space-between;
}

.alert-item .description {
    font-size: 0.8rem;
    color: #57606a;
    margin-top: 0.3rem;
    line-height: 1.4;
}

/* Weather Card - compact for 17 regions */
.weather-card {
    background: linear-gradient(135deg, #e8f4fc 0%, #ffffff 100%);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.4rem;
    border: 1px solid #d0d7de;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.weather-card .region {
    font-size: 0.8rem;
    font-weight: 600;
    color: #24292f;
    min-width: 100px;
}

.weather-card .temp {
    font-size: 1.2rem;
    font-weight: 500;
    color: #0969da;
    min-width: 50px;
}

.weather-card .description {
    flex: 1;
    color: #3d4550;
    font-size: 0.8rem;
}

.weather-card .conditions {
    display: flex;
    gap: 0.6rem;
    font-size: 0.75rem;
    color: #3d4550;
}

.weather-card .condition {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

/* Volcano Card */
.volcano-card {
    background: #ffffff;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #d0d7de;
}

.volcano-card .name {
    font-weight: 500;
    color: #24292f;
}

.volcano-card .level {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.volcano-card .level-0 {
    background: #1a7f37;
    color: #fff;
}

.volcano-card .level-1 {
    background: #bf8700;
    color: #fff;
}

.volcano-card .level-2 {
    background: #bc4c00;
    color: #fff;
}

.volcano-card .level-3,
.volcano-card .level-4,
.volcano-card .level-5 {
    background: #cf222e;
    color: #fff;
}

/* Incident Item */
.incident-item {
    background: #ffffff;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid #d0d7de;
}

.incident-item .title {
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    color: #24292f;
}

.incident-item .time {
    font-size: 0.75rem;
    color: #57606a;
}

.incident-item .source {
    font-size: 0.7rem;
    color: #0969da;
    margin-top: 0.3rem;
}

/* Error state */
.error {
    color: #cf222e;
    text-align: center;
    padding: 1rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f6f8fa;
}

::-webkit-scrollbar-thumb {
    background: #d0d7de;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #afb8c1;
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    background: #ffffff;
    color: #24292f;
    border-radius: 8px;
    border: 1px solid #d0d7de;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-tip {
    background: #ffffff;
}

.leaflet-popup-content {
    margin: 0.75rem;
}

.popup-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #24292f;
}

.popup-meta {
    font-size: 0.8rem;
    color: #57606a;
}

/* Subtle map attribution */
.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.8) !important;
    color: #57606a !important;
    font-size: 0.55rem !important;
    padding: 2px 5px !important;
}

.leaflet-control-attribution a {
    color: #0969da !important;
}

/* Developer Button */
#developer-btn {
    position: fixed;
    bottom: 20px;
    right: 160px;
    background: rgba(255, 255, 255, 0.9);
    color: #57606a;
    border: 1px solid #d0d7de;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

#developer-btn:hover {
    background: #ffffff;
    color: #24292f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Donate Button */
#donate-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #0969da;
    color: #fff;
    border: 1px solid #0969da;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
}

#donate-btn:hover {
    background: #0860ca;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(9, 105, 218, 0.3);
}

/* Donate Floating Popup */
#donate-popup {
    display: none;
    position: fixed;
    bottom: 60px;
    right: 20px;
    width: 280px;
    background: #ffffff;
    border-radius: 10px;
    padding: 1rem;
    z-index: 2000;
    border: 1px solid #d0d7de;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

#donate-popup.active {
    display: block;
}

#donate-popup h2 {
    margin: 0 0 0.5rem 0;
    color: #24292f;
    font-size: 1rem;
    padding-right: 24px;
}

#donate-popup > p {
    color: #57606a;
    font-size: 0.75rem;
    margin-bottom: 0.75rem;
}

.popup-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: #57606a;
    font-size: 1.2rem;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    line-height: 1;
}

.popup-close:hover {
    background: #f3f4f6;
    color: #24292f;
}

/* Donate Links */
.donate-links {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.donate-link {
    display: block;
    padding: 0.5rem 0.6rem;
    background: #f6f8fa;
    border-radius: 6px;
    text-decoration: none;
    color: #24292f;
    font-size: 0.75rem;
    transition: all 0.2s;
    border: 1px solid #d0d7de;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.donate-link:hover {
    background: #ddf4ff;
    border-color: #0969da;
    color: #0969da;
}

.donate-link .donate-icon {
    margin-right: 0.4rem;
}

.popup-footer {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid #d0d7de;
    text-align: center;
    font-size: 0.65rem;
    color: #57606a;
}

/* Responsive */
@media (max-width: 900px) {
    main {
        flex-direction: column;
    }

    #map-container {
        height: 50vh;
    }

    #sidebar {
        width: 100%;
        height: 50vh;
    }

    #developer-btn {
        bottom: 10px;
        right: 120px;
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }

    #donate-btn {
        bottom: 10px;
        right: 10px;
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }

    .popup-content {
        padding: 1.5rem;
    }
}
