/* ============================================================
   INSPECTIFY LAPSTORE — MOBILE REDESIGN
   Premium iOS-style mobile experience for ≤768px screens
   Based on Claude design system, adapted for Razor views
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ============ DESIGN TOKENS ============ */
:root {
    --ils-navy: #16212e;
    --ils-navy-2: #1e2a3a;
    --ils-navy-3: #243447;
    --ils-accent: #2b72d4;
    --ils-accent-glow: #5ea0ff;
    --ils-accent-soft: rgba(43, 114, 212, 0.12);
    --ils-success: #10b981;
    --ils-warning: #f59e0b;
    --ils-danger: #ef4444;
    --ils-gold: #f7b500;

    --ils-r-card: 16px;
    --ils-r-pill: 999px;
    --ils-r-input: 12px;

    --ils-gap-xxs: 4px;
    --ils-gap-xs: 8px;
    --ils-gap-sm: 12px;
    --ils-gap-md: 16px;
    --ils-gap-lg: 20px;
    --ils-gap-xl: 28px;
}

/* ============ HIDE MARK LOGO ON DESKTOP (above 768px) ============ */
.brand-logo-mark {
    display: none !important;
}

/* ============ MOBILE-ONLY (≤768px) ============ */
@media (max-width: 768px) {

    /* ── Reset & base ───────────────────────────────────────── */
    html, body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        font-family: 'Inter', -apple-system, system-ui, "Segoe UI", sans-serif;
        letter-spacing: -0.01em;
    }

    body {
        padding-bottom: 80px; /* space for bottom nav */
    }

    /* iOS zoom prevention */
    input, textarea, select {
        font-size: 16px !important;
    }

    /* ── Header (mobile) ────────────────────────────────────── */
    .header {
        position: sticky;
        top: 0;
        z-index: 30;
        background: color-mix(in oklab, var(--bg, #16212e) 92%, transparent);
        backdrop-filter: blur(20px) saturate(160%);
        -webkit-backdrop-filter: blur(20px) saturate(160%);
        border-bottom: 0.5px solid rgba(255, 255, 255, 0.08);
        padding: 0;
    }

    html[data-theme="light"] .header {
        background: color-mix(in oklab, #ffffff 92%, transparent);
        border-bottom-color: rgba(0, 0, 0, 0.08);
    }

    .header .container,
    .header .nav-wrapper {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 10px 12px !important;
        max-width: 100% !important;
        width: 100% !important;
        flex-wrap: nowrap !important;
        overflow: hidden !important;
    }

    /* FORCE CORRECT ORDER ON MOBILE: 1.Logo  2.Search  3.Theme  4.Profile */
    .header .logo {
        order: 1 !important;
    }

    .header .nav-menu {
        order: 99 !important; /* hidden but keeps order safe */
    }

    .header .search-bar {
        order: 2 !important;
    }

    .header .user-actions {
        order: 3 !important;
    }

    /* Hide horizontal logo on mobile, show mark (icon) only */
    .brand-logo-horizontal {
        display: none !important;
    }

    .brand-logo-mark {
        display: none;
        height: 36px !important;
        width: auto;
    }

    /* Show mark logo based on theme */
    html[data-theme="dark"] .brand-logo-mark.brand-logo-light {
        display: none !important;
    }
    html[data-theme="dark"] .brand-logo-mark.brand-logo-dark {
        display: block !important;
    }
    html[data-theme="light"] .brand-logo-mark.brand-logo-dark {
        display: none !important;
    }
    html[data-theme="light"] .brand-logo-mark.brand-logo-light {
        display: block !important;
    }

    .logo {
        flex-shrink: 0;
        display: flex;
        align-items: center;
    }

    .brand-link {
        display: flex;
        align-items: center;
    }

    /* Hide nav menu on mobile (we use bottom nav) */
    .nav-menu {
        display: none !important;
    }

    /* Search bar - between logo and theme button */
    .search-bar {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        height: 38px !important;
        background: rgba(255, 255, 255, 0.06) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-radius: var(--ils-r-pill) !important;
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 0 14px !important;
        margin: 0 !important;
        position: relative;
    }

    html[data-theme="light"] .search-bar {
        background: #f3f4f6 !important;
        border-color: rgba(0, 0, 0, 0.08) !important;
    }

    .search-bar i {
        color: var(--ils-accent);
        font-size: 13px;
        flex-shrink: 0;
    }

    .search-bar input {
        flex: 1 !important;
        min-width: 0 !important;
        background: transparent !important;
        border: 0 !important;
        outline: 0 !important;
        font-size: 14px !important;
        color: inherit !important;
        width: 100% !important;
    }

    .search-bar form {
        flex: 1;
        display: flex;
        min-width: 0;
    }

    /* User actions container — Theme first, then Profile */
    .user-actions {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        flex-shrink: 0 !important;
    }

    .user-actions .theme-toggle {
        order: 1 !important;
    }

    .user-actions .icon-btn {
        order: 2 !important;
        display: none !important; /* favorites moved to bottom nav */
    }

    .user-actions .profile-dropdown,
    .user-actions .btn-primary {
        order: 3 !important;
    }

    /* Theme toggle - SIMPLE single icon button on mobile (no slide) */
    .theme-toggle {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        border-radius: 50% !important;
        background: rgba(255, 255, 255, 0.06) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
        padding: 0 !important;
        position: relative;
        cursor: pointer;
    }

    html[data-theme="light"] .theme-toggle {
        background: #f3f4f6 !important;
        border-color: rgba(0, 0, 0, 0.08) !important;
    }

    /* Hide the slide track on mobile - we just show one icon */
    .theme-toggle .theme-toggle-track {
        background: transparent !important;
        width: auto !important;
        height: auto !important;
        padding: 0 !important;
        border: 0 !important;
        box-shadow: none !important;
        position: static !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .theme-toggle .theme-toggle-thumb {
        background: transparent !important;
        width: auto !important;
        height: auto !important;
        position: static !important;
        transform: none !important;
        box-shadow: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Show only sun in dark theme, only moon in light theme */
    html[data-theme="dark"] .theme-toggle .sun-icon {
        display: block !important;
        color: var(--ils-gold) !important;
        font-size: 16px !important;
        opacity: 1 !important;
        position: static !important;
    }
    html[data-theme="dark"] .theme-toggle .moon-icon {
        display: none !important;
    }
    html[data-theme="light"] .theme-toggle .moon-icon {
        display: block !important;
        color: var(--ils-navy) !important;
        font-size: 16px !important;
        opacity: 1 !important;
        position: static !important;
    }
    html[data-theme="light"] .theme-toggle .sun-icon {
        display: none !important;
    }

    /* Profile circle / icon buttons */
    .icon-btn,
    .profile-circle {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
        background: rgba(255, 255, 255, 0.06) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        font-size: 14px !important;
        font-weight: 600;
        padding: 0 !important;
    }

    html[data-theme="light"] .icon-btn,
    html[data-theme="light"] .profile-circle {
        background: #f3f4f6 !important;
        border-color: rgba(0, 0, 0, 0.08) !important;
    }

    .profile-circle img {
        width: 100% !important;
        height: 100% !important;
        border-radius: 50% !important;
        object-fit: cover;
    }

    /* Hide favorites icon on mobile (it's in bottom nav) */
    .user-actions > .icon-btn {
        display: none !important;
    }

    /* Sign In button on mobile - compact */
    .user-actions .btn-primary {
        width: auto !important;
        height: 38px !important;
        padding: 0 14px !important;
        font-size: 13px !important;
        border-radius: var(--ils-r-pill) !important;
        box-shadow: none !important;
        flex-shrink: 0 !important;
    }

    /* Hide mobile menu burger (we use bottom nav now) */
    .mobile-menu-btn {
        display: none !important;
    }

    /* Hide floating Sell button (replaced with bottom nav FAB) */
    .sell-btn-float {
        display: none !important;
    }

    /* ── Bottom Navigation ──────────────────────────────────── */
    .ils-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        padding: 6px 8px calc(8px + env(safe-area-inset-bottom)) 8px;
        background: color-mix(in oklab, var(--ils-navy) 92%, transparent);
        backdrop-filter: blur(20px) saturate(160%);
        -webkit-backdrop-filter: blur(20px) saturate(160%);
        border-top: 0.5px solid rgba(255, 255, 255, 0.08);
        display: flex;
        justify-content: space-around;
        align-items: stretch;
    }

    html[data-theme="light"] .ils-bottom-nav {
        background: color-mix(in oklab, #ffffff 92%, transparent);
        border-top-color: rgba(0, 0, 0, 0.08);
    }

    .ils-nav-item {
        flex: 1;
        padding: 8px 4px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        color: #64748b;
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.01em;
        transition: color 0.12s;
        position: relative;
        text-decoration: none;
    }

    .ils-nav-item i {
        font-size: 18px;
    }

    .ils-nav-item.active {
        color: var(--ils-accent);
    }

    .ils-nav-item.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 28px;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: var(--ils-accent);
    }

    .ils-nav-fab {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: var(--ils-accent);
        color: #fff;
        display: grid;
        place-items: center;
        margin-top: -12px;
        box-shadow: 0 8px 22px rgba(43, 114, 212, 0.5);
        flex-shrink: 0;
        align-self: center;
        border: none;
        cursor: pointer;
    }

    .ils-nav-fab i {
        font-size: 18px;
    }

    /* ── Cards ──────────────────────────────────────────────── */
    .ils-card {
        background: var(--ils-navy-2);
        border-radius: var(--ils-r-card);
        border: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
        overflow: hidden;
    }

    html[data-theme="light"] .ils-card {
        background: #ffffff;
        border-color: rgba(0, 0, 0, 0.08);
        box-shadow: 0 1px 0 rgba(0,0,0,0.02), 0 4px 14px rgba(15, 23, 42, 0.06);
    }

    /* ── Listing Cards (laptop cards on mobile) ──────────────── */
    .ad-card,
    .product-card,
    .listing-card {
        background: var(--ils-navy-2);
        border-radius: var(--ils-r-card);
        border: 1px solid rgba(255, 255, 255, 0.08);
        overflow: hidden;
        margin-bottom: 14px;
        transition: transform 0.12s;
    }

    html[data-theme="light"] .ad-card,
    html[data-theme="light"] .product-card,
    html[data-theme="light"] .listing-card {
        background: #ffffff;
        border-color: rgba(0, 0, 0, 0.08);
    }

    .ad-card:active,
    .product-card:active,
    .listing-card:active {
        transform: scale(0.98);
    }

    /* ── Buttons (iOS style) ─────────────────────────────────── */
    .btn-primary,
    .btn-primary-form {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        height: 48px;
        padding: 0 18px;
        border-radius: var(--ils-r-input);
        font-weight: 600;
        font-size: 15px;
        background: var(--ils-accent);
        color: #fff;
        box-shadow: 0 6px 18px rgba(43, 114, 212, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
        border: 0;
        cursor: pointer;
        transition: transform 0.12s, background 0.12s;
        width: 100%;
        text-decoration: none;
    }

    .btn-primary:active,
    .btn-primary-form:active {
        transform: scale(0.98);
    }

    .btn-secondary {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        height: 48px;
        padding: 0 18px;
        border-radius: var(--ils-r-input);
        font-weight: 600;
        font-size: 15px;
        background: var(--ils-navy-2);
        color: inherit;
        border: 1px solid rgba(255, 255, 255, 0.08);
        cursor: pointer;
        text-decoration: none;
    }

    html[data-theme="light"] .btn-secondary {
        background: #ffffff;
        border-color: rgba(0, 0, 0, 0.08);
    }

    /* ── Badges ─────────────────────────────────────────────── */
    .ils-badge {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 3px 8px;
        border-radius: var(--ils-r-pill);
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.01em;
        white-space: nowrap;
    }

    .ils-badge-verified {
        background: var(--ils-accent-soft);
        color: var(--ils-accent);
    }

    .ils-badge-scan {
        background: rgba(16, 185, 129, 0.12);
        color: var(--ils-success);
    }

    .ils-badge-discount {
        background: rgba(239, 68, 68, 0.12);
        color: var(--ils-danger);
    }

    /* ── Filter Chips (horizontal scroll) ────────────────────── */
    .ils-chip-row {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding: 12px 14px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .ils-chip-row::-webkit-scrollbar {
        display: none;
    }

    .ils-chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        height: 34px;
        padding: 0 14px;
        border-radius: var(--ils-r-pill);
        background: var(--ils-navy-2);
        border: 1px solid rgba(255, 255, 255, 0.08);
        font-size: 13px;
        font-weight: 500;
        color: #94a3b8;
        white-space: nowrap;
        flex-shrink: 0;
        cursor: pointer;
        text-decoration: none;
    }

    html[data-theme="light"] .ils-chip {
        background: #ffffff;
        border-color: rgba(0, 0, 0, 0.08);
        color: #5b6675;
    }

    .ils-chip.active {
        background: var(--ils-accent);
        color: #fff;
        border-color: var(--ils-accent);
    }

    /* ── Hero (mobile) ──────────────────────────────────────── */
    .home-page .hero,
    .hero {
        padding: 20px 18px 26px !important;
        min-height: auto !important;
        background: linear-gradient(180deg, #16212e 0%, #1e2f48 100%) !important;
        border-bottom-left-radius: 24px;
        border-bottom-right-radius: 24px;
        margin: 0 0 4px;
        position: relative;
        overflow: hidden;
        color: #fff;
    }

    .hero-title {
        font-size: 26px !important;
        line-height: 1.2 !important;
        letter-spacing: -0.02em !important;
        margin-bottom: 6px !important;
        color: #fff !important;
    }

    .hero-sub {
        font-size: 14px !important;
        color: rgba(226, 232, 240, 0.7) !important;
        margin-bottom: 18px !important;
        line-height: 1.5 !important;
    }

    .hero-cta {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
    }

    .hero-cta .btn-primary {
        flex: 1;
        background: #fff;
        color: var(--ils-navy);
    }

    .hero-cta .btn-secondary {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        border-color: rgba(255, 255, 255, 0.2);
    }

    /* Hide 3D laptop on mobile */
    .home-page .hero-laptop,
    .home-page .label3d,
    canvas {
        display: none !important;
    }

    /* ── Forms ──────────────────────────────────────────────── */
    .form-group {
        margin-bottom: 16px;
    }

    .form-group label {
        font-size: 13px;
        font-weight: 500;
        color: #94a3b8;
        margin-bottom: 6px;
        display: block;
    }

    html[data-theme="light"] .form-group label {
        color: #5b6675;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100%;
        height: 50px;
        padding: 0 14px;
        background: var(--ils-navy-2);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: var(--ils-r-input);
        font-size: 16px !important;
        color: inherit;
        transition: border-color 0.12s, box-shadow 0.12s;
    }

    html[data-theme="light"] .form-group input,
    html[data-theme="light"] .form-group select,
    html[data-theme="light"] .form-group textarea {
        background: #ffffff;
        border-color: rgba(0, 0, 0, 0.08);
    }

    .form-group input:focus,
    .form-group select:focus,
    .form-group textarea:focus {
        border-color: var(--ils-accent);
        box-shadow: 0 0 0 3px var(--ils-accent-soft);
        outline: 0;
    }

    .form-group textarea {
        height: auto;
        min-height: 100px;
        padding: 14px;
    }

    /* ── Auth pages ─────────────────────────────────────────── */
    .auth-card,
    .reset-card {
        margin: 16px;
        padding: 24px 20px;
        border-radius: 16px;
        background: var(--ils-navy-2);
        border: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    }

    html[data-theme="light"] .auth-card,
    html[data-theme="light"] .reset-card {
        background: #ffffff;
        border-color: rgba(0, 0, 0, 0.08);
        box-shadow: 0 1px 0 rgba(0,0,0,0.02), 0 4px 14px rgba(15, 23, 42, 0.06);
    }

    .auth-card h2,
    .reset-card h2 {
        font-size: 22px;
        font-weight: 700;
        letter-spacing: -0.02em;
        margin-bottom: 8px;
    }

    .auth-card .subtitle,
    .reset-card .subtitle {
        font-size: 14px;
        color: #94a3b8;
        margin-bottom: 24px;
    }

    /* ── Section titles ─────────────────────────────────────── */
    .ils-section-title {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        padding: 0 14px;
        margin: 24px 0 12px;
    }

    .ils-section-title h2,
    .ils-section-title h3 {
        font-size: 18px;
        font-weight: 700;
        letter-spacing: -0.02em;
        margin: 0;
    }

    .ils-section-title a {
        font-size: 13px;
        color: var(--ils-accent);
        font-weight: 500;
        text-decoration: none;
    }

    /* ── Skeletons ──────────────────────────────────────────── */
    @keyframes ils-shimmer {
        0% { background-position: -200% 0; }
        100% { background-position: 200% 0; }
    }

    .ils-skel {
        background: linear-gradient(90deg, var(--ils-navy-3) 0%, rgba(255, 255, 255, 0.06) 50%, var(--ils-navy-3) 100%);
        background-size: 200% 100%;
        animation: ils-shimmer 1.4s ease-in-out infinite;
        border-radius: 8px;
    }

    /* ── Empty states ───────────────────────────────────────── */
    .ils-empty {
        text-align: center;
        padding: 60px 20px;
    }

    .ils-empty-icon {
        width: 80px;
        height: 80px;
        margin: 0 auto 16px;
        border-radius: 50%;
        background: var(--ils-accent-soft);
        color: var(--ils-accent);
        display: grid;
        place-items: center;
        font-size: 36px;
    }

    .ils-empty h3 {
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 6px;
    }

    .ils-empty p {
        font-size: 14px;
        color: #94a3b8;
        margin-bottom: 20px;
    }

    /* ── Toast ──────────────────────────────────────────────── */
    @keyframes ils-toast-up {
        from { opacity: 0; transform: translate(-50%, 20px); }
        to { opacity: 1; transform: translate(-50%, 0); }
    }

    .ils-toast {
        position: fixed;
        left: 50%;
        bottom: 92px;
        transform: translateX(-50%);
        z-index: 200;
        max-width: 88%;
        background: var(--ils-navy);
        color: #fff;
        padding: 12px 16px;
        border-radius: 12px;
        font-size: 13px;
        font-weight: 500;
        display: flex;
        align-items: center;
        gap: 10px;
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
        animation: ils-toast-up 0.25s ease-out;
    }

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

    /* ── Profile pages ──────────────────────────────────────── */
    .profile-shell,
    .admin-shell {
        grid-template-columns: 1fr !important;
        padding: 14px !important;
    }

    .profile-sidebar,
    .admin-sidebar {
        position: static !important;
        width: 100% !important;
        margin-bottom: 16px !important;
    }

    /* ── Footer (compact on mobile) ─────────────────────────── */
    .footer {
        margin-bottom: 80px; /* don't overlap bottom nav */
        padding: 24px 14px !important;
    }

    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
    }

    .footer-section h3,
    .footer-section h4 {
        font-size: 15px;
    }

    /* ── Trusted Seller cards ───────────────────────────────── */
    .seller-card {
        flex-direction: row !important;
        align-items: center !important;
        gap: 14px !important;
        padding: 14px !important;
    }

    .seller-avatar {
        width: 56px !important;
        height: 56px !important;
        margin: 0 !important;
        flex-shrink: 0;
    }

    /* ── Trust band (hardware-scan verified) ────────────────── */
    .trust-band {
        margin: 24px 14px 0;
        padding: 16px;
        background: linear-gradient(135deg, rgba(43, 114, 212, 0.12) 0%, rgba(94, 160, 255, 0.06) 100%);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 16px;
        display: flex;
        align-items: center;
        gap: 14px;
    }

    .trust-band-icon {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        background: var(--ils-accent);
        color: #fff;
        display: grid;
        place-items: center;
        flex-shrink: 0;
        box-shadow: 0 8px 20px rgba(43, 114, 212, 0.4);
    }

    /* ── Touch optimizations ────────────────────────────────── */
    a, button, .btn {
        -webkit-tap-highlight-color: transparent;
    }

    .ad-card a,
    .product-card a {
        min-height: 44px;
    }

    /* ── Show profile dropdown menu as bottom sheet on mobile ─ */
    .profile-menu {
        position: fixed !important;
        top: auto !important;
        bottom: 80px !important;
        left: 14px !important;
        right: 14px !important;
        width: auto !important;
        border-radius: 16px !important;
        max-height: 70vh;
        overflow-y: auto;
    }
}

/* ============ EXTRA SMALL (≤480px) ============ */
@media (max-width: 480px) {
    .hero-title {
        font-size: 22px !important;
    }

    .auth-card h2,
    .reset-card h2 {
        font-size: 20px;
    }

    .ils-section-title h2 {
        font-size: 16px;
    }
}

/* ============ TINY (≤360px) ============ */
@media (max-width: 360px) {
    .header .container,
    .header .nav-wrapper {
        padding: 8px 10px;
        gap: 8px;
    }

    .brand-logo {
        height: 32px !important;
    }

    .search-bar {
        height: 36px;
    }
}
