/* ============================================
   PETA BANJIR PEKALONGAN v2.2
   With Firebase Auth & Evacuation Posts
   ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* MAP */
#map {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    background: #cbd5e1;
}

.map-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 999;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.leaflet-top.leaflet-right { top: 10px; right: 10px; }
.leaflet-control-zoom { border: none !important; box-shadow: 0 2px 10px rgba(0,0,0,0.15) !important; }
.leaflet-control-zoom a { width: 36px !important; height: 36px !important; line-height: 36px !important; font-size: 18px !important; border-radius: 8px !important; }

/* HEADER COMPACT */
.header-compact {
    position: fixed;
    top: 10px;
    left: 60px;
    z-index: 1000;
    background: white;
    padding: 10px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-compact span {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
}

/* USER INFO */
.user-info {
    position: fixed;
    top: 10px;
    right: 60px;
    z-index: 1000;
    background: white;
    padding: 8px 12px;
    border-radius: 25px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-info span {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-info button {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}

.user-info button:hover {
    color: #ef4444;
}

/* SIDEBAR TOGGLE */
.sidebar-toggle {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: white;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    transition: all 0.2s;
}

.sidebar-toggle:hover { background: #f1f5f9; color: #3b82f6; }

/* SIDEBAR */
.sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    width: 300px;
    max-width: 85vw;
    height: 100vh;
    background: white;
    z-index: 2000;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar.active { left: 0; }

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.sidebar-header h3 { font-size: 18px; font-weight: 700; color: #1e293b; }

.sidebar-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-section {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    overflow-y: auto;
}

.sidebar-section h4 {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.sidebar-overlay.active { opacity: 1; visibility: visible; }

/* STATS GRID */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-card {
    background: #f8fafc;
    padding: 12px;
    border-radius: 10px;
    text-align: center;
}

.stat-card.warning { background: #fef3c7; }
.stat-card.danger { background: #fee2e2; }
.stat-card.critical { background: #fecaca; }

.stat-num {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
}

.stat-card.warning .stat-num { color: #d97706; }
.stat-card.danger .stat-num { color: #dc2626; }
.stat-card.critical .stat-num { color: #b91c1c; }

.stat-label {
    display: block;
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
}

/* REPORTS LIST */
.reports-list {
    max-height: 200px;
    overflow-y: auto;
}

.list-loading {
    text-align: center;
    padding: 20px;
    color: #94a3b8;
    font-size: 13px;
}

.report-item {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 8px;
    overflow: hidden;
    background: white;
}

.report-item-header {
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background 0.2s;
}

.report-item-header:hover { background: #f8fafc; }

.report-item-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.report-item-title span {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.severity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.severity-dot.low { background: #3b82f6; }
.severity-dot.medium { background: #f59e0b; }
.severity-dot.high { background: #f97316; }
.severity-dot.critical { background: #ef4444; }

.report-item-arrow {
    color: #94a3b8;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.report-item.expanded .report-item-arrow { transform: rotate(180deg); }

.report-item-content {
    display: none;
    padding: 0 12px 12px;
    font-size: 12px;
    color: #475569;
    border-top: 1px solid #f1f5f9;
}

.report-item.expanded .report-item-content { display: block; }

.report-item-content p { margin: 6px 0; }
.report-item-content strong { color: #1e293b; }

.goto-btn {
    margin-top: 10px;
    padding: 8px 12px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
}

.goto-btn:hover { background: #2563eb; }

/* EVACUATION ITEM */
.evac-item {
    border: 1px solid #fbbf24;
    background: #fffbeb;
}

.evac-item .report-item-header:hover { background: #fef3c7; }

.evac-count {
    font-size: 12px;
    font-weight: 600;
    color: #d97706;
    background: #fef3c7;
    padding: 2px 8px;
    border-radius: 10px;
}

/* SIDEBAR NAV */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: white;
    color: #475569;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-btn:hover {
    background: #f1f5f9;
    color: #3b82f6;
    border-color: #3b82f6;
}

/* REPORT BUTTON */
.report-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    transition: all 0.3s;
}

.report-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(59, 130, 246, 0.5);
}

/* MODAL */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 20px;
    overflow-y: auto;
}

.modal.active { display: flex; }

.modal-content {
    background: white;
    border-radius: 24px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideUp 0.3s ease-out;
}

.modal-sm { max-width: 400px; }

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    border-radius: 24px 24px 0 0;
}

.modal-header h2 { font-size: 18px; font-weight: 700; color: #1e293b; }

.close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover { background: #e2e8f0; }

.modal-body { padding: 20px; }

@media (max-width: 768px) {
    .modal { padding: 0; align-items: flex-end; }
    .modal-content { max-height: 95vh; border-radius: 24px 24px 0 0; }
}

/* LOGIN BUTTONS */
.login-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.login-btn.google {
    background: white;
    color: #1e293b;
    border: 2px solid #e2e8f0;
}

.login-btn.google:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.login-btn.email {
    background: #3b82f6;
    color: white;
}

.login-btn.email:hover { background: #2563eb; }

.login-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: #94a3b8;
    font-size: 13px;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

.login-divider span { padding: 0 12px; }

.email-login-form input {
    margin-bottom: 12px;
}

/* FORM */
form { padding: 20px; }
.form-section { margin-bottom: 20px; }

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 10px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    margin-bottom: 10px;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.helper-text {
    font-size: 12px;
    color: #64748b;
    margin-top: -6px;
    margin-bottom: 10px;
}

@media (max-width: 768px) {
    .form-input, select.form-input { font-size: 16px; }
}

/* GPS BUTTON */
.gps-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.gps-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.gps-btn:disabled { opacity: 0.7; cursor: not-allowed; }

.location-divider {
    display: flex;
    align-items: center;
    margin: 16px 0;
    color: #94a3b8;
    font-size: 13px;
}

.location-divider::before,
.location-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

.location-divider span { padding: 0 12px; }

.manual-pick-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    color: #0369a1;
    font-size: 13px;
    margin-bottom: 12px;
}

.location-display {
    background: #f8fafc;
    font-family: monospace;
    font-size: 13px !important;
}

/* BUTTONS */
.btn {
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    width: 100%;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

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

.btn-loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ALERT */
#alertContainer {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 4000;
    max-width: 350px;
}

.alert {
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

.alert-success { background: #10b981; color: white; }
.alert-error { background: #ef4444; color: white; }

/* POPUP */
.leaflet-popup-content-wrapper { border-radius: 16px; padding: 0; }
.leaflet-popup-content { margin: 0; padding: 16px; min-width: 220px; }
.popup-content h3 { font-size: 15px; font-weight: 700; color: #1e293b; margin-bottom: 10px; }
.popup-content p { font-size: 12px; color: #475569; margin-bottom: 5px; }
.popup-content strong { color: #1e293b; }

.severity-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 8px;
}

.severity-low { background: #dbeafe; color: #1e40af; }
.severity-medium { background: #fef3c7; color: #92400e; }
.severity-high { background: #fed7aa; color: #9a3412; }
.severity-critical { background: #fee2e2; color: #991b1b; }

.popup-image, .popup-media {
    width: 100%;
    margin-top: 10px;
    border-radius: 8px;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .header-compact { left: 60px; padding: 8px 12px; }
    .header-compact span { font-size: 14px; }
    .sidebar { width: 280px; }
    .user-info { right: 10px; top: 60px; }
    .user-info span { display: none; }
    .report-btn { bottom: 20px; right: 16px; padding: 12px 20px; font-size: 14px; }
    #alertContainer { top: 60px; left: 10px; right: 10px; max-width: none; }
}

@media (hover: none) and (pointer: coarse) {
    .sidebar-btn, .btn, .gps-btn, .report-btn, .login-btn { min-height: 48px; }
}
