/* ============================================
   TECHSHOP LANKA — Mobile Responsive Styles
   ============================================ */

/* ─── TOPBAR — Hide on mobile ─── */
@media (max-width: 767px) {
    .topbar { display: none; }
}

/* ─── NAVBAR BASE ─── */
.navbar-logo { max-height: 44px; width: auto; object-fit: contain; }
.brand-text { font-family: 'Outfit', sans-serif; font-size: 22px; font-weight: 800; color: var(--text-primary); }
.brand-accent { color: var(--accent); }
.navbar-inner { display: flex; align-items: center; gap: 12px; padding: 10px 0; position: relative; }
.navbar-categories { display: flex; align-items: center; gap: 4px; flex: 1; overflow: hidden; }
.nav-cat-link { color: var(--text-secondary); font-size: 13px; font-weight: 500; padding: 6px 10px; border-radius: 6px; transition: var(--transition); white-space: nowrap; background: none; border: none; cursor: pointer; }
.nav-cat-link:hover { color: var(--text-primary); background: var(--bg-secondary); }
.navbar-search { flex: 0 0 260px; position: relative; }
.search-wrap { display: flex; align-items: center; }
.search-input { width: 100%; background: var(--bg-secondary); border: 1px solid var(--border); color: var(--text-primary); padding: 9px 14px; border-radius: var(--radius-sm) 0 0 var(--radius-sm); font-size: 13px; outline: none; transition: var(--transition); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-btn { background: var(--accent); color: #fff; border: none; padding: 9px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; cursor: pointer; font-size: 14px; transition: var(--transition); flex-shrink: 0; }
.search-btn:hover { background: var(--accent-dark); }
.navbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.nav-action-btn { background: var(--bg-secondary); border: 1px solid var(--border); color: var(--text-primary); padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 16px; display: flex; align-items: center; gap: 6px; transition: var(--transition); position: relative; white-space: nowrap; }
.nav-action-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav-username { font-size: 13px; font-weight: 600; }
.user-avatar-sm { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; font-weight: 800; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-cat-more { position: relative; }
.mega-menu { display: none; position: absolute; top: calc(100% + 8px); left: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; z-index: 100; min-width: 240px; grid-template-columns: 1fr 1fr; gap: 4px; box-shadow: var(--shadow-lg); }
.mega-menu-item { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 13px; transition: var(--transition); }
.mega-menu-item:hover { background: var(--bg-secondary); color: var(--accent); }
.nav-login-btn { font-size: 13px !important; }
.nav-login-btn span { display: inline; }

/* ─── HAMBURGER ─── */
.hamburger-btn { display: none; background: none; border: none; padding: 6px; cursor: pointer; flex-direction: column; gap: 5px; align-items: center; justify-content: center; transition: var(--transition); min-width: 36px; min-height: 36px; border-radius: var(--radius-sm); }
.hamburger-btn:hover { background: var(--bg-secondary); }
.hamburger-line { display: block; width: 22px; height: 2px; background: var(--text-primary); border-radius: 2px; transition: all 0.3s ease; transform-origin: center; }
.hamburger-btn.is-active .hamburger-line:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger-btn.is-active .hamburger-line:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.is-active .hamburger-line:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ─── MOBILE SEARCH BAR (always visible below navbar on mobile) ─── */
.mobile-searchbar {
    display: none;
    padding: 8px 12px;
    background: var(--navbar-bg, #fff);
    border-top: 1px solid var(--border);
}
.mobile-searchbar .search-wrap { display: flex; }
.mobile-searchbar .search-input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); font-size: 15px; padding: 11px 14px; }
.mobile-searchbar .search-btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 11px 16px; font-size: 16px; }

/* ─── MOBILE NAV DRAWER ─── */
.mobile-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: min(320px, 85vw);
    height: 100vh;
    background: #ffffff !important;
    z-index: 1005;
    padding: 20px 0 40px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 35px rgba(0, 0, 0, 0.3);
    -webkit-font-smoothing: antialiased;
}
.mobile-nav.open { transform: translateX(0); }
.mobile-nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s, visibility 0.3s;
}
.mobile-nav-overlay.open { opacity: 1; visibility: visible; pointer-events: auto; }
.mobile-search-wrap { display: flex; margin: 0 16px 16px; }
.mobile-search-wrap .search-input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.mobile-search-wrap .search-btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.mobile-nav-section { padding: 0 0 12px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.mobile-nav-section:last-child { border-bottom: none; }
.mobile-nav-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); padding: 10px 16px 4px; }
.mobile-nav-item { display: flex; align-items: center; gap: 10px; padding: 13px 16px; color: var(--text-secondary); font-size: 15px; transition: var(--transition); border-left: 3px solid transparent; min-height: 48px; }
.mobile-nav-item:active { background: var(--bg-secondary); }
.mobile-nav-item:hover { color: var(--text-primary); background: var(--bg-secondary); border-left-color: var(--accent); }
.mobile-nav-item i { width: 20px; text-align: center; opacity: 0.7; }
.mobile-cat-toggle-btn {
    background: none;
    border: none;
    padding: 10px 16px;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    min-width: 48px;
}
.mobile-cat-toggle-btn:hover, .mobile-cat-toggle-btn:active {
    color: var(--accent);
}
.mobile-subcat-container {
    background: var(--bg-secondary, #f8fafc);
    border-left: 3px solid var(--accent);
    margin-left: 16px;
    border-radius: 0 0 8px 8px;
}
.mobile-sub-item {
    padding-left: 20px !important;
    font-size: 14px !important;
    min-height: 42px !important;
    color: var(--text-secondary);
}
.mobile-sub-item:hover, .mobile-sub-item:active {
    color: var(--accent);
}

/* ─── WHATSAPP FLOAT BUTTON ─── */
.whatsapp-float { position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px; background: #25d366; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; color: #fff; box-shadow: 0 4px 20px rgba(37,211,102,0.4); z-index: 900; transition: transform .2s, box-shadow .2s; text-decoration: none; }
.whatsapp-float:hover { transform: scale(1.1); box-shadow: 0 6px 28px rgba(37,211,102,0.6); color: #fff; }
.whatsapp-tooltip { position: absolute; right: calc(100% + 12px); background: rgba(0,0,0,0.8); color: #fff; padding: 6px 12px; border-radius: 6px; font-size: 12px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .2s; }
.whatsapp-float:hover .whatsapp-tooltip { opacity: 1; }
@media (max-width: 480px) { .whatsapp-float { bottom: 16px; right: 16px; width: 50px; height: 50px; font-size: 26px; } }

/* ─── SEARCH RESULTS DROPDOWN ─── */
.search-results { position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; z-index: 300; box-shadow: var(--shadow-lg); display: none; }
.search-results.open { display: block; }
.search-result-item { display: flex; align-items: center; gap: 12px; padding: 12px; transition: var(--transition); }
.search-result-item:hover, .search-result-item:active { background: var(--bg-secondary); }
.search-result-item img { width: 44px; height: 44px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; }
.search-result-info h4 { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.search-result-info p { font-size: 12px; color: var(--accent); font-weight: 700; }

/* ─── MOBILE SEARCH RESULTS ─── */
.mobile-searchbar { position: relative; }
.mobile-searchbar .search-results { top: calc(100% + 4px); }

/* ─── NAVBAR SCROLLED STATE ─── */
.navbar.scrolled { box-shadow: 0 4px 20px rgba(0,0,0,0.12); }

/* ─── USER DROPDOWN ─── */
.dropdown-menu { position: absolute; top: calc(100% + 8px); right: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); min-width: 200px; z-index: 200; box-shadow: var(--shadow-lg); display: none; overflow: hidden; }
.dropdown-menu.open { display: block; }
.dropdown-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--text-secondary); font-size: 14px; transition: var(--transition); border-bottom: 1px solid var(--border); min-height: 46px; }
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover, .dropdown-item:active { background: var(--bg-secondary); color: var(--text-primary); }
.dropdown-item i { width: 16px; text-align: center; }

/* ─── TOPBAR LINKS ─── */
.topbar-link { color: var(--text-secondary); font-size: 12px; display: flex; align-items: center; gap: 5px; text-decoration: none; transition: var(--transition); }
.topbar-link:hover { color: var(--text-primary); }
.topbar-hours { display: none; }
@media (min-width: 1024px) { .topbar-hours { display: flex; } }

/* ─── CART ─── */
.cart-badge { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.cart-badge.hidden { display: none; }

/* ─── FOOTER ─── */
.footer-brand-col { flex: 0 0 auto; max-width: 280px; }
.footer-logo { max-height: 50px; max-width: 160px; object-fit: contain; margin-bottom: 12px; }
.footer-bottom-inner { display: flex; align-items: center; justify-content: space-between; padding: 20px 0; flex-wrap: wrap; gap: 12px; }
.footer-legal { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-legal a { font-size: 13px; color: var(--text-secondary); }
.footer-legal a:hover { color: var(--text-primary); }
.footer-contact { display: flex; flex-direction: column; gap: 8px; }
.footer-contact-row { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.footer-contact-icon { color: var(--accent); width: 14px; flex-shrink: 0; margin-top: 2px; }
.footer-payment { margin-top: 16px; }
.payment-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.payment-badge { background: var(--bg-card); border: 1px solid var(--border); padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; letter-spacing: .5px; color: var(--text-secondary); }
.social-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--bg-secondary); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--text-secondary); transition: var(--transition); }
.social-btn:hover { background: var(--hover-color, var(--accent)); color: #fff; border-color: transparent; transform: translateY(-2px); }
.footer-col-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; color: var(--text-primary); letter-spacing: .3px; }

/* ─── PRODUCT GRID RESPONSIVE ─── */
@media (max-width: 1199px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 767px)  { .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
@media (max-width: 380px)  { .product-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; } }

/* ─── HERO RESPONSIVE ─── */
@media (max-width: 991px) {
    .hero-content { grid-template-columns: 1fr; gap: 32px; }
    .hero-image-wrap { display: none; }
    .hero-title { font-size: clamp(28px, 7vw, 52px); }
    .hero-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .hero-section { padding: 40px 0 32px; }
    .hero-title { font-size: 28px; }
    .hero-stats { gap: 12px; }
}

/* ─── CATEGORY GRID RESPONSIVE ─── */
@media (max-width: 767px)  { .category-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; } }
@media (max-width: 400px)  { .category-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; } }

