html {
    scroll-behavior: smooth;
    height: 100%;
}

/* Tamil Font Support */
html[lang="ta"] body,
.tamil-mode {
    font-family: 'Noto Sans Tamil', 'Inter', sans-serif !important;
}

:root {
    /* Colors */
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --secondary: #16a34a;
    --secondary-light: #f0fdf4;
    --dark: #0f172a;
    --slate-900: #0f172a;
    --slate-800: #1e293b;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748b;
    --slate-400: #94a3b8;
    --slate-300: #cbd5e1;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50: #f8fafc;
    --white: #ffffff;
    --red: #ef4444;
    --amber: #f59e0b;
    
    /* Spacing System */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;
    --sp-12: 48px;

    /* Borders & Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-2xl: 32px;
    --radius-full: 9999px;

    /* Shadows */
    --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);
    --shadow-premium: 0 20px 40px -10px rgba(30, 64, 175, 0.2);
}

/* Safe Area Utilities */
.pb-safe {
    padding-bottom: env(safe-area-inset-bottom, 16px);
}

.pt-safe {
    padding-top: env(safe-area-inset-top, 0px);
}

.p-safe {
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 16px) env(safe-area-inset-left, 0px);
}

/* Premium Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Animations */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translate3d(20px, 0, 0);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes float {
    0% {
        transform: translateY(0px) rotate(0deg);
    }

    50% {
        transform: translateY(-6px) rotate(2deg);
    }

    100% {
        transform: translateY(0px) rotate(0deg);
    }
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

.group:hover .group-hover\:animate-float {
    animation: float 3s ease-in-out infinite;
}

@keyframes pulseSoft {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(37, 99, 235, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
    }
}

/* ── Skeleton Loading Animation ── */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: var(--radius-md);
    border: none !important;
    color: transparent !important;
    pointer-events: none;
}

.skeleton-dark {
    background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
}

.fade-in-up {
    animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.delay-100 {
    animation-delay: 0.1s;
}

.delay-200 {
    animation-delay: 0.2s;
}

.delay-300 {
    animation-delay: 0.3s;
}

/* 144Hz Performance & Smoothness Essentials */
.gpu-accelerated {
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    perspective: 1000px;
    will-change: transform, opacity;
}

.smooth-transition {
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.transform-gpu {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Global Hardware Acceleration Layer */
.gpu-heavy-layer {
    will-change: transform, opacity;
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Glassmorphism */
.glass {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

/* Map specific tweaks - REVERTING some popup overrides to allow default markers */
.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    padding: 0 !important;
}

.leaflet-popup-content {
    margin: 0 !important;
}

.marker-hit-area {
    pointer-events: auto !important;
}

/* Background Overlay for Modal Experience */
#sheet-overlay {
    transition: opacity 0.2s ease-out;
    will-change: opacity;
}

#sheet-overlay.active {
    opacity: 1 !important;
    pointer-events: auto !important;
    display: block !important;
}

/* Hardware Accelerated Layers */
.glass,
.cat-chip,
#worker-profile-sheet,
.user-location-marker,
.worker-marker-container,
.hero-video,
#category-selection-sheet,
#map-style-sheet,
.premium-shadow {
    will-change: transform, opacity;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Production-Grade Bottom Sheet Styles */
#worker-profile-sheet {
    transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    background: #ffffff !important;
    border-top: 1px solid #f1f5f9;
    will-change: transform;
    touch-action: pan-y;
}

#worker-profile-sheet.open {
    transform: translateY(0) translateZ(0) !important;
}

/* Desktop Version: Centered Card */
@media (min-width: 768px) {
    #worker-profile-sheet {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        bottom: auto !important;
        transform: translate(-50%, -20%) scale(0.9) !important;
        opacity: 0;
        border-radius: 16px !important;
        max-width: 380px !important;
        max-height: 80vh !important;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
    }

    #worker-profile-sheet.open {
        transform: translate(-50%, -50%) scale(1) translateZ(0) !important;
        opacity: 1 !important;
    }
}

.custom-popup-card .leaflet-popup-content {
    margin: 0 !important;
}

