/**
 * TMC Mobile Framework v2.0
 * Focus: Zero overflow, strict boundaries, and native app-like interactions.
 */

:root {
    --header-h: 64px;
    --nav-h: 68px;
    --mobile-gutter: 16px;
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
}

/* 1. Universal Boundary Control */
html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* 2. Mobile Header Modern */
.mobile-header {
    height: 72px;
    z-index: 50;
    pointer-events: none;
}

.header-container {
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(24px) saturate(200%);
    -webkit-backdrop-filter: blur(24px) saturate(200%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    pointer-events: auto;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 768px) {
    .mobile-header {
        height: 68px;
        padding: 8px 16px;
    }

    .header-container {
        border-radius: 24px;
        margin: 0;
        height: 52px;
        box-shadow: 
            0 4px 24px -1px rgba(0, 0, 0, 0.04),
            0 0 1px 0 rgba(0, 0, 0, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.8);
    }
    
    .header-logo {
        max-height: 32px !important;
        filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05));
    }
}

.header-logo {
    max-height: 44px;
    width: auto;
    object-fit: contain;
    display: block;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (max-width: 768px) {

    /* 3. Mobile Content Area */
    main {
        padding: 20px var(--mobile-gutter) calc(80px + var(--safe-bottom) + 20px) !important;
        width: 100% !important;
        box-sizing: border-box !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    /* Universal containment */
    .max-w-6xl, .max-w-7xl, .container, .grid, section, div {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* 4. The "No-Overflow" Grid */
    .grid {
        display: grid !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
    }

    /* 5. Mobile Bottom Bar */
    .mobile-nav {
        z-index: 9999 !important;
        transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .mobile-nav-item {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        color: #94a3b8 !important;
        text-decoration: none !important;
        gap: 4px !important;
        height: 100% !important;
        transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
        position: relative;
    }

    .mobile-nav-item.active {
        color: #0f172a !important;
    }

    .mobile-nav-item.active .w-10 {
        background: #0f172a !important;
        color: #ffffff !important;
        transform: translateY(-8px) scale(1.1);
        box-shadow: 0 12px 24px -6px rgba(15, 23, 42, 0.3);
    }

    .mobile-nav-item.active::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -100%);
        width: 40px;
        height: 40px;
        background: radial-gradient(circle at center, rgba(15, 23, 42, 0.08) 0%, transparent 70%);
        border-radius: 16px;
        z-index: -1;
        animation: pulse-soft 2s infinite;
    }

    @keyframes pulse-soft {
        0%, 100% { transform: translate(-50%, -100%) scale(1); opacity: 0.5; }
        50% { transform: translate(-50%, -100%) scale(1.1); opacity: 0.8; }
    }

    .mobile-nav-item.active::after {
        content: '';
        position: absolute;
        bottom: 8px;
        width: 6px;
        height: 2px;
        background: #0f172a;
        border-radius: 100px;
        box-shadow: 0 0 10px rgba(15, 23, 42, 0.2);
    }

    .mobile-nav-item:active {
        transform: scale(0.9);
    }

    /* 6. Utility Fixes */
    .max-w-6xl {
        max-width: 100vw !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* 7. Enhanced Product Cards & Content */
    .product-card {
        background: #ffffff !important;
        border: 0.5px solid rgba(0, 0, 0, 0.05) !important;
        border-radius: 24px !important;
        overflow: hidden !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04) !important;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
        position: relative;
    }

    .product-card::after {
        content: '';
        position: absolute;
        inset: 0;
        background: radial-gradient(circle at center, rgba(255,255,255,0.2) 0%, transparent 100%);
        opacity: 0;
        transition: opacity 0.4s ease;
        pointer-events: none;
    }

    .product-card:active {
        transform: scale(0.96) translateY(2px) !important;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08) !important;
    }

    .product-card:active::after {
        opacity: 1;
    }

    .product-card img {
        border-radius: 20px !important;
        margin: 6px !important;
        width: calc(100% - 12px) !important;
        transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    }

    .product-card:active img {
        transform: scale(1.05);
    }

    /* Hero Section Polish */
    .hero-container {
        margin: 12px var(--mobile-gutter) 32px !important;
        border-radius: 36px !important;
        background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%) !important;
        box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.08) !important;
        border: 1px solid rgba(255, 255, 255, 1) !important;
        overflow: hidden;
        position: relative;
    }

    .hero-container::before {
        content: '';
        position: absolute;
        top: -50%;
        left: -50%;
        width: 200%;
        height: 200%;
        background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8) 0%, transparent 50%);
        pointer-events: none;
    }

    .hero-badge {
        background: #0f172a !important;
        color: #ffffff !important;
        padding: 6px 14px !important;
        font-size: 10px !important;
        font-weight: 800 !important;
        letter-spacing: 0.1em !important;
        border-radius: 100px !important;
        box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2) !important;
    }

    .hero-title {
        font-size: 32px !important;
        line-height: 1.1 !important;
        margin-bottom: 16px !important;
    }

    .hero-subtitle {
        font-size: 15px !important;
        line-height: 1.5 !important;
        color: #64748b !important;
        margin-bottom: 24px !important;
    }

    /* Modal Polish */
    [role="dialog"] {
        pointer-events: none;
    }

    [role="dialog"].hidden {
        display: none !important;
    }

    [role="dialog"]:not(.hidden) {
        display: flex !important;
        pointer-events: auto;
    }

    /* Animation Utilities */
    .animate-float {
        animation: float 6s ease-in-out infinite;
    }

    @keyframes float {
        0%, 100% { transform: translateY(0); }
        50% { transform: translateY(-10px); }
    }

    /* 8. Premium Typography for Mobile */
    h1, h2, h3 {
        letter-spacing: -0.02em !important;
    }

    .text-slate-900 {
        color: #0f172a !important;
    }

    .text-slate-500 {
        color: #64748b !important;
    }

    .category-scroll {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        padding: 8px 16px;
        gap: 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        align-items: center;
        background: rgba(255, 255, 255, 0.6);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-radius: 20px;
        margin: 4px 16px;
        border: 1px solid rgba(255, 255, 255, 0.5);
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.02);
    }

    .category-tag {
        display: inline-flex;
        align-items: center;
        padding: 8px 16px;
        border-radius: 14px;
        font-size: 13px;
        font-weight: 700;
        color: #64748b;
        background: transparent;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        border: 1px solid transparent;
        line-height: 1;
    }

    .category-tag.active {
        background: #0f172a;
        color: #ffffff;
        box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
        transform: scale(1.02);
    }

    .category-tag:active {
        transform: scale(0.9) translateY(0);
    }

    /* Skeleton Loader Premium */
    .skeleton {
        background: linear-gradient(90deg, #f1f5f9 25%, #f8fafc 50%, #f1f5f9 75%);
        background-size: 200% 100%;
        animation: shimmer 1.5s infinite linear;
        border-radius: 12px;
    }

    @keyframes shimmer {
        0% { background-position: -200% 0; }
        100% { background-position: 200% 0; }
    }

    /* Safe Area Spacing Helpers */
    .pb-safe {
        padding-bottom: var(--safe-bottom) !important;
    }

    .pt-safe {
        padding-top: var(--safe-top) !important;
    }

    /* Responsive Button Sizing */
    .btn-mobile {
        min-height: 48px;
        padding: 12px 24px;
        font-size: 15px;
        font-weight: 700;
        border-radius: 16px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .btn-mobile:active {
        transform: scale(0.96);
    }

    /* Improved Touch Targets */
    button, a {
        min-width: 32px;
        min-height: 32px;
    }
}