/* ─── PROMO BANNERS RESPONSIVE ─── */
@media (max-width: 767px) {
    .promo-banners { grid-template-columns: 1fr; gap: 10px; }
}

/* ─── FILTER LAYOUT RESPONSIVE ─── */
.mobile-filter-btn { display: none !important; }
.mobile-close-filter { display: none !important; }

@media (max-width: 991px) {
    .mobile-filter-btn { display: inline-flex !important; align-items: center; gap: 6px; }
    .mobile-close-filter { display: inline-block !important; }
    .filter-layout { grid-template-columns: 1fr; }
    .filter-sidebar {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 1010;
        background: rgba(15, 23, 42, 0.65);
        backdrop-filter: blur(4px);
        padding: 16px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .filter-sidebar.mobile-open {
        display: flex;
        align-items: flex-start;
        justify-content: center;
        animation: fadeIn 0.25s ease;
    }
    .filter-sidebar .card {
        width: 100%;
        max-width: 380px;
        margin: 20px auto;
        position: relative !important;
        top: 0 !important;
        max-height: 85vh;
        overflow-y: auto;
        box-shadow: 0 20px 40px rgba(0,0,0,0.3);
        border-radius: 16px;
        padding: 20px;
    }
}

/* ─── PRODUCT DETAIL RESPONSIVE ─── */
@media (max-width: 900px) {
    .pd-grid { grid-template-columns: 1fr; gap: 20px; }
    .pd-gallery { position: static !important; }
    .pd-action-row { flex-direction: column; }
    .pd-action-row .btn { flex: none; width: 100%; }
    .pd-trust { gap: 8px; }
    .pd-trust-item { min-width: 45%; font-size: 11px; }
}
@media (max-width: 767px) {
    .product-detail-wrap { grid-template-columns: 1fr; gap: 24px; }
    .product-action-btns { flex-direction: column; }
    .pd-tabs-nav { overflow-x: auto; scrollbar-width: none; }
    .pd-tabs-nav::-webkit-scrollbar { display: none; }
    .pd-tab-btn { padding: 11px 16px; font-size: 13px; }
}

/* ─── CHECKOUT RESPONSIVE ─── */
@media (max-width: 991px) {
    .checkout-wrap { grid-template-columns: 1fr; }
}

/* ─── ACCOUNT LAYOUT RESPONSIVE ─── */
@media (max-width: 767px) {
    .account-layout { grid-template-columns: 1fr; }
    .account-sidebar { display: flex; flex-direction: column; }
}

/* ─── FORM ROW RESPONSIVE ─── */
@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr !important; }
}