.custom-popup-card .leaflet-popup-tip {
    box-shadow: none !important;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

@keyframes pulse-ring {
    0% {
        transform: scale(0.33);
        opacity: 0.8;
    }

    80%,
    100% {
        opacity: 0;
    }
}

@keyframes green-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

.green-pulse-anim {
    animation: green-pulse 2s infinite;
}

@keyframes bounce-subtle {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.animate-bounce-subtle {
    animation: bounce-subtle 3s ease-in-out infinite;
}

.radial-pulse-anim {
    animation: pulse-ring 3s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

/* ── UI Components Design System ── */

/* Premium Cards */
.card-premium {
    background: var(--white);
    border: 1px solid var(--slate-100);
    border-radius: var(--radius-xl);
    padding: var(--sp-6);
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-premium:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-2px);
    border-color: var(--slate-200);
}

/* Dashboard Stat Cards */
.stat-card-new {
    background: var(--white);
    border: 1px solid var(--slate-100);
    border-radius: var(--radius-lg);
    padding: var(--sp-4);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.stat-card-new:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

/* Button Standard Styles */
.btn-new {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.875rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: none;
    gap: 0.5rem;
}

.btn-new-primary {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-new-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
    transform: translateY(-1px);
}

.btn-new-primary:active {
    transform: translateY(0);
    scale: 0.96;
}

/* Micro-Interaction Fixes */
.active-pulse:active {
    transform: scale(0.96);
    transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-new-premium {
    background: linear-gradient(135deg, #1e40af 0%, #4f46e5 100%);
    color: var(--white);
    box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.4);
}

.btn-new-premium:hover {
    box-shadow: 0 15px 30px -5px rgba(79, 70, 229, 0.5);
    transform: translateY(-2px) scale(1.02);
}

/* Typography Helpers */
.text-label {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--slate-500);
}

.text-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--slate-900);
    letter-spacing: -0.02em;
}

.text-body {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--slate-600);
}

/* ── Layout Utilities ── */
.overflow-ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Global Component Enforcements ── */

/* Force consistent border radius for ALL buttons and cards as requested */
.btn-primary, .btn-secondary, .btn-blue, .btn-green, .btn-indigo, .btn-new,
.stat-card, .plan-card, .glass-card, .section-card, .card-premium, .worker-row {
    border-radius: var(--radius-lg) !important; /* 16px Standard */
}

/* Standard Button Heights & Padding */
.btn-primary, .btn-secondary, .btn-blue, .btn-indigo, .btn-new {
    height: 48px;
    padding-left: var(--sp-6);
    padding-right: var(--sp-6);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    transition: all 0.2s ease;
}

/* Stat Card Padding Consistency */
.stat-card, .stat-card-new, .stat-card-glow {
    padding: var(--sp-5) !important;
}

/* Ensure no horizontal overflow ever */
body, html {
    max-width: 100vw;
    overflow-x: hidden;
}
body {
    min-height: 100vh;
    /* Changed from hidden to auto to restore scrolling */
    width: 100vw;
    -webkit-font-smoothing: antialiased;
    background: #F8FAFC;
    position: relative;
}

/* Extra Smooth Improvements */
input,
button,
a,
[role="button"],
.marker-hit-area,
.cat-option,
.nav-link {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    /* Removes 300ms click delay */
    min-height: 44px; /* Apple/Google accessibility standard */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Hover-only effects for Desktop to avoid sticky mobile states */
@media (hover: hover) {

    .cat-chip:hover,
    .btn:hover,
    a:hover,
    button:hover {
        transform: translateY(-2px) translateZ(0);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }
}

* {
    -webkit-touch-callout: none;
}

/* Form focus ring animation */
input:focus,
select:focus,
textarea:focus {
    transition: all 0.2s ease-in-out;
    transform: translateY(-1px);
}

/* Mobile optimizations */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.toast {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
}

.toast-active {
    opacity: 1 !important;
    transform: translateY(0) scale(1) !important;
}

.active\:scale-95:active {
    transform: scale(0.95);
}

.active\:scale-90:active {
    transform: scale(0.90);
}

/* Tamil Responsive Typography */
.tamil-mode h1 {
    font-size: 2.125rem !important;
    /* Mobile: text-4xl approx, slightly reduced */
    line-height: 1.4 !important;
    letter-spacing: normal !important;
    word-break: keep-all;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

@media (min-width: 640px) {
    .tamil-mode h1 {
        font-size: 3rem !important;
        /* Tablet (sm): text-5xl equivalent */
    }
}

@media (min-width: 768px) {
    .tamil-mode h1 {
        font-size: 4.5rem !important;
        /* Desktop (md): text-7xl equivalent */
        line-height: 1.25 !important;
    }
}

.tamil-mode .hero-sub {
    line-height: 1.6 !important;
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
}

/* Verified Badge System Components */
.verified-badge-marker {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    pointer-events: none;
}

.verified-badge-marker svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.verified-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #dbeafe;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.verified-pill svg {
    width: 12px;
    height: 12px;
}