/* ═══════════════════════════════════════════════════════════
   mobile.css — Mobile Overrides (separate from desktop styles)
   Loaded after styles.css in header.php
   ═══════════════════════════════════════════════════════════ */

/* ── General ──────────────────────────────────────────── */
@media (max-width: 576px) {
    body {
        padding-top: 56px !important;
    }
    .main-content {
        padding: 15px 0;
        min-height: 40vh;
    }
}

@media (max-width: 400px) {
    body {
        padding-top: 50px !important;
    }
}

/* ── Navbar Overrides ─────────────────────────────────── */
@media (max-width: 991.98px) {
    /* Search input: full width in collapsed navbar */
    #liveSearchInput,
    .live-search-inline input {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* Live search results: inside navbar flow with own scroll */
    .live-search-results {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        min-width: auto !important;
        max-height: 55vh !important;
        overflow-y: auto !important;
        transform: none !important;
        width: 100% !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        margin-top: 4px !important;
    }

    /* Navbar items: bigger touch targets */
    .navbar-nav .nav-link {
        padding: 10px 12px !important;
        font-size: 15px;
    }

    /* Remove hover dropdown on mobile — use click instead */
    .dropdown-hover:hover > .dropdown-menu {
        display: none !important;
    }
    .dropdown-hover.show > .dropdown-menu {
        display: block !important;
    }

    /* Navbar collapse: allow scrolling on mobile */
    #navbarMain,
    #hpNavWidget {
        max-height: 80vh;
        overflow-y: auto;
    }

    /* Mega menu: full width on mobile */
    .dropdown-roots {
        min-width: auto !important;
        width: 100%;
        border-radius: 0;
        box-shadow: none;
    }
    .root-item {
        position: static !important;
    }
    .root-item:hover > .mega-menu {
        display: none !important;
    }
    .root-item.show > .mega-menu {
        display: block !important;
    }
    .mega-menu {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        left: auto !important;
        top: auto !important;
        border-radius: 0;
        box-shadow: none;
        margin: 0;
        border: none;
        padding: 0;
        background: transparent;
    }
    .mega-menu .container {
        padding: 0;
        max-width: 100%;
    }
    .mega-menu .row {
        flex-wrap: wrap;
        margin: 0;
    }
    .mega-menu .menu-col {
        flex: 0 0 100%;
        max-width: 100%;
        border-right: none;
        padding: 0;
        white-space: normal;
    }
    .mega-menu .mega-group {
        margin-bottom: 0;
        padding: 0;
    }
    .mega-menu .mega-heading {
        white-space: normal;
        font-weight: 600;
        font-size: 0.85rem;
        padding: 8px 16px;
        border-bottom: 1px solid #f0f0f0;
        color: #333;
        background: #f5f5f5;
    }
    .mega-menu .mega-link {
        padding: 8px 16px 8px 28px;
        white-space: normal;
        font-size: 0.85rem;
        border-bottom: 1px solid #f8f8f8;
        color: #555;
    }
    .mega-menu .mega-link:last-child {
        border-bottom: none;
    }
}

/* ── Hero Slider ──────────────────────────────────────── */
@media (max-width: 576px) {
    .hero-slider {
        border-radius: 0;
        box-shadow: none;
        margin-top: 0;
        margin-bottom: 15px;
    }
    .hero-slider .slider-img {
        height: auto !important;
        aspect-ratio: 16 / 9;
        object-fit: contain;
        object-position: center;
    }
    .hero-slider .slider-placeholder {
        height: 200px !important;
    }
    .hero-slider .carousel-control-prev,
    .hero-slider .carousel-control-next {
        width: 32px;
        height: 32px;
    }
    .hero-slider .carousel-control-prev {
        left: 4px;
    }
    .hero-slider .carousel-control-next {
        right: 4px;
    }
    .hero-slider .carousel-control-prev-icon,
    .hero-slider .carousel-control-next-icon {
        padding: 10px;
        background-size: 50%;
    }
    .hero-slider .slider-caption-minimal {
        bottom: 10px;
    }
    .hero-slider .slider-caption-minimal p {
        font-size: 0.75rem;
        padding: 3px 10px;
    }

    /* Theme Editor slider - full image on mobile */
    .hp-widget-slider .slider-img {
        height: auto !important;
        aspect-ratio: 16 / 9;
        object-fit: contain;
    }
    /* Categories widget: stacked vertically on mobile */
    .hp-cat-img {
        width: var(--cat-img-size-mobile, 75px) !important;
    }
    .hp-widget-categories .hp-section-title-left,
    .hp-widget-categories .hp-section-title {
        font-size: var(--cat-title-size-mobile, 14px) !important;
    }
    .hp-cat-flex-row {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }
    .hp-cat-card {
        width: 100% !important;
        max-width: 100%;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }
    .hp-cat-img {
        aspect-ratio: auto !important;
        height: auto !important;
        min-height: 120px;
        border-radius: 0 !important;
        background: transparent !important;
    }
    .hp-cat-img img {
        object-fit: contain !important;
    }
}

