/* Modern CSS Reset and Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --secondary: #f1f5f9;
    --accent: #10b981;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --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);
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Unified Button System */

/* Base Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.5;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    min-height: 2.75rem;
    white-space: nowrap;
    user-select: none;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-light);
}

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

/* Primary Button (Main CTA) */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, var(--primary-dark) 0%, #1e3a8a 100%);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-md);
}

/* Secondary Button */
.btn-secondary {
    background: var(--surface);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary:active:not(:disabled) {
    transform: translateY(0);
    background: var(--primary-light);
}

/* Success Button */
.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.btn-success:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-md);
}

/* Danger/Error Button */
.btn-danger {
    background: linear-gradient(135deg, var(--error) 0%, #dc2626 100%);
    color: white;
    border-color: var(--error);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.btn-danger:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-md);
}

/* Ghost Button (Transparent) */
.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border-color: transparent;
    box-shadow: none;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--surface-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-ghost:active:not(:disabled) {
    transform: translateY(0);
    background: var(--border-light);
}

/* Outline variants */
.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Button Sizes */
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 2.25rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    min-height: 3.25rem;
}

.btn-xl {
    padding: 1.25rem 2.5rem;
    font-size: 1.25rem;
    min-height: 3.75rem;
}

/* Full width button */
.btn-block {
    width: 100%;
}

/* Button with icon */
.btn-icon {
    padding: 0.875rem;
    min-width: 2.75rem;
}

.btn-icon.btn-sm {
    padding: 0.5rem;
    min-width: 2.25rem;
}

.btn-icon.btn-lg {
    padding: 1rem;
    min-width: 3.25rem;
}

/* Loading state */
.btn-loading {
    position: relative;
    color: transparent;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-left: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: inherit;
}

.btn-primary.btn-loading::after {
    color: white;
    border-color: white;
    border-left-color: transparent;
}

/* Button Groups */
.btn-group {
    display: inline-flex;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.btn-group .btn {
    border-radius: 0;
    border-right-width: 1px;
    margin-left: -1px;
}

.btn-group .btn:first-child {
    border-top-left-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-lg);
    margin-left: 0;
}

.btn-group .btn:last-child {
    border-top-right-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    border-right-width: 2px;
}

.btn-group .btn:only-child {
    border-radius: var(--radius-lg);
    border-width: 2px;
}

/* Override for form submit buttons to maintain full width */
.search-form .btn {
    width: 100%;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    text-align: center;
    padding: 2rem;
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.loading-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.loading-message {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.loading-progress {
    width: 100%;
    max-width: 16rem;
    height: 0.25rem;
    background: var(--border);
    border-radius: 9999px;
    overflow: hidden;
    margin: 0 auto;
}

.loading-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0; transform: translateX(0); }
    50% { width: 60%; }
    100% { width: 100%; transform: translateX(0); }
}

/* Main Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-light);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.credits-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, var(--primary-light), var(--surface));
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--primary);
    box-shadow: var(--shadow-sm);
}

.credits-icon {
    width: 2rem;
    height: 2rem;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.875rem;
}

.credits-info {
    display: flex;
    flex-direction: column;
}

.credits-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.credits-count {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
}

/* Search Section */
.search-section {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 3rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-light);
}

