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

html {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
    max-width: 100%;
}

/* App layout: left nav panel + main content */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Left navigation panel - vertical grouped buttons */
.left-nav-panel {
    width: 220px;
    min-width: 220px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.98);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.06);
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-panel-inner {
    padding: 16px 12px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.nav-group-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    margin-bottom: 8px;
    padding: 0 10px;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-group-account {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    text-align: left;
    font-family: inherit;
    background: #f1f5f9;
    color: #334155;
}

.nav-btn:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.nav-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.nav-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Nav button group colors (optional – keep subtle, group by section) */
.nav-btn-hub:hover { background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%); color: white; }
.nav-btn-emergency:hover { background: #e53935; color: white; }
.nav-btn-airports:hover { background: #2196F3; color: white; }
.nav-btn-evacuation:hover { background: #4CAF50; color: white; }
.nav-btn-guard:hover { background: #FF6B35; color: white; }
.nav-btn-citizen:hover { background: #0ea5e9; color: white; }
.nav-btn-mutual:hover { background: linear-gradient(135deg, #059669 0%, #047857 100%); color: white; }
.nav-btn-analytics:hover { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.nav-btn-crime:hover { background: linear-gradient(135deg, #0f766e 0%, #134e4a 100%); color: white; }
.nav-btn-maritime:hover { background: linear-gradient(135deg, #0c4a6e 0%, #075985 100%); color: white; }
.nav-btn-lifeline:hover { background: linear-gradient(135deg, #0e7490 0%, #0891b2 100%); color: white; }
.nav-btn-rescuer:hover { background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%); color: white; }
.nav-btn-alerts:hover { background: #e53935; color: white; }
.nav-btn-health:hover { background: #00897B; color: white; }
.nav-btn-help:hover { background: #64748b; color: white; }
.nav-btn-admin:hover { background: #9C27B0; color: white; }
.nav-btn-profile:hover { background: #667eea; color: white; }
.nav-btn-logout { background: #fef2f2; color: #b91c1c; }
.nav-btn-logout:hover { background: #dc2626; color: white; }

.container {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 20px;
}

header {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow-x: hidden;
    min-width: 0;
    max-width: 100%;
}

.header-top {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    min-width: 0;
}

header h1 {
    color: #667eea;
    margin: 0;
    font-size: 28px;
    flex-shrink: 0;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Logout button in left nav (extends .nav-btn) */
.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-align: left;
}

.btn-logout:active {
    transform: translateX(0);
}

.btn-logout:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.logout-text {
    font-size: 13px;
}

.header-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    min-width: 0;
    max-width: 100%;
}

.filter-select {
    padding: 10px 12px;
    min-height: 44px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-select:hover {
    border-color: #667eea;
}

/* Language selector in header: compact, matches page */
.header-top .language-select-wrap {
    margin-left: 8px;
    flex-shrink: 0;
}
.header-top .language-select {
    max-width: 140px;
    min-width: 100px;
}

.btn-primary {
    padding: 10px 20px;
    min-height: 44px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-alerts-range {
    padding: 10px 14px;
    min-height: 44px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-alerts-range:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #334155;
}

.main-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    height: calc(100vh - 200px);
}

.map-container {
    position: relative;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 2; /* above legends so info windows never overlap */
}

.map-legend {
    position: absolute;
    top: 10px;
    right: 10px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 1; /* below map so info windows always on top */
    min-width: 150px;
}

/* Alert Types Legend - Left side of map */
.map-legend-left {
    left: 10px;
    right: auto;
}

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

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 12px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    position: relative;
}

/* Ensure satellite panel appears at top when visible */
.sidebar .satellite-panel[style*="display: block"],
.sidebar .satellite-panel:not([style*="display: none"]) {
    order: -1;
    margin-bottom: 20px;
}

.stats-panel,
.earthquake-list,
.weather-alerts-panel {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stats-panel h2,
.earthquake-list h2,
.weather-alerts-panel h2 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 20px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

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

.stat-label {
    color: #666;
    font-size: 14px;
}

.stat-value {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.list-container {
    max-height: 500px;
    overflow-y: auto;
}

.earthquake-item {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background 0.2s;
    border-left: 4px solid transparent;
}

.earthquake-item:hover {
    background: #f5f5f5;
}

.earthquake-item.selected {
    background: #e3f2fd;
    border-left-color: #667eea;
}

.earthquake-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.earthquake-magnitude {
    font-size: 20px;
    font-weight: bold;
    color: #333;
}

.earthquake-source {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 12px;
    background: #e0e0e0;
    color: #666;
    text-transform: uppercase;
}

.earthquake-location {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.earthquake-time {
    font-size: 12px;
    color: #999;
}

.earthquake-details {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

.error {
    text-align: center;
    padding: 40px;
    color: #f44336;
}

/* Magnitude-based colors */
.magnitude-2 { border-left-color: #9E9E9E !important; }
.magnitude-3 { border-left-color: #607D8B !important; }
.magnitude-4 { border-left-color: #4CAF50 !important; }
.magnitude-5 { border-left-color: #FFC107 !important; }
.magnitude-6 { border-left-color: #FF9800 !important; }
.magnitude-7 { border-left-color: #F44336 !important; }

/* Satellite Panel */
.satellite-panel {
    background: #ffffff !important;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    margin-bottom: 20px;
    overflow: hidden;
    border: 2px solid #e0e0e0 !important;
    position: relative !important;
    z-index: 1000 !important;
    width: 100% !important;
    max-height: 70vh;
    min-height: 300px;
    order: -1; /* Show at top of sidebar */
    display: none; /* Hidden by default */
    visibility: visible;
    flex-direction: column;
    isolation: isolate; /* Create new stacking context */
}

/* Force visibility when displayed */
.satellite-panel[style*="display: block"],
.satellite-panel[style*="display: flex"],
.sidebar .satellite-panel:not([style*="display: none"]) {
    display: flex !important;
    flex-direction: column !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.satellite-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-shrink: 0;
    min-height: 44px;
}

.satellite-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.satellite-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.satellite-header h2 {
    color: white;
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    line-height: 1;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.satellite-content {
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    display: block !important;
    background: #ffffff !important;
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #667eea #f0f0f0;
}

.satellite-content::-webkit-scrollbar {
    width: 8px;
}

.satellite-content::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 4px;
}

.satellite-content::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.satellite-content::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Loading Spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    text-align: center;
    color: #666;
    margin: 0;
}

/* Statistics Cards */
.satellite-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.satellite-stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.satellite-stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.satellite-label {
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.satellite-value {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

/* Image Gallery */
.satellite-gallery {
    margin-bottom: 25px;
}

.gallery-header {
    margin-bottom: 20px;
}

.gallery-header h3 {
    color: #667eea;
    font-size: 18px;
    margin: 0;
    font-weight: 600;
}

.image-comparison-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.comparison-item {
    display: flex;
    flex-direction: column;
}

.image-label {
    font-size: 13px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 10px;
    text-align: center;
    padding: 8px;
    background: #f0f4ff;
    border-radius: 6px;
}

.image-wrapper {
    position: relative;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.image-wrapper:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transform: scale(1.02);
}

.image-wrapper img {
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: contain;
    display: block;
}

.image-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.placeholder-icon {
    font-size: 48px;
    opacity: 0.5;
}

.change-detection-container {
    margin-top: 20px;
}

.change-info {
    margin-top: 10px;
    padding: 10px;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
    font-size: 12px;
    color: #856404;
}

/* Action Buttons */
.satellite-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-primary-action {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary-action:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a3d91 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary-action {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-secondary-action:hover {
    background: linear-gradient(135deg, #e081e8 0%, #e4455a 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.4);
}

.btn-action:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

.btn-icon {
    font-size: 18px;
}

.btn-text {
    font-size: 13px;
}

/* Cloud Filter */
.cloud-filter-controls {
    padding: 15px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.cloud-filter-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #333;
    font-weight: 600;
}

.filter-icon {
    font-size: 18px;
}

.cloud-filter-controls .filter-select {
    flex: 1;
    max-width: 150px;
}

/* Image Modal (for fullscreen view) */
.image-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.image-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
}

.image-modal-close:hover {
    color: #f44336;
}

.btn-secondary {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
    flex: 1;
}

.btn-secondary:hover {
    background: #5568d3;
}

.btn-secondary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Responsive design */
@media (max-width: 1024px) {
    .left-nav-panel {
        width: 180px;
        min-width: 180px;
    }

    .nav-panel-inner {
        padding: 12px 8px 20px;
        gap: 16px;
    }

    .nav-btn .nav-label {
        font-size: 12px;
    }

    .main-content {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .map-container {
        height: 500px;
    }
    
    .satellite-images {
        grid-template-columns: 1fr;
    }
    
    .image-comparison-container {
        grid-template-columns: 1fr;
    }
    
    .satellite-stats {
        grid-template-columns: 1fr;
    }
    
    .satellite-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    /* Left nav remains a left-side drawer on mobile (styled in mobile.css); do not convert to top strip */

    .container {
        padding: 10px;
    }
    
    header {
        padding: 15px;
    }
    
    .header-top {
        margin-bottom: 10px;
    }
    
    header h1 {
        font-size: 20px;
        margin-bottom: 10px;
    }
    
    .header-controls {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }
    
    .filter-select,
    .btn-primary {
        width: 100%;
        padding: 10px;
    }
    
    .map-container {
        height: 400px;
        border-radius: 8px;
    }
    
    /* Mobile: move legends below map so they never overlap info windows */
    .map-legend {
        position: relative;
        top: auto;
        right: auto;
        left: auto;
        margin: 10px;
        width: calc(100% - 20px);
        z-index: 0;
    }
    
    .map-legend-left {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        margin: 10px;
        width: calc(100% - 20px);
        z-index: 0;
    }
    
    .sidebar {
        gap: 15px;
    }
    
    .stats-panel,
    .earthquake-list {
        padding: 15px;
    }
    
    .earthquake-item {
        padding: 12px;
    }
    
    .satellite-panel {
        max-height: 80vh;
        min-height: 250px;
    }
    
    .satellite-content {
        padding: 12px;
    }
    
    .cloud-filter-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .cloud-filter-controls .filter-select {
        max-width: 100%;
        width: 100%;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 18px;
    }
    
    .nav-btn .nav-label {
        max-width: 72px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .map-container {
        height: 300px;
    }
    
    
    .earthquake-magnitude {
        font-size: 18px;
    }
    
    .earthquake-source {
        font-size: 10px;
        padding: 3px 6px;
    }
    
    .stat-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .satellite-stat-card {
        flex-direction: column;
        text-align: center;
    }
}

/* Profile incomplete banner - prompt user to fill necessary info */
.profile-incomplete-banner {
    background: linear-gradient(90deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px 16px 0;
    font-size: 14px;
    color: #92400e;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.profile-incomplete-banner a {
    color: #b45309;
    font-weight: 600;
    text-decoration: underline;
}
.profile-incomplete-banner a:hover {
    color: #92400e;
}
