/**
 * Scratch Karo - User App Mobile Stylesheet
 */

/* Mobile Viewport & Device Compatibility Guard */
html, body.user-app {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden !important;
    position: relative;
    -webkit-text-size-adjust: 100%;
    touch-action: pan-y pinch-zoom;
}

/* Responsive Mobile Container & Desktop Blocker */
.app-container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    background-color: #FFFFFF;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow-x: hidden !important;
    box-sizing: border-box;
    /* Base Safe Area Support */
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

/* iOS PWA Standalone Notch & Status Bar Clearance */
@supports (-webkit-touch-callout: none) {
    @media (display-mode: standalone) {
        .app-container {
            padding-top: max(calc(env(safe-area-inset-top, 0px) + 16px), 66px) !important;
        }
    }
}

html.is-ios-pwa .app-container,
body.is-ios-pwa .app-container {
    padding-top: max(calc(env(safe-area-inset-top, 0px) + 16px), 66px) !important;
}

html.is-ios:not(.is-ios-pwa) .app-container {
    padding-top: max(env(safe-area-inset-top, 0px), 10px);
}

/* Extra comfortable spacing for header bar on iOS */
html.is-ios-pwa .landing-page-wrapper > header,
html.is-ios-pwa .dashboard-wrapper > div:first-child {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}

