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

:root {
    --primary-color: #059669;
    --primary-dark: #047857;
    --secondary-color: #64748b;
    --success-color: #059669;
    --warning-color: #d97706;
    --danger-color: #dc2626;
    --info-color: #0891b2;
    --light-bg: #f8fafc;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--light-bg);
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 1rem 0;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-icon {
    font-size: 1.5rem;
    color: var(--white);
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--white);
}

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

.language-selector {
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-sm);
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    font-size: 0.875rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.language-selector:hover {
    background: rgba(255, 255, 255, 0.2);
}

.language-selector:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.language-selector option {
    background: var(--gray-800);
    color: var(--white);
}

/* Mobile Toggle */
.mobile-toggle {
    display: flex;
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 0.25rem;
    margin: 1rem;
    box-shadow: var(--shadow);
    gap: 0.25rem;
}

.toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-btn.active {
    background: var(--primary-color);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

.toggle-btn:hover:not(.active) {
    background: var(--gray-100);
    color: var(--gray-700);
}

.toggle-btn i {
    font-size: 1rem;
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
    min-height: calc(100vh - 200px); /* Adjusted for header + report button + mobile toggle */
    display: flex;
    flex-direction: column;
}

/* Report Button Container */
.report-button-container {
    padding: 1rem;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: center;
    align-items: center;
}

.report-btn {
    width: 100%;
    max-width: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.report-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* View Containers */
.view-container {
    display: block; /* Always show both views */
    height: calc(50vh - 120px); /* Half height for each view */
    min-height: 300px;
    order: 1; /* Default order */
}

.view-container.active {
    order: 1; /* Active view comes first */
}

.view-container:not(.active) {
    order: 2; /* Inactive view comes second */
}

/* Map Container */
.map-container {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    margin: 0 1rem;
    height: 100%;
    order: 2; /* Map second by default */
}

/* When map view is active, reorder */
.main-content.map-view-active .list-container {
    order: 2;
}

.main-content.map-view-active .map-container {
    order: 1;
}

.map {
    width: 100%;
    height: 100%;
    min-height: 400px;
}

/* Floating Action Buttons */
.fab {
    position: absolute;
    bottom: 2rem; /* Increased from 1.5rem */
    right: 2rem; /* Increased from 1.5rem */
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: var(--shadow-xl);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 25px 50px -12px rgba(5, 150, 105, 0.4);
}

.fab:active {
    transform: scale(0.95);
}

.fab-secondary {
    position: absolute;
    bottom: 2rem; /* Increased from 1.5rem */
    right: 5.5rem; /* Adjusted for new fab position */
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--white);
    color: var(--gray-700);
    border: 2px solid var(--gray-200);
    font-size: 1rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    transform: scale(1.05);
}

/* List Container */
.list-container {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    margin: 0 1rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    order: 1; /* List first by default */
}

.list-header {
    padding: 1rem; /* Reduced from 1.5rem */
    border-bottom: 1px solid var(--gray-200);
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--white) 100%);
}

.list-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem; /* Reduced from 0.75rem */
    margin-bottom: 0.75rem; /* Reduced from 1rem */
    color: var(--gray-800);
    font-size: 1.125rem; /* Reduced from 1.25rem */
    font-weight: 700;
}

.list-header h2 i {
    color: var(--warning-color);
}

.filters {
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* Reduced from 1rem */
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem; /* Reduced from 0.5rem */
}

.filter-group label {
    display: flex;
    align-items: center;
    gap: 0.375rem; /* Reduced from 0.5rem */
    font-size: 0.8rem; /* Reduced from 0.875rem */
    font-weight: 600;
    color: var(--gray-700);
}

.filter-group label i {
    color: var(--primary-color);
}

.filter-select {
    padding: 0.625rem; /* Reduced from 0.75rem */
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem; /* Reduced from 0.875rem */
    background: var(--white);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

/* Incidents List */
.incidents-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.incident-item {
    padding: 1rem; /* Reduced from 1.25rem */
    border-bottom: 1px solid var(--gray-200);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.incident-item:hover {
    background: var(--gray-50);
}

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

.incident-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem; /* Reduced from 0.75rem */
}

.incident-type {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem; /* Reduced from 0.5rem */
    padding: 0.25rem 0.5rem; /* Reduced from 0.375rem 0.75rem */
    border-radius: var(--border-radius-sm);
    font-size: 0.7rem; /* Reduced from 0.75rem */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.incident-type.police { 
    background: #dcfce7; 
    color: #047857; 
}

.incident-type.radar { 
    background: #fed7aa; 
    color: #ea580c; 
}

.incident-type.accident { 
    background: #fecaca; 
    color: #dc2626; 
}

.incident-type.traffic { 
    background: #fef3c7; 
    color: #d97706; 
}

.incident-type.closure { 
    background: #e9d5ff; 
    color: #7c3aed; 
}

.incident-time {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem; /* Reduced from 0.75rem */
    color: var(--gray-500);
}

.incident-time i {
    font-size: 0.6rem; /* Reduced from 0.625rem */
}

.incident-title {
    font-weight: 600;
    margin-bottom: 0.375rem; /* Reduced from 0.5rem */
    color: var(--gray-800);
    font-size: 0.95rem; /* Reduced from 1rem */
}

.incident-description {
    font-size: 0.8rem; /* Reduced from 0.875rem */
    color: var(--gray-600);
    margin-bottom: 0.5rem; /* Reduced from 0.75rem */
    line-height: 1.4; /* Reduced from 1.5 */
}

.incident-votes {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem; /* Reduced from 1rem */
}

.vote-buttons {
    display: flex;
    gap: 0.375rem; /* Reduced from 0.5rem */
}

.vote-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem; /* Reduced from 0.375rem */
    padding: 0.375rem 0.5rem; /* Reduced from 0.5rem 0.75rem */
    border: 1px solid var(--gray-300);
    background: var(--white);
    border-radius: var(--border-radius-sm);
    font-size: 0.7rem; /* Reduced from 0.75rem */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.vote-btn:hover:not(.disabled) {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.vote-btn.voted {
    background: var(--success-color);
    color: var(--white);
    border-color: var(--success-color);
}

.vote-btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--gray-100);
    color: var(--gray-500);
    border-color: var(--gray-200);
}

.vote-count {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem; /* Reduced from 0.75rem */
    color: var(--gray-600);
    font-weight: 500;
}

.voted-indicator {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--success-color);
    font-weight: 500;
    font-size: 0.7rem; /* Reduced from 0.75rem */
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--gray-600);
    color: var(--white);
}

