:root {
    --primary-color: #0056b3;
    --primary-dark: #003d80;
    --accent-color: #00a8e8;
    --bg-light: #f8f9fa;
    --text-dark: #333333;
    --text-muted: #666666;
    --white: #ffffff;
    --error-color: #d90429;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.9);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    color: var(--text-dark);
}

#map {
    height: 100vh;
    width: 100vw;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Sidebar Styling */
.sidebar {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 380px;
    max-height: calc(100vh - 40px);
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    z-index: 1000;
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 30px;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.3);
    overflow-y: auto;
}

@media (max-width: 600px) {
    .sidebar {
        width: calc(100% - 40px);
        top: 20px;
        left: 20px;
        padding: 20px;
    }
}

header {
    margin-bottom: 25px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.water-icon {
    width: 32px;
    height: 32px;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

.logo h1 span {
    font-weight: 300;
    color: var(--text-dark);
}

header p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-dark);
}

select, textarea, input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5eb;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: var(--white);
}

select:focus, textarea:focus, input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 86, 179, 0.1);
}

textarea {
    resize: none;
    height: 100px;
}

.coord-container {
    display: flex;
    gap: 10px;
}

.coord-container input {
    background: #f1f3f5;
    cursor: default;
}

#get-location {
    padding: 0 15px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#get-location:hover {
    background: var(--primary-dark);
}

#get-location svg {
    width: 20px;
    height: 20px;
}

/* Validation Message */
.validation-msg {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: rgba(217, 4, 41, 0.1);
    color: var(--error-color);
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 20px;
    border: 1px solid rgba(217, 4, 41, 0.2);
}

.validation-msg svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.hidden {
    display: none !important;
}

/* Submit Button */
.btn-submit {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 86, 179, 0.3);
}

.btn-submit:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(0, 86, 179, 0.4);
}

.btn-submit:active {
    transform: translateY(0);
}

/* Admin Toggle Button */
.btn-admin-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--white);
    border: 2px solid #e1e5eb;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.btn-admin-toggle:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-admin-toggle svg {
    width: 20px;
    height: 20px;
}

/* Admin Panel */
.admin-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 600px;
    height: 100vh;
    background: var(--white);
    z-index: 2000;
    box-shadow: -10px 0 30px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    padding: 30px;
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.admin-panel.hidden {
    transform: translateX(100%);
    display: flex !important; /* Overriding .hidden display:none to allow sliding animation */
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid #e1e5eb;
    padding-bottom: 15px;
}

.admin-header h2 {
    color: var(--primary-color);
    font-size: 1.4rem;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.btn-close:hover {
    color: var(--error-color);
}

.admin-filters {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.admin-filters select {
    width: auto;
    flex: 1;
}

.table-container {
    flex: 1;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid #e1e5eb;
}

#admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#admin-table th, #admin-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e1e5eb;
}

#admin-table th {
    background: var(--bg-light);
    font-weight: 600;
    position: sticky;
    top: 0;
}

#admin-table tbody tr:hover {
    background: #f8f9fa;
}

.status-select {
    padding: 6px 10px;
    font-size: 0.85rem;
    border-radius: 4px;
    border: 1px solid #ccc;
}

/* Status Colors (Select backgrounds) */
.status-select[data-status="Pending"] { background: #fee2e2; color: #991b1b; }
.status-select[data-status="In Review"] { background: #fef3c7; color: #92400e; }
.status-select[data-status="In Repair"] { background: #dbeafe; color: #1e40af; }
.status-select[data-status="Resolved"] { background: #d1fae5; color: #065f46; }

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--white);
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.modal-icon svg {
    width: 48px;
    height: 48px;
    margin-bottom: 15px;
}

.modal-content h3 {
    font-size: 1.25rem;
    margin-bottom: 10px;
    color: var(--text-dark);
}

.modal-content p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 25px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-actions button {
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    border: none;
}

.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e1e5eb; color: var(--text-dark); }
.btn-secondary:hover { background: #d1d5db; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { text-decoration: underline; }

/* Map Markers CSS Filters */
.marker-pending { filter: hue-rotate(150deg); } 
.marker-review { filter: hue-rotate(200deg); } 
.marker-repair { filter: hue-rotate(0deg); } 
.marker-resolved { filter: hue-rotate(270deg); opacity: 0.5; }

/* Spinner Animation */
.spinner {
    animation: rotate 2s linear infinite;
    width: 20px;
    height: 20px;
}

.spinner circle {
    stroke: white;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

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

@keyframes dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

footer {
    margin-top: auto;
    padding-top: 30px;
}

footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
}

/* ========================================== */
/* LOGIN & RBAC STYLES                        */
/* ========================================== */

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: rgba(255, 255, 255, 0.85);
    padding: 40px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.login-logo {
    justify-content: center;
    margin-bottom: 25px;
}

.login-hint {
    margin-top: 15px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* Logout Button */
.btn-logout {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--error-color);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: #b90324;
}

.btn-logout svg {
    width: 20px;
    height: 20px;
}

/* Role Based Visibility */
body[data-role="guest"] .sidebar,
body[data-role="guest"] .btn-admin-toggle,
body[data-role="guest"] .btn-logout {
    display: none !important;
}

body[data-role="citizen"] .btn-admin-toggle {
    display: none !important;
}

body[data-role="admin"] .login-overlay,
body[data-role="citizen"] .login-overlay {
    display: none !important;
}

body[data-role="admin"] .btn-logout,
body[data-role="citizen"] .btn-logout {
    display: flex !important;
}

/* ========================================== */
/* ADVANCED MODULES STYLES                    */
/* ========================================== */

/* User Stats & Badges */
.user-stats {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}
.badge.bronze { background: #cd7f32; color: white; }
.badge.silver { background: #c0c0c0; color: #333; }
.badge.gold { background: #ffd700; color: #333; }

.points {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* Sidebar follow zone button */
.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}
.btn-outline.active {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
}
.btn-outline svg {
    width: 20px;
    height: 20px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: var(--white);
    color: var(--text-dark);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    border-left: 4px solid var(--accent-color);
    animation: slideIn 0.3s ease-out forwards;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 300px;
}
.toast svg {
    width: 24px;
    height: 24px;
    color: var(--accent-color);
}
@keyframes slideIn {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Dashboard Tabs */
.admin-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e1e5eb;
    padding-bottom: 10px;
}
.tab-btn {
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.3s;
}
.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: -12px;
}
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
}
.tab-content.active {
    display: block;
}

.dashboard-stats {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-light);
    padding: 15px;
    border-radius: 8px;
    flex: 1;
    border: 1px solid #e1e5eb;
}
.stat-card h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}
.stat-card p {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.proof-img {
    max-width: 100%;
    margin-top: 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
}
