/* ==================== GLOBAL VARIABLES ==================== */
:root {
    /* Colors - Light Mode */
    --primary: #3B82F6;
    --primary-dark: #2563EB;
    --primary-light: #60A5FA;
    --accent: #F59E0B;
    --success: #10B981;
    --error: #EF4444;
    --warning: #F59E0B;

    /* Backgrounds */
    --bg-primary: #F8FAFC;
    --bg-secondary: #F1F5F9;
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-card-hover: rgba(255, 255, 255, 0.85);

    /* Text */
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;

    /* Glass effect */
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    --radius-xl: 2rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
}


/* ==================== RESET ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color var(--transition-base);
}

/* ==================== BACKGROUND GRADIENTS ==================== */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(245, 158, 11, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    /* Removed heavy image overlay for performance */
}

/* Static background — no shimmer animation for better performance */
@keyframes shimmer-bg {

    0%,
    100% {
        transform: translateZ(0);
    }
}

/* Light mode body background */
body {
    background: #F0F4FF;
}

/* Performance hint for glass cards */
.glass-card {
    will-change: transform;
    contain: layout style;
}


/* ==================== LOADING SCREEN ==================== */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
}

.loading-logo {
    width: 90px;
    height: 90px;
    margin: 0 auto 1.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    position: relative;
    overflow: hidden;
}

.loading-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.loading-logo__glow {
    position: absolute;
    inset: -6px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.35), transparent 70%);
    filter: blur(8px);
    border-radius: 50%;
    z-index: -1;
}

.loading-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* ==================== GLASS CARD ==================== */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--glass-shadow);
    transition: all var(--transition-base);
}

.glass-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
}

.glass-card-strong {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(30px);
}


/* ==================== APP CONTAINER ==================== */
.app-container {
    min-height: 100vh;
    padding-bottom: 80px;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

.page-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Mobile First - Optimized for phones */
@media (max-width: 480px) {
    .page-content {
        padding: 0.75rem;
        padding-top: 1rem;
    }

    body {
        font-size: 15px;
    }
}

/* ==================== BOTTOM NAVIGATION ==================== */
.bottom-nav {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: min(320px, 84%);
    background: rgba(9, 13, 30, 0.25);
    border-radius: 999px;
    padding: 0.35rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.15rem;
    z-index: 100;
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: 0 14px 24px rgba(3, 6, 23, 0.15);
    backdrop-filter: blur(36px);
}

.bottom-nav.hidden {
    display: none;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    background: transparent;
    border-radius: 999px;
    padding: 0.25rem 0.4rem;
    border: none;
    position: relative;
    transition: transform 0.2s ease;
    color: rgba(255, 255, 255, 0.65);
}

.nav-item i {
    font-size: 1.25rem;
}

.nav-item span {
    font-size: 0.75rem;
    font-weight: 500;
}

.nav-item.active {
    color: #ffffff;
}

.nav-item:hover {
    transform: translateY(-1px);
    color: #fff;
}

.nav-item .badge {
    position: absolute;
    top: 0.25rem;
    right: 0.6rem;
    background: rgba(239, 68, 68, 0.85);
    color: white;
    font-size: 0.6rem;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    min-width: 16px;
    text-align: center;
    box-shadow: 0 6px 15px rgba(239, 68, 68, 0.5);
}

.bottom-nav::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    pointer-events: none;
}

.nav-item.active::after {
    content: '';
    position: absolute;
    inset: 0.3rem;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.45), transparent 70%);
    opacity: 0.65;
    z-index: -1;
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

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

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

.btn-secondary {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: var(--bg-card);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
}

.btn-ghost:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}


.btn-full {
    width: 100%;
}

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

/* ==================== FORM ELEMENTS ==================== */
.input-group {
    margin-bottom: var(--spacing-lg);
}

.input-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.input-field {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

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

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

textarea.input-field {
    resize: vertical;
    min-height: 100px;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
    position: fixed;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    max-width: 90vw;
}

.toast {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    min-width: 300px;
    animation: slideInRight 0.3s ease;
}

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

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

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

.toast i {
    font-size: 1.25rem;
}

.toast-success i {
    color: var(--success);
}

.toast-error i {
    color: var(--error);
}

.toast-warning i {
    color: var(--warning);
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.25rem;
}

/* ==================== UTILITIES ==================== */
.text-center {
    text-align: center;
}

.mb-1 {
    margin-bottom: var(--spacing-sm);
}

.mb-2 {
    margin-bottom: var(--spacing-md);
}

.mb-3 {
    margin-bottom: var(--spacing-lg);
}

.mb-4 {
    margin-bottom: var(--spacing-xl);
}

.mt-1 {
    margin-top: var(--spacing-sm);
}

.mt-2 {
    margin-top: var(--spacing-md);
}

.mt-3 {
    margin-top: var(--spacing-lg);
}

.mt-4 {
    margin-top: var(--spacing-xl);
}

.hidden {
    display: none !important;
}

.grid {
    display: grid;
    gap: var(--spacing-lg);
}

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

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ==================== RESPONSIVE - MOBILE FIRST ==================== */
@media (max-width: 768px) {

    /* Base font size for mobile */
    :root {
        font-size: 14px;
    }

    /* Container padding */
    #bottom-nav {
        padding: 0.625rem 0.75rem;
        min-width: 100%;
    }

    .nav-btn {
        font-size: 0.75rem;
    }

    /* IMPORTANT: Keep services grid as 2 columns on mobile */
    #services-grid.grid-2 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.625rem;
    }

    /* Service cards - smaller on mobile */
    .service-card {
        padding: 0.75rem !important;
    }

    .service-card h4 {
        font-size: 0.875rem !important;
    }

    .service-card p {
        font-size: 0.75rem !important;
    }

    /* Emergency badge - smaller on mobile */
    .emergency-badge {
        font-size: 0.625rem !important;
        padding: 0.2rem 0.5rem !important;
    }

    /* Other grids go to single column on mobile */
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    /* Keep hero section 2 columns on mobile */
    .hero-section {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
    }

    .toast-container {
        top: auto;
        bottom: 100px;
        right: var(--spacing-md);
        left: var(--spacing-md);
    }

    .toast {
        min-width: auto;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.125rem;
    }

    h4 {
        font-size: 1rem;
    }

    .glass-card {
        padding: 0.875rem;
    }

    .btn {
        padding: 0.625rem 1rem !important;
        font-size: 0.8125rem !important;
    }
}

/* Extra small devices (phones, 576px and down) */
@media (max-width: 576px) {
    .hero-section {
        gap: 0.625rem !important;
    }

    .user-avatar-glow {
        width: 70px !important;
        height: 70px !important;
        font-size: 1.75rem !important;
    }

    h2 {
        font-size: 1.125rem !important;
    }

    .glass-card {
        padding: 0.75rem !important;
    }

    .btn {
        padding: 0.625rem 1rem !important;
        font-size: 0.8125rem !important;
    }
}

/* Enhanced Shadows for Floating Cards */
.animate-float {
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.1),
        0 10px 30px rgba(59, 130, 246, 0.05);
}


/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}