/* ─── GRID-2 RESPONSIVE ─── */
@media (max-width: 767px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* ─── FOOTER RESPONSIVE ─── */
.footer-main { display: grid; grid-template-columns: 260px repeat(3, 1fr); gap: 40px; padding: 48px 0; }
@media (max-width: 1199px) { .footer-main { grid-template-columns: 1fr 1fr; } .footer-brand-col { max-width: 100%; } }
@media (max-width: 767px)  {
    .footer-main { grid-template-columns: 1fr 1fr; gap: 28px; padding: 32px 0; }
    .footer-brand-col { grid-column: 1 / -1; }
    .footer-bottom-inner { flex-direction: column; text-align: center; }
    .footer-legal { justify-content: center; }
}
@media (max-width: 480px)  { .footer-main { grid-template-columns: 1fr; } }

/* ─── NAVBAR RESPONSIVE BREAKPOINTS ─── */
@media (max-width: 1100px) {
    .navbar-categories { display: none; }
    .navbar-search { flex: 1; }
}
@media (max-width: 767px) {
    .hamburger-btn { display: flex; }
    .mobile-searchbar { display: block; }   /* show search bar below navbar on mobile */
    .navbar-search { display: none; }       /* hide inline search on mobile */
    .nav-username { display: none; }
    .nav-login-btn span { display: none; }
    /* ── Smaller icon buttons on mobile ── */
    .nav-action-btn {
        padding: 6px 8px;
        font-size: 15px;
        min-height: 38px;
        min-width: 38px;
        justify-content: center;
    }
    .nav-login-btn { padding: 6px 8px; }
    .brand-text { font-size: 18px; }
    .navbar-logo { max-height: 36px; }
    .navbar-inner { padding: 8px 0; gap: 6px; }
}
@media (max-width: 480px) {
    /* ── Even smaller on very small screens ── */
    .nav-action-btn { padding: 5px 7px; font-size: 14px; min-height: 36px; min-width: 36px; }
    .hamburger-btn { padding: 5px; }
    .hamburger-line { width: 18px; }
    .brand-text { font-size: 16px; }
    .navbar-logo { max-height: 32px; }
    .navbar-inner { gap: 5px; }
    .container { padding: 0 10px; }
}

/* ─── ADMIN RESPONSIVE ─── */
@media (max-width: 991px) {
    .admin-sidebar { transform: translateX(-100%); transition: transform .3s ease; position: fixed; z-index: 300; }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-left: 0 !important; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .admin-content { padding: 16px; }
    .table-wrap { overflow-x: auto; }
    .table { min-width: 600px; }
}
@media (max-width: 400px) {
    .kpi-grid { grid-template-columns: 1fr; }
}

/* ─── CART SIDEBAR RESPONSIVE ─── */
.cart-sidebar { width: min(400px, 95vw); }
@media (max-width: 480px) {
    .cart-sidebar { width: 100vw; border-radius: 0; }
}

/* ─── TABLE RESPONSIVE ─── */
@media (max-width: 767px) {
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ─── CONTAINER RESPONSIVE ─── */
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .container { padding: 0 24px; } }
@media (min-width: 1024px) { .container { padding: 0 32px; } }

/* ─── TOUCH IMPROVEMENTS — Fix iOS tap delay & div click ─── */
* { -webkit-tap-highlight-color: transparent; }
.product-card,
.category-card,
.mobile-nav-item,
.search-result-item,
.btn,
.nav-action-btn,
.dropdown-item,
.pd-thumb,
.pd-tab-btn {
    touch-action: manipulation;  /* removes 300ms tap delay */
    -webkit-tap-highlight-color: transparent;
}
.product-card { cursor: pointer; }

/* ─── TOUCH ACTIVE STATES ─── */
@media (hover: none) {
    .product-card:active { transform: scale(0.97); box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
    .btn:active { transform: scale(0.96); opacity: 0.9; }
    .category-card:active { transform: scale(0.96); }
    .mobile-nav-item:active { background: var(--bg-secondary); border-left-color: var(--accent); }
    .nav-action-btn:active { background: var(--accent-light); border-color: var(--accent); }
}

/* ─── TOUCH TARGETS (minimum 44px for Apple HIG) ─── */
.btn, .nav-action-btn, .cart-toggle, .hamburger-btn, a.mobile-nav-item, .social-btn, .product-add-cart {
    min-height: 44px;
}

/* ─── SAFE AREA (iPhone X+) ─── */
body {
    padding-bottom: env(safe-area-inset-bottom);
}
.navbar {
    padding-top: env(safe-area-inset-top);
}

/* ─── PRODUCT CARD MOBILE TWEAKS ─── */
@media (max-width: 767px) {
    .product-card-body { padding: 10px 10px 12px; }
    .product-card-name { font-size: 12px; }
    .product-price-current { font-size: 15px; }
    .product-add-cart { padding: 7px 9px; font-size: 11px; min-height: 36px; }
    .product-card-stock { font-size: 10px; }
    .product-card-category { font-size: 9px; }
    .gallery-thumb { width: 56px; height: 56px; }
}

/* ─── SLIDE HERO MOBILE ─── */
@media (max-width: 767px) {
    .slide { height: 220px; }
    .slide-text { padding: 16px 20px; }
    .slide-title { font-size: 18px; line-height: 1.25; }
    .slide-subtitle { font-size: 12px; display: none; }
    .slide-prev, .slide-next { width: 32px; height: 32px; font-size: 11px; }
    .slide-prev { left: 8px; } .slide-next { right: 8px; }
    .slide-badge { font-size: 10px; padding: 3px 10px; }
    .slide-actions .btn { padding: 8px 16px; font-size: 13px; }
}

/* ─── STICKY OVERRIDES FOR MOBILE ─── */
@media (max-width: 991px) {
    [style*="position:sticky"], [style*="position: sticky"] {
        position: static !important;
    }
}
