/*
 * BookzCart — Responsive Breakpoints
 * Mobile-first: 320px → 480px → 768px → 1024px → 1200px
 *
 * @package BookzCart
 */

/* ============================================
   MOBILE (< 480px)
   ============================================ */
@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.75rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .hero-search {
        flex-direction: column;
    }

    .hero-search .search-btn {
        width: 100%;
    }

    .book-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-2);
    }

    .book-card {
        padding-top: 0;
        align-items: stretch;
    }

    .book-cover-wrap {
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        overflow: hidden;
    }

    .book-cover {
        width: 100%;
        height: auto;
        aspect-ratio: 3 / 4;
        border-radius: 0;
    }

    .book-cover img {
        border-radius: 0;
    }

    /* Zoom btn always visible on mobile (no hover on touch) */
    .book-zoom-btn {
        opacity: 1;
        transform: scale(1);
    }

    .book-content {
        padding: var(--space-1) var(--space-2) var(--space-2);
    }

    .book-title {
        font-size: 0.8125rem;
    }

    .book-author-name {
        font-size: 0.6875rem;
    }

    .book-price {
        font-size: 1rem;
    }

    .book-old-price {
        font-size: 0.75rem;
    }

    .book-card .btn-add-cart {
        padding: 7px;
        font-size: 0.6875rem;
    }

    .book-badge--category,
    .book-badge--sale,
    .book-badge {
        font-size: 0.5625rem;
        padding: 2px 6px;
    }

    .btn-wishlist {
        width: 36px;
        height: 36px;
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .product-single {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }

    .product-gallery {
        position: static;
    }

    .product-info h1 {
        font-size: 1.5rem;
    }

    /* Sticky bar mobile compact — keep old price visible for sale context */
    .sticky-bar-price .book-old-price {
        font-size: 0.75rem;
    }

    .sticky-bar-price .book-price {
        font-size: 1.25rem;
    }

    .sticky-bar-price .action-discount-badge {
        font-size: 0.625rem;
        padding: 2px 7px;
    }

    .sticky-bar-cart {
        padding: 10px 16px;
        font-size: 0.8125rem;
    }

    /* Sticky bar sits above mobile bottom nav */
    .single-product .product-sticky-bar.is-visible {
        bottom: 56px;
    }

    /* Push toast above sticky bar + bottom nav on mobile */
    .product-sticky-bar.is-visible~.cart-toast.is-visible {
        bottom: 130px;
    }

    .btn-icon {
        width: 40px;
        height: 40px;
    }

    .search-bar-wrap {
        flex-direction: column;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .footer-bottom {
        flex-direction: column;
        gap: var(--space-2);
        text-align: center;
    }

    .container {
        padding: 0 var(--space-2);
    }

    .cart-toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        max-width: none;
    }

    /* Taxonomy directory mobile */
    .az-jump-letter {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .az-term-grid {
        grid-template-columns: 1fr;
    }

    .az-section-letter {
        font-size: 1.5rem;
    }

    /* My Account mobile */
    .myaccount-layout {
        grid-template-columns: 1fr;
        gap: var(--space-3);
        padding-bottom: 80px;
    }

    .myaccount-nav {
        display: none;
    }

    .myaccount-inline-tabs {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 0 var(--space-2);
        margin-bottom: var(--space-3);
        scrollbar-width: none;
    }

    .myaccount-inline-tabs::-webkit-scrollbar {
        display: none;
    }

    .myaccount-inline-tab {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 8px 16px;
        border-radius: var(--radius-pill);
        background: white;
        border: 1px solid #e0e0e0;
        font-size: 0.8125rem;
        font-weight: 500;
        color: var(--deep-indigo);
        text-decoration: none;
        white-space: nowrap;
        transition: all var(--transition-fast);
        flex-shrink: 0;
    }

    .myaccount-inline-tab.is-active {
        background: var(--palm-leaf);
        color: white;
        border-color: var(--palm-leaf);
    }

    .myaccount-inline-tab.is-active .bz-icon {
        color: white;
    }

    .myaccount-inline-tab .bz-icon {
        color: #999;
        flex-shrink: 0;
    }

    .dashboard-stats {
        grid-template-columns: 1fr !important;
    }

    .dashboard-action-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-welcome {
        padding: var(--space-4);
    }

    .dashboard-welcome h2 {
        font-size: 1.25rem;
    }

    .myaccount-content .woocommerce-Addresses {
        grid-template-columns: 1fr;
    }

    /* Search page mobile */
    .search-page-wrap .search-bar-wrap {
        flex-direction: column;
    }

    .search-page-wrap .search-btn {
        width: 100%;
        justify-content: center;
    }

    /* Mobile bottom nav — visible on all pages including single product */

    .mobile-bottom-nav {
        display: flex;
        justify-content: space-between;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        box-sizing: border-box;
        background: white;
        border-top: 1px solid #f0f0f0;
        z-index: 100;
        padding: 6px 12px;
        padding-bottom: max(6px, env(safe-area-inset-bottom));
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    }

    .mobile-bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 4px 0;
        font-size: 0.5625rem;
        font-weight: 500;
        color: #999;
        text-decoration: none;
        text-align: center;
        transition: color var(--transition-fast);
        background: none;
        border: none;
        cursor: pointer;
        position: relative;
    }

    .mobile-bottom-nav-item.is-active {
        color: var(--palm-leaf);
        font-weight: 700;
    }

    .mobile-bottom-nav-item .bz-icon {
        flex-shrink: 0;
    }

    .mobile-bottom-cart-count {
        position: absolute;
        top: 0;
        right: 50%;
        transform: translateX(14px);
    }

    /* Hide header action icons on mobile (we have bottom nav) */
    .nav-actions .nav-action-btn:not(.nav-toggle):not(#nav-toggle) {
        display: none;
    }

    .nav-actions #nav-toggle,
    .nav-actions .nav-toggle {
        display: flex;
    }

    /* Ensure footer padding for bottom nav */
    body {
        padding-bottom: 60px;
    }

    .single-product body,
    body.single-product {
        padding-bottom: 60px;
    }

    .back-to-top {
        bottom: 70px;
    }

    .cart-toast {
        bottom: 70px;
    }

    /* ============================================
       CART TABLE — MOBILE RESPONSIVE
       ============================================ */
    .woocommerce-cart table.shop_table {
        font-size: 0.8125rem;
    }

    /* Reduce product image size in cart */
    .woocommerce-cart table.shop_table .product-thumbnail img {
        width: 50px !important;
        height: auto !important;
        max-width: 50px;
    }

    /* Trim product names with ellipsis */
    .woocommerce-cart table.shop_table td.product-name {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Completely hide Subtotal column */
    .woocommerce-cart table.shop_table th.product-subtotal,
    .woocommerce-cart table.shop_table td.product-subtotal {
        display: none !important;
    }

    /* Hide product title repetition in quantity column */
    .woocommerce-cart table.shop_table td.product-quantity::before {
        display: none !important;
    }

    /* Reduce cart table padding */
    .woocommerce-cart table.shop_table th,
    .woocommerce-cart table.shop_table td {
        padding: 8px 6px;
    }

    /* Quantity input smaller on mobile */
    .woocommerce-cart .quantity .qty {
        width: 50px;
        padding: 6px 4px;
        font-size: 0.8125rem;
    }

    /* Cart actions row */
    .woocommerce-cart table.shop_table .actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .woocommerce-cart table.shop_table .actions .coupon {
        display: flex;
        gap: 6px;
        flex: 1;
        min-width: 0;
    }

    .woocommerce-cart table.shop_table .actions .coupon #coupon_code {
        flex: 1;
        min-width: 0;
        font-size: 0.8125rem;
        padding: 8px;
    }
}