/* ── Products Widget (Theme Editor) ──────────────────── */
@media (max-width: 576px) {
    .hp-product-img-wrap {
        height: var(--prod-img-size-mobile, 120px) !important;
    }
    .hp-product-img-wrap .hp-product-img {
        object-fit: contain !important;
    }
    .hp-product-list-img {
        width: var(--prod-img-size-mobile, 120px) !important;
        height: var(--prod-img-size-mobile, 120px) !important;
    }
    .hp-product-name, .hp-product-list-name {
        font-size: var(--prod-name-size-mobile, 12px) !important;
    }
    .hp-add-to-cart-btn, .hp-add-to-cart-list-btn {
        font-size: var(--prod-cart-size-mobile, 11px) !important;
    }
    .hp-section-title, .hp-section-title-left {
        font-size: var(--prod-title-size-mobile, 16px) !important;
    }
}

/* ── Product Cards ────────────────────────────────────── */
@media (max-width: 576px) {
    .product-card .card-img-top {
        height: auto !important;
        aspect-ratio: 1 / 1;
        object-fit: cover;
    }
    .product-card .card-body {
        padding: 10px;
    }
    .product-card .card-title {
        font-size: 0.85rem;
        min-height: auto;
        margin-bottom: 6px;
    }
    .product-price {
        font-size: 1rem;
    }
    .product-price .old-price {
        font-size: 0.8rem;
        margin-left: 4px;
    }
    .product-card .badge-stock,
    .product-card .badge-discount {
        font-size: 0.7rem;
        padding: 3px 6px;
    }
    .btn-add-to-cart-card {
        font-size: 0.75rem;
        padding: 5px 8px;
        width: 100%;
    }

    /* Product grid: 2 columns on mobile */
    .product-col {
        flex: 0 0 50%;
        max-width: 50%;
        padding: 0 6px;
        margin-bottom: 12px;
    }
    .row.products-grid {
        margin: 0 -6px;
    }
}