/* Base Body in User App */
body.user-app {
    background: radial-gradient(circle at top center, #F8FAFC 0%, #EEF2F6 100%);
    color: #1E293B;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* On desktop and tablet screens (min-width: 577px), present clean phone frame like Agent & Vendor portal */
@media (min-width: 577px) {
    body.user-app {
        padding: 20px 0;
        background: radial-gradient(circle at top center, #EEF2FF 0%, #E2E8F0 100%);
    }
    .app-container {
        border-radius: 28px;
        box-shadow: 0 20px 50px rgba(108, 99, 255, 0.14), 0 0 0 1px rgba(108, 99, 255, 0.08);
        overflow: hidden;
        min-height: calc(100vh - 40px);
    }
    .modal-dialog {
        max-width: 480px;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 576px) {
    body.user-app {
        background: #FFFFFF;
        padding: 0;
    }
    .app-container {
        box-shadow: none;
        border-radius: 0;
        min-height: 100vh;
        min-height: 100dvh;
    }
}

/* Desktop blocker permanently disabled (All devices supported in phone view) */
.desktop-blocker {
    display: none !important;
}

/* App Content Area */
.app-content {
    flex: 1 0 auto;
    padding: 1rem 1rem calc(76px + env(safe-area-inset-bottom, 0px)) 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}
.app-content.no-bottom-nav {
    padding-bottom: 1.5rem;
}

/* ==========================================================================
   USER BOTTOM NAVIGATION - Native Mobile App Docked Bar with Elevated FAB
   ========================================================================== */
.bottom-nav-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 1040;
    pointer-events: none;
    padding: 0;
}

body.modal-open .bottom-nav-container {
    display: none !important;
}

.bottom-nav {
    pointer-events: auto;
    width: 100%;
    max-width: 480px;
    height: calc(62px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #FFFFFF;
    border-top: 1px solid #E2E8F0;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    padding-left: 4px;
    padding-right: 4px;
    position: relative;
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #64748B;
    flex: 1;
    height: 62px;
    position: relative;
    transition: color 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.bottom-nav .nav-icon-wrap {
    width: 32px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.2s ease;
}

.bottom-nav .nav-icon-wrap i {
    font-size: 1.3rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

.bottom-nav .nav-label {
    font-size: 0.68rem;
    font-weight: 500;
    margin-top: 3px;
    transition: all 0.2s ease;
    letter-spacing: -0.2px;
    white-space: nowrap;
}

/* Active State: Clean Native App Highlight */
.bottom-nav .nav-item.active {
    color: #6C63FF;
}

.bottom-nav .nav-item.active .nav-icon-wrap i {
    transform: scale(1.1);
    color: #6C63FF;
}

.bottom-nav .nav-item.active .nav-label {
    font-weight: 700;
    color: #6C63FF;
}

.bottom-nav .nav-item.active:not(.nav-item-center)::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 14px;
    height: 3px;
    border-radius: 2px;
    background: #6C63FF;
}

/* Center Tab (Wallet) Elevated Floating Action Button (FAB) */
.bottom-nav .nav-item.nav-item-center {
    overflow: visible;
}

.bottom-nav .nav-item.nav-item-center .nav-icon-wrap.center-fab {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-top: -20px;
    background: linear-gradient(135deg, #7C3AED 0%, #4F46E5 100%);
    border: 3.5px solid #FFFFFF;
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bottom-nav .nav-item.nav-item-center .nav-icon-wrap.center-fab i {
    font-size: 1.35rem;
    color: #FFFFFF;
}

.bottom-nav .nav-item.nav-item-center .nav-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: #7C3AED;
    margin-top: 2px;
}

.bottom-nav .nav-item.nav-item-center:active .nav-icon-wrap.center-fab,
.bottom-nav .nav-item.nav-item-center.active .nav-icon-wrap.center-fab {
    transform: scale(1.06);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.55);
}

/* Wallet Card */
.wallet-balance-card {
    background: linear-gradient(135deg, #6C63FF 0%, #4E44E6 100%);
    color: #FFFFFF;
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 10px 24px rgba(108, 99, 255, 0.3);
    position: relative;
    overflow: hidden;
}
.wallet-balance-card::after {
    content: '';
    position: absolute;
    width: 140px;
    height: 140px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    top: -30px;
    right: -30px;
    pointer-events: none;
}
.wallet-amount {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* Pack Cards */
.pack-card {
    border-radius: 18px;
    border: 1px solid var(--border);
    background: #FFFFFF;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.pack-card:active {
    transform: scale(0.98);
}
.pack-header {
    background: linear-gradient(135deg, #F8FAFC, #EDF2F7);
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}
.pack-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* Scratch Card Experience */
.scratch-card-wrapper {
    position: relative;
    width: 320px;
    height: 320px;
    margin: 1.5rem auto;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.scratch-card-underlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, #FFF9E6 0%, #FFE89E 100%);
    padding: 1.5rem;
    text-align: center;
    z-index: 1;
}

.scratch-card-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    cursor: grab;
    touch-action: none;
}
.scratch-card-canvas:active {
    cursor: grabbing;
}

.scratch-reward-value {
    font-size: 3rem;
    font-weight: 800;
    color: #2E7D32;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Activity Items */
.activity-item {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #F1F5F9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
    color: inherit;
}
.activity-item:last-child {
    border-bottom: none;
}
.activity-icon-badge {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* Profile Menu */
.profile-menu-list {
    background: #FFFFFF;
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
}
.profile-menu-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    font-weight: 500;
    transition: background-color 0.15s ease;
}
.profile-menu-item:last-child {
    border-bottom: none;
}
.profile-menu-item:hover, .profile-menu-item:active {
    background-color: #F8FAFC;
    color: var(--primary);
}
.profile-menu-item i:first-child {
    font-size: 1.2rem;
    margin-right: 1rem;
    color: #64748B;
}

/* Native App Splash Screen Overlay */
.app-splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(150deg, #6C63FF 0%, #4F46E5 45%, #3B82F6 100%);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s ease, visibility 0.4s ease;
    will-change: opacity, transform;
}
.app-splash-screen.splash-hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(1.04);
    pointer-events: none;
}
.splash-inner {
    padding: 2rem;
    animation: splashFadeIn 0.6s ease-out;
}
.splash-logo-box {
    width: 96px;
    height: 96px;
    margin: 0 auto;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
    animation: splashPulse 2s infinite ease-in-out;
}
.splash-logo-img {
    width: 76px;
    height: 76px;
    border-radius: 22px;
    object-fit: cover;
}
.splash-title {
    font-size: 1.85rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
.splash-tagline {
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    letter-spacing: 0.4px;
}
.splash-spinner-ring {
    width: 32px;
    height: 32px;
    margin: 0 auto;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: splashSpin 0.75s linear infinite;
}
@keyframes splashSpin {
    to { transform: rotate(360deg); }
}
@keyframes splashPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25); }
    50% { transform: scale(1.05); box-shadow: 0 20px 48px rgba(255, 255, 255, 0.2); }
}
@keyframes splashFadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Native Pull-to-Refresh Floating Indicator */
.pull-to-refresh-indicator {
    position: fixed;
    top: max(env(safe-area-inset-top, 0px), 16px);
    left: 50%;
    transform: translate(-50%, -75px);
    z-index: 100000;
    pointer-events: none;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.2), opacity 0.2s ease;
    opacity: 0;
}
.pull-to-refresh-indicator.ptr-pulling,
.pull-to-refresh-indicator.ptr-refreshing {
    opacity: 1;
}
.pull-to-refresh-indicator.ptr-pulling {
    transition: none;
}
.ptr-content {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    padding: 8px 18px;
    border-radius: 999px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(108, 99, 255, 0.15);
    border: 1.5px solid rgba(108, 99, 255, 0.25);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #4F46E5;
}
.ptr-icon {
    font-size: 1.05rem;
    transition: transform 0.15s ease;
    display: inline-block;
}

/* Splash Screen */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    color: #FFFFFF;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.splash-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

/* Onboarding Screen */
.onboarding-slider {
    text-align: center;
    padding: 2rem 1rem;
}
.onboarding-illustration {
    width: 180px;
    height: 180px;
    margin: 0 auto 2rem;
    border-radius: 50%;
    background: rgba(108, 99, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    color: var(--primary);
}
