/* Responsive — Modern (v2) */

/* ── Desktop: cursor fixes ─────────────────────── */
@media (hover: hover) and (pointer: fine) {
    .product-card:hover { transform: translateY(-6px); border-color: rgba(255,159,28,0.2); box-shadow: 0 24px 56px -16px rgba(255,159,28,0.2); }
    .review-card:hover { transform: translateY(-4px); border-color: rgba(255,159,28,0.15); }
    .feature-card:hover { transform: translateY(-4px); border-color: rgba(255,159,28,0.15); }
    .feature-card:hover .feature-icon { transform: scale(1.1) rotate(10deg); }
    .listing-card:hover { transform: translateY(-6px); border-color: rgba(255,159,28,0.2); box-shadow: 0 20px 48px -12px rgba(255,159,28,0.18); }
    .wallet-card:hover { transform: translateY(-4px); }
    .product-card:hover .product-image img { transform: scale(1.06); }
    .listing-card:hover .listing-image img { transform: scale(1.06); }
    .feature-card:hover, .stat-card:hover { background: rgba(255,255,255,0.035); border-color: rgba(255,255,255,0.08); transform: translateY(-4px); }
    .btn:hover, .button-primary:hover { transform: translateY(-2px); }
}

/* ── Tablet ────────────────────────────────────── */
@media (max-width: 1024px) {
    .nav-links { display: none; }
    .mobile-toggle { display: flex; }
    .hero { grid-template-columns: 1fr; padding: 2rem 0 3rem; }
    .hero h1 { font-size: 2.6rem; }
    .hero-visual { height: 360px; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .chat-container { grid-template-columns: 1fr; }
    .chat-sidebar { max-height: 200px; }
    .balance-badge { font-size: 0.68rem; }
    .navbar { max-width: 750px; }
    .navbar.scrolled { max-width: 850px; }
}

@media (max-width: 900px) {
    .balance-badge { font-size: 0.68rem; padding: 0.25rem 0.4rem; }
    .icon-btn { width: 32px; height: 32px; font-size: 0.75rem; }
    .navbar { max-width: 700px; }
    .navbar.scrolled { max-width: 800px; }
}

/* ── Mobile (≤768px) — Master block ────────────── */
@media (max-width: 768px) {

    /* ── Cursor & pointer ─────────────────────────── */
    .cursor-ring, .cursor-dot { display: none !important; }

    /* ── Touch targets: minimum 44px (WCAG) ──────── */
    .icon-btn, .user-avatar, .user-menu, .adm-icon-btn,
    .chat-send, .fav-btn, .buy-btn-direct, .pay-method,
    .wallet-card, .modal-product-image, .product-image,
    .product-img, .adm-btn, .adm-table td, .adm-table tr,
    .calc-pick-item, .calc-tab, .tab-pill, .close-btn,
    .btn, .mobile-toggle, .pf-tab, .wallet-card-btn,
    .copy-btn, .lite-switch {
        min-width: 44px !important;
        min-height: 44px !important;
    }

    /* ── Prevent double-tap zoom ──────────────────── */
    * { -webkit-tap-highlight-color: transparent; }

    /* ── Container ────────────────────────────────── */
    .container { padding: 0 0.8rem; }

    /* ── Navbar ───────────────────────────────────── */
    .navbar {
        padding: 0.35rem 0.5rem;
        margin: 0.3rem 0.4rem;
        max-width: none;
        border-radius: var(--radius-sm);
        position: relative;
        z-index: 1000;
    }
    .navbar.scrolled { padding: 0.35rem 0.6rem; }
    .logo { font-size: 0.85rem; gap: 0.4rem; flex-shrink: 0; }
    .logo-icon { width: 24px; height: 24px; font-size: 0.7rem; border-radius: 6px; }
    .nav-links { display: none; }
    .mobile-toggle {
        display: flex;
        width: 44px; height: 44px;
        align-items: center; justify-content: center;
        font-size: 1.1rem;
    }
    .nav-actions { gap: 0.25rem; overflow: hidden; }
    .nav-actions > a.icon-btn:first-child { display: none; }
    .balance-badge { display: none; }
    .icon-btn { width: 36px; height: 36px; font-size: 0.78rem; border-radius: var(--radius-sm); }
    .btn-primary { padding: 0.45rem 0.9rem; font-size: 0.8rem; border-radius: 20px; }

    /* ── User dropdown (positioned to avoid overflow) */
    .user-dropdown {
        right: -0.5rem;
        min-width: 240px;
        max-width: calc(100vw - 1rem);
    }

    /* ── Mobile menu ──────────────────────────────── */
    .mobile-menu { gap: 0.8rem; padding: 1rem; }
    .mobile-menu button { font-size: 1.1rem; padding: 0.6rem 1rem; min-height: 48px; }

    /* ── Hero ─────────────────────────────────────── */
    .hero { grid-template-columns: 1fr; padding: 1.5rem 0 2rem; text-align: center; }
    .hero h1 { font-size: 1.8rem; line-height: 1.15; }
    .hero p { font-size: 0.85rem; margin: 0 auto 1.2rem; }
    .hero-cta { justify-content: center; }
    .hero-stats { justify-content: center; gap: 1rem; }
    .hero-visual { display: none; }

    /* ── Sections ─────────────────────────────────── */
    .section { padding: 1.5rem 0; }
    .section-title { font-size: 1.3rem; }
    .section-subtitle { font-size: 0.78rem; }
    .section-head { flex-direction: column; align-items: flex-start; }
    .page-content { overflow-x: clip; }

    /* ── Product cards (2-col) ────────────────────── */
    .products-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
    .product-image, .product-img { height: 90px; font-size: 2.2rem; border-radius: var(--radius-sm); }
    .product-card { padding: 0.7rem; border-radius: var(--radius-md); }
    .product-title { font-size: 0.8rem; }
    .product-desc { font-size: 0.68rem; min-height: 1.6em; }
    .product-bottom { flex-direction: column; gap: 0.4rem; align-items: stretch; }
    .buy-btn-direct {
        width: 100%; justify-content: center;
        padding: 0.55rem; font-size: 0.72rem;
        min-height: 44px;
    }
    .current-price { font-size: 1rem; }

    /* ── Listings ─────────────────────────────────── */
    .listings-grid { grid-template-columns: 1fr; gap: 0.6rem; }
    .listing-icon { width: 40px; height: 40px; font-size: 1.5rem; }
    .listing-title { font-size: 0.88rem; }
    .news-card .listing-header { padding: 0.6rem; }

    /* ── Orders ───────────────────────────────────── */
    .order-card { grid-template-columns: 1fr; gap: 0.6rem; padding: 0.8rem; }
    .order-icon { width: 40px; height: 40px; font-size: 1.5rem; }
    .order-actions { flex-direction: column; }
    .order-actions .btn { width: 100%; min-height: 44px; }

    /* ── Wallet ───────────────────────────────────── */
    .wallet-cards { grid-template-columns: 1fr; }
    .wallet-card-balance { font-size: 1.5rem; }
    .wallet-card-actions { flex-direction: column; }
    .wallet-card-btn { width: 100%; min-height: 44px; }

    /* ── Profile ──────────────────────────────────── */
    .profile-header { flex-direction: column; text-align: center; gap: 1rem; }
    .profile-info { text-align: center; }
    .profile-info h2 { text-align: center; font-size: 1.2rem; }

    /* ── Features ─────────────────────────────────── */
    .features-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
    .feature-card { padding: 0.8rem; }
    .feature-icon { width: 36px; height: 36px; font-size: 0.9rem; }
    .feature-card h4 { font-size: 0.82rem; }
    .feature-card p { font-size: 0.7rem; }

    /* ── Reviews ──────────────────────────────────── */
    .reviews-grid { grid-template-columns: 1fr; }
    .review-card { padding: 1rem; }

    /* ── Chat ─────────────────────────────────────── */
    .chat-container { grid-template-columns: 1fr; height: auto; }
    .chat-sidebar { max-height: 180px; }
    .chat-main { min-height: 350px; }
    .chat-msg { max-width: 85%; font-size: 0.82rem; }
    .chat-input { font-size: 0.82rem; }
    .chat-actions { padding: 0.5rem; }
    .chat-input-area { padding: 0.6rem; }
    .chat-send { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
    .chat-header { padding: 0.7rem 1rem; }
    .chat-messages { padding: 1rem; }

    /* ── Support chat ─────────────────────────────── */
    .support-chat-main { height: 65vh; min-height: 400px; }
    .support-chat-input { padding: 0.7rem; }
    .support-chat-messages { padding: 1rem; }

    /* ── Modals ───────────────────────────────────── */
    .modal { max-width: 95vw; margin: 0.5rem; border-radius: var(--radius-lg); max-height: 95vh; }
    .modal-body { padding: 1rem; }
    .modal-product-image { height: 140px; font-size: 3.5rem; }
    .modal-header { padding: 0.8rem 1rem; }

    /* ── Auth / Forms ─────────────────────────────── */
    .auth-card { padding: 1.5rem; max-width: 100%; border-radius: var(--radius-lg); }
    .auth-card h2 { font-size: 1.3rem; }
    .form-group { margin-bottom: 1rem; }
    .form-group label { font-size: 0.7rem; }
    .form-input { padding: 0.65rem 0.9rem; font-size: 0.85rem; }
    .btn { padding: 0.5rem 0.8rem; font-size: 0.75rem; }

    /* ── Footer ───────────────────────────────────── */
    .footer-grid { grid-template-columns: 1fr; gap: 1.2rem; }
    .footer-col { text-align: left; padding: 0 0.5rem; }
    .footer-col h5 { font-size: 0.85rem; margin-bottom: 0.7rem; }
    .footer-col a { font-size: 0.78rem; display: block; margin-bottom: 0.5rem; padding: 0.3rem 0; line-height: 1.6; }
    .social-links { justify-content: flex-start; gap: 0.6rem; }
    .social-links a { width: 36px; height: 36px; flex-shrink: 0; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); }
    .social-links a i { font-size: 1rem; color: var(--text-1); }

    /* ── Filters (horizontal scroll) ──────────────── */
    .filters-bar { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.5rem; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .filters-bar::-webkit-scrollbar { display: none; }
    .tab-pill { white-space: nowrap; flex-shrink: 0; padding: 0.45rem 0.9rem; font-size: 0.75rem; }
    .filter-spacer { display: none; }

    /* ── Admin table (horizontal scroll) ──────────── */
    .admin-stats { grid-template-columns: 1fr 1fr; }
    .admin-stat .val { font-size: 1.3rem; }
    .admin-stat { padding: 0.8rem; }
    .admin-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.3rem; }
    .admin-table { font-size: 0.72rem; }
    .admin-table th, .admin-table td { padding: 0.4rem 0.3rem; }
    .admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
    .admin-table-wrap::-webkit-scrollbar { height: 4px; }
    .admin-table-wrap::-webkit-scrollbar-track { background: transparent; }
    .admin-table-wrap::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 2px; }
    .admin-table { min-width: 500px; }

    /* ── Toasts ───────────────────────────────────── */
    .toast-container { left: 10px; right: 10px; bottom: 10px; }
    .toast { max-width: 100%; font-size: 0.8rem; }

    /* ── Marquee ──────────────────────────────────── */
    .marquee-track span { font-size: 0.72rem; }
    .marquee-track { gap: 0.8rem; }

    /* ── Payment ──────────────────────────────────── */
    .payment-receipt .value { font-size: 0.85rem; }
    .payment-receipt .value.big { font-size: 1rem; }
    .copy-btn { font-size: 0.7rem; padding: 0.3rem 0.6rem; }

    /* ── Stats ────────────────────────────────────── */
    .stat-item .num { font-size: 1.3rem; }
    .stat-item .label { font-size: 0.68rem; }

    /* ── Forms single-column ──────────────────────── */
    #createListingForm,
    #addProductForm,
    #addWorkerForm,
    #addAdminForm,
    #createPromoForm,
    #createNewsForm {
        grid-template-columns: 1fr !important;
    }
    .contact-grid { grid-template-columns: 1fr !important; }
    .btn { width: 100%; justify-content: center; }
    .wallet-card-btn { width: 100%; }
    .row-actions { flex-wrap: wrap; }
    .row-actions .btn { flex: 1; min-width: 0; }

    /* ── Admin panel ──────────────────────────────── */
    .adm-shell { grid-template-columns: 1fr; gap: 1rem; }
    .adm-main { min-width: 0; }
    .adm-table-wrap { -webkit-overflow-scrolling: touch; }
    .adm-page-head { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
    .adm-page-head-actions { width: 100%; }
    .adm-form-grid { gap: 0.6rem; }
    .adm-toolbar { gap: 0.4rem; }
    .adm-icon-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }

    /* ── Touch improvements ───────────────────────── */
    .fav-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }

    /* ── Ensure no horizontal overflow ────────────── */
    .section { padding: 1rem 0; }
}