@media (max-width: 400px) {
    .product-col {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ── Product Detail Page ──────────────────────────────── */
@media (max-width: 576px) {
    .product-detail-price {
        font-size: 1.3rem !important;
    }
    .product-detail-price .old-price {
        font-size: 1rem;
    }

    .product-gallery {
        flex-direction: column-reverse;
        align-items: center;
    }
    .gallery-thumbs {
        flex-direction: row;
        overflow-x: auto;
        width: 100%;
        max-width: 100%;
    }
    .thumb-list {
        flex-direction: row;
        max-height: none;
        overflow-y: visible;
        overflow-x: auto;
    }
    .gallery-thumb {
        width: 56px;
        height: 56px;
        flex-shrink: 0;
    }
    .thumb-scroll {
        width: 28px;
        height: 56px;
    }
    .gallery-main {
        min-height: 250px;
        width: 100%;
    }
    .gallery-main img {
        max-height: 300px;
    }

    .btn-add-to-cart {
        width: 100%;
        height: 44px;
        font-size: 1rem;
    }

    .qty-group-lg .form-control {
        width: 60px;
        min-width: 60px;
        height: 44px;
        font-size: 1rem;
    }
    .qty-group-lg .btn {
        height: 44px;
        padding: 6px 12px;
        font-size: 1rem;
    }

    .add-to-cart-section .row {
        flex-direction: column;
        gap: 8px;
    }
    .add-to-cart-section .col-auto {
        width: 100%;
    }
}

/* ── Category Page ────────────────────────────────────── */
@media (max-width: 768px) {
    /* Filter sidebar: make it a collapsible card on mobile */
    .filter-sidebar {
        margin-bottom: 15px;
    }
    .filter-sidebar .card-header {
        cursor: pointer;
        user-select: none;
    }
    .filter-sidebar .card-header::after {
        content: '\f078';
        font-family: 'Font Awesome 5 Free';
        font-weight: 900;
        float: right;
        font-size: 0.8rem;
        transition: transform 0.2s;
    }
    .filter-sidebar .card-header.collapsed::after {
        transform: rotate(-90deg);
    }
    .filter-sidebar .card-body {
        display: none;
    }
    .filter-sidebar .card-body.show {
        display: block;
    }
}

@media (max-width: 576px) {
    .category-tree-list {
        font-size: 0.85rem;
    }
    .tree-level-0 { padding-left: 12px; }
    .tree-level-1 { padding-left: 24px; }
    .tree-level-2 { padding-left: 36px; }
    .tree-level-3 { padding-left: 48px; }
    .tree-level-4 { padding-left: 60px; }

    select.form-control-sm {
        width: 100%;
        margin-bottom: 8px;
    }
}

/* ── Cart / Checkout ──────────────────────────────────── */
@media (max-width: 576px) {
    .cart-item-row .card-body {
        padding: 12px;
    }
    .cart-item-img-fluid,
    .cart-item-img-placeholder {
        max-width: 70px;
        height: 60px;
    }
    .cart-item-name {
        font-size: 0.85rem;
    }
    .cart-item-price {
        font-size: 0.8rem;
    }
    .cart-item-total {
        font-size: 0.9rem;
    }
    .qty-group .form-control {
        width: 40px;
        min-width: 40px;
    }
    .qty-group .btn {
        font-size: 0.75rem;
        padding: 2px 8px;
    }

    .cart-summary .card-body {
        padding: 15px;
    }
    .cart-summary .h5 {
        font-size: 1rem;
    }
}

/* ── Checkout Page ────────────────────────────────────── */
@media (max-width: 576px) {
    .checkout-items .list-group-item {
        padding: 10px 12px;
        font-size: 0.85rem;
    }
    .checkout-step-label {
        font-size: 0.8rem;
    }
}

/* ── Footer ───────────────────────────────────────────── */
@media (max-width: 576px) {
    .footer-columns {
        grid-template-columns: 1fr;
        gap: 24px;
        padding: 24px 0 16px;
    }
    .footer-newsletter {
        padding: 28px 0 20px;
    }
    .newsletter-title {
        font-size: 18px;
    }
    .footer-bottom-inner {
        flex-direction: column;
        text-align: center;
        gap: 4px;
        font-size: 12px;
    }
    .footer-sep {
        display: none;
    }
    .footer-col-title {
        font-size: 14px;
        margin-bottom: 12px;
    }
    .footer-links li {
        margin-bottom: 6px;
    }
    .footer-contact-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ── Touch Optimizations ──────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .product-card:hover {
        transform: none !important;
        box-shadow: none !important;
    }
    .category-card:hover {
        box-shadow: none !important;
    }
    .footer-links a:hover {
        padding-left: 0 !important;
    }
    .footer-links a:active {
        padding-left: 4px;
    }
    .dropdown-hover:hover > .dropdown-menu {
        display: none !important;
    }

    /* Bigger touch targets (Apple HIG: min 44px) */
    .nav-link,
    .dropdown-item,
    .btn-sm,
    .page-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    .footer-links a {
        min-height: 36px;
        display: flex;
        align-items: center;
    }
}

/* ── Extra Small Devices (320px, iPhone SE) ───────────── */
@media (max-width: 360px) {
    .hero-slider .slider-img {
        height: 180px !important;
    }
    .product-card .card-title {
        font-size: 0.8rem;
    }
    .product-price {
        font-size: 0.9rem;
    }
    .navbar-brand {
        font-size: 0.9rem;
    }
    .navbar-brand i {
        font-size: 0.85rem;
    }
}
