/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #333;
    background: #f5f5f5;
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

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

button {
    background: white;
    color: #667eea;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button:active {
    transform: translateY(0);
}

select {
    padding: 0.6rem 1rem;
    border: 2px solid white;
    border-radius: 5px;
    background: white;
    color: #667eea;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

/* Container Layout */
.container {
    display: flex;
    height: calc(100vh - 100px);
    overflow: hidden;
}

/* Sidebar */
aside {
    width: 350px;
    background: white;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

/* Stats Section */
.stats {
    padding: 1.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.8rem;
}

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

.stat-label {
    font-weight: 600;
    color: #666;
}

.stat-value {
    font-weight: 700;
    color: #667eea;
}

/* Legend */
.legend {
    padding: 1.5rem;
    background: white;
    border-bottom: 1px solid #e0e0e0;
}

.legend h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: #333;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.6rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    margin-right: 0.8rem;
}

/* Local Alerts Section */
.local-alerts-section {
    border-bottom: 2px solid #e0e0e0;
    background: #f0f8ff;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1rem 0.5rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.section-header h3 {
    font-size: 1rem;
    margin: 0;
}

.clear-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid white;
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 3px;
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.local-alerts-list {
    padding: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.local-alert-item {
    background: #fff !important;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15) !important;
}

.local-alert-item:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25) !important;
}

/* All Alerts Section */
.all-alerts-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.all-alerts-section h3 {
    padding: 1rem;
    margin: 0;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    font-size: 1rem;
}

/* Alerts List */
.alerts-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.alert-item {
    background: white;
    padding: 1rem;
    margin-bottom: 0.8rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.alert-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.alert-event {
    font-weight: 700;
    color: #333;
    flex: 1;
}

.alert-severity {
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-left: 0.5rem;
}

.alert-area {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}

.alert-time {
    color: #999;
    font-size: 0.8rem;
}

.loading,
.error,
.no-alerts {
    text-align: center;
    padding: 2rem;
    color: #999;
}

.error {
    color: #ff0000;
}

/* Main Content */
main {
    flex: 1;
    position: relative;
}

/* Map */
#map {
    width: 100%;
    height: 100%;
}

/* Custom Location Marker */
.custom-location-marker {
    background: none;
    border: none;
}

.location-marker-wrapper {
    position: relative;
    width: 40px;
    height: 40px;
}

.location-marker-pin {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 3px solid white;
    border-radius: 50% 50% 50% 0;
    transform: translateX(-50%) rotate(-45deg);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.location-marker-pin::after {
    content: '📍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    font-size: 16px;
}

.location-marker-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    background: rgba(102, 126, 234, 0.4);
    border-radius: 50%;
    animation: pulse 2s infinite;
    z-index: 1;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

/* Popup Styling */
.popup-content {
    font-size: 0.9rem;
}

.popup-content strong {
    color: #333;
    font-size: 1rem;
}

.popup-content em {
    color: #666;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 10px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.close:hover,
.close:focus {
    color: #333;
}

.modal-content h2 {
    color: #333;
    margin-bottom: 1.5rem;
    padding-right: 2rem;
}

.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section h3 {
    color: #667eea;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-section p {
    color: #666;
    line-height: 1.6;
    white-space: pre-wrap;
}

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

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

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

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

/* Mobile Toggle Button */
.mobile-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.mobile-toggle:active {
    transform: scale(0.95);
}

/* Responsive Design - Tablet */
@media (max-width: 1024px) {
    aside {
        width: 300px;
    }

    header h1 {
        font-size: 1.6rem;
    }
}

/* Responsive Design - Mobile */
@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    header {
        padding: 1rem;
        position: sticky;
        top: 0;
        z-index: 100;
    }

    header h1 {
        font-size: 1.3rem;
        margin-bottom: 0.75rem;
    }

    .controls {
        flex-direction: row;
        gap: 0.5rem;
    }

    .controls button,
    .controls select {
        font-size: 0.85rem;
        padding: 0.5rem 0.8rem;
        flex: 1;
    }

    .container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 120px);
    }

    /* Mobile sidebar - collapsible */
    aside {
        width: 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        position: relative;
        border-right: none;
        border-bottom: 2px solid #e0e0e0;
        order: 2;
    }

    aside.mobile-open {
        max-height: 70vh;
        overflow-y: auto;
    }

    .stats {
        padding: 1rem;
    }

    .legend {
        padding: 1rem;
    }

    .legend h3 {
        font-size: 0.9rem;
    }

    .alerts-list {
        padding: 0.75rem;
    }

    .local-alerts-list {
        padding: 0.75rem;
        max-height: 250px;
    }

    .alert-item {
        padding: 0.75rem;
        margin-bottom: 0.6rem;
    }

    .alert-item:hover,
    .local-alert-item:hover {
        transform: none;
    }

    .alert-event {
        font-size: 0.9rem;
    }

    .alert-area {
        font-size: 0.85rem;
    }

    .alert-time {
        font-size: 0.75rem;
    }

    /* Map takes priority on mobile */
    main {
        width: 100%;
        height: 50vh;
        min-height: 400px;
        order: 1;
    }

    #map {
        width: 100%;
        height: 100%;
    }

    /* Show mobile toggle button */
    .mobile-toggle {
        display: block;
    }

    /* Modal adjustments */
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 1.2rem;
        max-height: 85vh;
    }

    .modal-content h2 {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }

    .detail-section {
        margin-bottom: 1rem;
    }

    .detail-section h3 {
        font-size: 0.9rem;
    }

    .detail-section p {
        font-size: 0.9rem;
    }

    .close {
        font-size: 1.8rem;
    }

    /* Adjust location marker for mobile */
    .location-marker-wrapper {
        width: 35px;
        height: 35px;
    }

    .location-marker-pin {
        width: 25px;
        height: 25px;
    }

    .location-marker-pin::after {
        font-size: 14px;
    }

    /* Section headers */
    .section-header {
        padding: 0.75rem;
    }

    .section-header h3 {
        font-size: 0.9rem;
    }

    .all-alerts-section h3 {
        font-size: 0.9rem;
        padding: 0.75rem;
    }
}

/* Responsive Design - Small Mobile */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.1rem;
    }

    .controls {
        flex-wrap: wrap;
    }

    .controls button,
    .controls select {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }

    .stat-label,
    .stat-value {
        font-size: 0.85rem;
    }

    .legend-item {
        font-size: 0.85rem;
    }

    .legend-color {
        width: 16px;
        height: 16px;
    }

    main {
        height: 40vh;
        min-height: 300px;
    }

    .mobile-toggle {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
        bottom: 15px;
        right: 15px;
    }

    .modal-content {
        padding: 1rem;
    }

    .modal-content h2 {
        font-size: 1.1rem;
    }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    main {
        height: 60vh;
    }

    aside.mobile-open {
        max-height: 50vh;
    }
}