/* ============================================
   TABLET PORTRAIT (< 768px)
   ============================================ */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }

    .nav-toggle {
        display: flex;
    }

    .hero h1 {
        font-size: 1.875rem;
    }

    .hero {
        padding: var(--space-5) var(--space-3);
    }

    .book-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-2);
    }

    .product-single {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .product-gallery {
        position: static;
    }

    .category-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }

    .filter-tags {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: var(--space-1);
        -webkit-overflow-scrolling: touch;
    }

    .filter-tag {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .section {
        padding: var(--space-4) 0;
    }

    .section-header h2 {
        font-size: 1.5rem;
    }

    /* My Account tablet */
    .myaccount-layout {
        grid-template-columns: 1fr;
        gap: var(--space-3);
        padding-bottom: 80px;
    }

    .myaccount-nav {
        display: none;
    }

    .myaccount-inline-tabs {
        display: flex;
    }

    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .myaccount-content .woocommerce-Addresses {
        grid-template-columns: 1fr;
    }

    /* Mobile bottom nav — visible on all pages including single product (tablet) */

    .mobile-bottom-nav {
        display: flex;
        justify-content: space-between;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        box-sizing: border-box;
        background: white;
        border-top: 1px solid #f0f0f0;
        z-index: 100;
        padding: 6px 12px;
        padding-bottom: max(6px, env(safe-area-inset-bottom));
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    }

    .mobile-bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 4px 0;
        font-size: 0.625rem;
        font-weight: 500;
        color: #999;
        text-decoration: none;
        text-align: center;
        transition: color var(--transition-fast);
        background: none;
        border: none;
        cursor: pointer;
        position: relative;
    }

    .mobile-bottom-nav-item.is-active {
        color: var(--palm-leaf);
        font-weight: 700;
    }

    .mobile-bottom-nav-item .bz-icon {
        flex-shrink: 0;
    }

    .mobile-bottom-cart-count {
        position: absolute;
        top: 0;
        right: 50%;
        transform: translateX(14px);
    }

    /* Hide header action icons on tablet/mobile (bottom nav replaces them) */
    .nav-actions .nav-action-btn:not(.nav-toggle):not(#nav-toggle) {
        display: none;
    }

    .nav-actions #nav-toggle,
    .nav-actions .nav-toggle {
        display: flex;
    }

    /* Footer padding for bottom nav */
    body {
        padding-bottom: 60px;
    }

    /* Sticky bar sits above mobile bottom nav on tablet */
    .single-product .product-sticky-bar.is-visible {
        bottom: 56px;
    }

    .back-to-top {
        bottom: 70px;
    }

    .cart-toast {
        bottom: 70px;
    }

    /* ============================================
       CART TABLE — TABLET RESPONSIVE
       ============================================ */
    .woocommerce-cart table.shop_table .product-thumbnail img {
        width: 60px !important;
        height: auto !important;
        max-width: 60px;
    }

    .woocommerce-cart table.shop_table td.product-name {
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Completely hide Subtotal column on tablet */
    .woocommerce-cart table.shop_table th.product-subtotal,
    .woocommerce-cart table.shop_table td.product-subtotal {
        display: none !important;
    }

    /* Hide product title in quantity column */
    .woocommerce-cart table.shop_table td.product-quantity::before {
        display: none !important;
    }
}