.search-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.search-title {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.search-subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

.search-form {
    max-width: 48rem;
    margin: 0 auto;
}

.form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input,
.form-select {
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    background: var(--surface);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.city-input {
    grid-column: span 2;
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Results Section */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* KPI Section */
.kpi-section {
    grid-column: span 2;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    text-align: center;
    transition: all 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.kpi-icon {
    width: 3rem;
    height: 3rem;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.25rem;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.kpi-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Map Card */
.map-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}

.card-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-hover);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.card-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.map-container {
    height: 400px;
    background: var(--secondary);
}

.map-legend {
    padding: 1.5rem 2rem;
    background: var(--surface-hover);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.legend-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.legend-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.legend-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-dot.excellent { background: #10b981; }
.legend-dot.good { background: #f59e0b; }
.legend-dot.poor { background: #ef4444; }

.legend-note {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Insights Card */
.insights-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.insights-content {
    padding: 2rem;
    line-height: 1.7;
    color: var(--text-primary);
}

/* Form Error Styling */
.form-input.error,
.form-select.error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.error-message {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    font-weight: 500;
}

/* Leaflet Map Customizations */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid var(--border) !important;
}

.leaflet-popup-content {
    font-family: inherit !important;
    font-size: 0.875rem !important;
    line-height: 1.5 !important;
    color: var(--text-primary) !important;
    margin: 8px 12px !important;
}

.leaflet-popup-content h4 {
    color: var(--text-primary) !important;
    font-weight: 600 !important;
    margin: 0 0 8px 0 !important;
}

.leaflet-control-zoom a {
    background-color: var(--surface) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
}

.leaflet-control-zoom a:hover {
    background-color: var(--primary) !important;
    color: white !important;
}

.leaflet-container {
    border-radius: 0 !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    .kpi-section {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }

    .title {
        font-size: 2rem;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .header {
        padding: 1.5rem;
    }

    .search-section {
        padding: 2rem 1.5rem;
    }

    .search-title {
        font-size: 1.5rem;
    }

    .search-subtitle {
        font-size: 1rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .city-input {
        grid-column: span 1;
    }

    .kpi-section {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .kpi-card {
        padding: 1.25rem;
    }

    .map-container {
        height: 350px;
    }

    .map-legend {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .legend-group {
        flex-wrap: wrap;
    }

    .card-header {
        padding: 1.25rem 1.5rem;
    }

    .insights-content {
        padding: 1.5rem;
    }

    /* Responsive button adjustments */
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.875rem;
        min-height: 2.5rem;
    }
    
    .btn-sm {
        padding: 0.5rem 0.875rem;
        font-size: 0.8125rem;
        min-height: 2rem;
    }
    
    .btn-lg {
        padding: 0.875rem 1.75rem;
        font-size: 1rem;
        min-height: 3rem;
    }
    
    .btn-xl {
        padding: 1rem 2rem;
        font-size: 1.125rem;
        min-height: 3.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.25rem;
    }

    .title {
        font-size: 1.75rem;
    }

    .credits-badge {
        padding: 0.5rem 1rem;
        gap: 0.5rem;
    }

    .credits-icon {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.75rem;
    }

    .search-section {
        padding: 1.5rem 1rem;
    }

    .kpi-section {
        grid-template-columns: repeat(2, 1fr);
    }

    .kpi-card {
        padding: 1rem;
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .map-container {
        height: 300px;
    }
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeInUp 0.6s ease-out forwards;
    opacity: 0;
    transform: translateY(30px);
}

.animate-delay-1 { 
    animation-delay: 0.1s; 
}

.animate-delay-2 { 
    animation-delay: 0.2s; 
}

.animate-delay-3 { 
    animation-delay: 0.3s; 
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus improvements */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* Toast notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--surface);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    max-width: 400px;
    font-weight: 500;
}

.toast.toast-success {
    border-left: 4px solid var(--success);
}

.toast.toast-error {
    border-left: 4px solid var(--error);
}

.toast.toast-info {
    border-left: 4px solid var(--primary);
}

/* Utility classes */
.text-center {
    text-align: center;
}

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeInUp 0.6s ease-out;
}
.user-menu-trigger span {
    color: white !important;
    font-weight: 600;
    opacity: 1;
}
/* Mobile menu styles - ADD THIS */
.mobile-nav-section {
    display: none;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 0.5rem;
}

.nav-header {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
}

/* Show mobile menu on small screens - ADD THIS */
@media (max-width: 768px) {
    .mobile-nav-section {
        display: block;
    }
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.export-csv-btn {
    background: var(--accent);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.export-csv-btn:hover {
    background: #059669;
    transform: translateY(-1px);
}