/* ── Small mobile (≤480px) ─────────────────────── */
@media (max-width: 480px) {
    .container { padding: 0 0.6rem; }

    .navbar { padding: 0.3rem 0.4rem; margin: 0.3rem; border-radius: var(--radius-sm); }
    .navbar.scrolled { padding: 0.3rem 0.5rem; }
    .logo { font-size: 0.78rem; gap: 0.35rem; }
    .logo-icon { width: 22px; height: 22px; font-size: 0.65rem; border-radius: 5px; }
    .icon-btn { width: 36px; height: 36px; font-size: 0.72rem; }

    .hero h1 { font-size: 1.4rem; line-height: 1.2; }
    .hero p { font-size: 0.8rem; }
    .hero-cta { gap: 0.6rem; }
    .hero-cta .btn { padding: 0.5rem 0.8rem; font-size: 0.72rem; }
    .hero-badge { font-size: 0.55rem; padding: 0.3rem 0.7rem; }
    .hero-stats { gap: 0.8rem; }
    .stat-item .num { font-size: 1.1rem; }
    .stat-item .label { font-size: 0.6rem; }

    .products-grid { grid-template-columns: 1fr 1fr; gap: 0.4rem; }
    .product-card { padding: 0.4rem; border-radius: 0.6rem; }
    .product-image { height: 70px; font-size: 1.8rem; border-radius: 0.5rem; }
    .product-title { font-size: 0.72rem; }
    .product-desc { font-size: 0.62rem; min-height: 1.4em; }
    .product-bottom { padding-top: 0.5rem; }
    .current-price { font-size: 0.85rem; }
    .buy-btn-direct { padding: 0.4rem 0.6rem; font-size: 0.68rem; }

    .features-grid { grid-template-columns: 1fr 1fr; gap: 0.4rem; }
    .feature-card { padding: 0.6rem; }
    .feature-icon { width: 32px; height: 32px; font-size: 0.8rem; margin-bottom: 0.5rem; }
    .feature-card h4 { font-size: 0.75rem; }
    .feature-card p { font-size: 0.65rem; }

    .section-title { font-size: 1.1rem; }
    .section-subtitle { font-size: 0.72rem; }

    .modal { margin: 0.3rem; }
    .modal-product-image { height: 120px; font-size: 3rem; }
    .modal-title { font-size: 1.2rem; }
    .modal-body { padding: 0.8rem; }

    .footer-col a { font-size: 0.72rem; padding: 0.2rem 0; }
    .footer-col h5 { font-size: 0.78rem; }

    .reviews-grid { grid-template-columns: 1fr; }
    .review-card { padding: 1rem; }

    .wallet-card-balance { font-size: 1.3rem; }
    .wallet-card { padding: 1rem; }

    .pf-avatar { width: 56px; height: 56px; font-size: 1.4rem; }
    .pf-name { font-size: 1.1rem; }
    .pf-stat-val { font-size: 0.9rem; }
    .pf-stat-lbl { font-size: 0.65rem; }
    .pf-tabs { gap: 0.25rem; }
    .pf-tab { padding: 0.4rem 0.6rem; font-size: 0.72rem; }

    .auth-card { padding: 1.2rem; }
    .auth-card h2 { font-size: 1.1rem; }

    .adm-grid-4 { grid-template-columns: 1fr 1fr !important; }
    .adm-stat-value { font-size: 1.2rem; }
    .adm-stat-title { font-size: 0.68rem; }
    .adm-stat-sub { font-size: 0.65rem; }
    .adm-sidebar-stats { grid-template-columns: 1fr 1fr; gap: 0.3rem; }

    .chat-msg { max-width: 90%; font-size: 0.8rem; }
    .chat-container { height: auto; min-height: 100vh; }
    .chat-sidebar { max-height: 150px; }
    .chat-main { min-height: 300px; }
}

/* ── Reduced motion ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .particle { display: none !important; }
    .marquee-track { animation: none !important; }
}