/* ============================================
   TABLET LANDSCAPE (< 1024px)
   ============================================ */
@media (max-width: 1024px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-4);
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .book-cover {
        height: 220px;
    }

    /* Tablet: single-col layout */
    .product-single {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .product-gallery {
        position: static;
    }
}

/* ============================================
   DESKTOP SMALL (< 1200px)
   ============================================ */
@media (max-width: 1200px) {
    .container {
        padding: 0 var(--space-3);
    }
}

/* ============================================
   DESKTOP LARGE (> 1200px)
   ============================================ */
@media (min-width: 1201px) {
    .book-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ============================================
   FILTER BUTTON (visible on all breakpoints)
   ============================================ */
.sidebar-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-family: var(--font-tamil);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--deep-indigo);
    font-size: 0.9375rem;
    margin-bottom: 0;
}

.sidebar-filter-btn:hover {
    border-color: var(--palm-leaf);
    color: var(--palm-leaf);
}

.sidebar-filter-btn .bz-icon {
    color: var(--marigold);
}

/* ============================================
   SIDEBAR HEADER & CLOSE (always visible)
   ============================================ */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) 0;
    margin-bottom: var(--space-2);
    border-bottom: 2px solid var(--marigold);
    position: sticky;
    top: 0;
    background: white;
    z-index: 2;
}

.sidebar-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--deep-indigo);
    margin: 0;
}

.sidebar-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-round);
    background: var(--rice-white);
    color: var(--deep-indigo);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.sidebar-close:hover {
    background: var(--error);
    color: white;
}

/* ============================================
   SIDEBAR OVERLAY
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.sidebar-overlay.is-active {
    display: block;
    opacity: 1;
}

/* ============================================
   RESPONSIVE SIDEBAR WIDTHS
   ============================================ */
@media (max-width: 1024px) {
    .shop-sidebar {
        width: 380px;
    }
}

@media (max-width: 768px) {
    .shop-sidebar {
        width: 320px;
    }
}