.btn-secondary:hover {
    background: var(--gray-700);
    transform: translateY(-1px);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    color: var(--gray-800);
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-header h3 i {
    color: var(--primary-color);
}

.close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--gray-500);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* Forms */
.incident-form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.875rem;
}

.form-group label i {
    color: var(--primary-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    transition: all 0.2s ease;
    background: var(--white);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Messages */
.message {
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    margin-top: 1rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message.success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.message.error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    gap: 1rem;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading p {
    color: var(--gray-600);
    font-weight: 500;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--gray-500);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
    color: var(--gray-400);
}

/* Leaflet Custom Styles */
.leaflet-popup-content-wrapper {
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
    margin: 1rem;
    line-height: 1.5;
}

.popup-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--gray-800);
    font-size: 1rem;
}

.popup-description {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.75rem;
}

.popup-meta {
    font-size: 0.75rem;
    color: var(--gray-500);
    border-top: 1px solid var(--gray-200);
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Custom marker styles with icons */
.custom-marker {
    border-radius: 50%;
    border: 3px solid var(--white);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--white);
    font-weight: bold;
}

.marker-police { 
    background: linear-gradient(135deg, #059669 0%, #047857 100%); 
}

.marker-radar { 
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); 
}

.marker-accident { 
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); 
}

.marker-traffic { 
    background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%); 
}

.marker-closure { 
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); 
}

/* Location Input Styles */
.location-input-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.location-input-container input {
    flex: 1;
}

.location-btn {
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    background: var(--white);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
}

.location-btn:hover {
    background: var(--gray-50);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.location-btn:active {
    background: var(--gray-100);
}

.location-btn.loading {
    background: var(--primary-color);
    color: var(--white);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Mini Map */
.mini-map {
    width: 100%;
    height: 200px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius-sm);
    margin-bottom: 0.5rem;
    background: var(--gray-50);
    position: relative;
    overflow: hidden;
}

.mini-map .leaflet-container {
    border-radius: var(--border-radius-sm);
}

.mini-map .leaflet-control-container {
    display: none;
}

.location-info {
    text-align: center;
    margin-top: 0.5rem;
}

.location-info small {
    color: var(--gray-500);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.75rem;
}

/* Responsive Design */
@media (min-width: 768px) {
    .main-content {
        display: flex;
        flex-direction: row;
        gap: 1rem;
        padding: 1rem;
    }
    
    .mobile-toggle {
        display: none;
    }
    
    .view-container {
        display: block !important;
        height: calc(100vh - 160px); /* Full height for desktop side-by-side layout */
    }
    
    .map-container {
        flex: 1;
        margin: 0;
        order: 2; /* Map on the right by default */
    }
    
    .list-container {
        width: 400px;
        margin: 0;
        order: 1; /* List on the left by default */
    }
    
    /* When map view is active on desktop, reorder */
    .main-content.map-view-active .list-container {
        order: 2;
    }
    
    .main-content.map-view-active .map-container {
        order: 1;
    }
    
    .filters {
        flex-direction: row;
        gap: 1rem;
    }
    
    .filter-group {
        flex: 1;
    }
    
    .form-actions {
        flex-direction: row;
    }
    
    .incident-votes {
        flex-direction: row;
    }
}

@media (max-width: 767px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    .header h1 {
        font-size: 1.125rem;
    }
    
    .list-header {
        padding: 0.75rem; /* Even more compact on mobile */
    }
    
    .list-header h2 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .filters {
        gap: 0.5rem;
    }
    
    .filter-group label {
        font-size: 0.75rem;
    }
    
    .filter-select {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    .incident-item {
        padding: 0.75rem; /* More compact on mobile */
    }
    
    .incident-title {
        font-size: 0.9rem;
    }
    
    .incident-description {
        font-size: 0.75rem;
        line-height: 1.3;
    }
    
    .fab {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 52px;
        height: 52px;
        font-size: 1.125rem;
    }
    
    .fab-secondary {
        bottom: 1.5rem;
        right: 5rem;
        width: 44px;
        height: 44px;
        font-size: 0.875rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .incident-votes {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .modal {
        padding: 0.5rem;
    }
    
    .modal-content {
        max-height: 95vh;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.75rem 0;
    }
    
    .header h1 {
        font-size: 1rem;
    }
    
    .list-header {
        padding: 1rem;
    }
    
    .incident-item {
        padding: 1rem;
    }
    
    .fab {
        bottom: 1.25rem;
        right: 1.25rem;
        width: 48px;
        height: 48px;
        font-size: 1rem;
    }
    
    .fab-secondary {
        bottom: 1.25rem;
        right: 4.25rem;
        width: 40px;
        height: 40px;
        font-size: 0.75rem;
    }
}