/* ==========================================================================
   AL MARVA MARKETPLACE — Frontend Styles
   Covers: Store button, Product grid, Sidebar filters, Product page layout,
           Mobile Uzum-style store UI
   ========================================================================== */

/* ==========================================================================
   GLOBAL: Portrait 3:4 Aspect Ratio for ALL Product Images
   Forces all product card and gallery images to display in portrait (3:4).
   ========================================================================== */

/* --- All product loop/archive images (shop, category, tag, search, store) --- */
.woocommerce ul.products li.product img,
.woocommerce ul.products li.product a > img,
.woocommerce ul.products li.product .attachment-woocommerce_thumbnail,
.woocommerce-page ul.products li.product img,
.wc-block-grid__product-image img,
ul.products li.product img {
    aspect-ratio: 3 / 4 !important;
    width: 100% !important;
    height: auto !important;
    object-fit: cover !important;
    display: block !important;
}

/* --- Override theme/plugin CSS forcing square (1:1) thumbnails --- */
body .woocommerce ul.products li.product .woocommerce-LoopProduct-link img,
body .woocommerce ul.products li.product .woocommerce-loop-product-link img,
body.almarva-product-archive ul.products li.product img,
body.almarva-store-page ul.products li.product img {
    aspect-ratio: 3 / 4 !important;
    object-fit: cover !important;
    height: auto !important;
}

/* --- Kill padding-top: 100% (square hack) on image wrappers --- */
.woocommerce ul.products li.product .woocommerce-loop-product-link,
.woocommerce ul.products li.product .woocommerce-LoopProduct-link,
.woocommerce ul.products li.product a:first-child {
    padding-top: 0 !important;
    height: auto !important;
}

/* Ensure no parent forces aspect-ratio: 1/1 */
.woocommerce ul.products li.product a img,
.woocommerce ul.products li.product .wp-post-image {
    aspect-ratio: 3 / 4 !important;
}

/* --- Single product: main gallery image (preserve natural ratio, no forced portrait) --- */
.woocommerce div.product div.images img,
.woocommerce div.product div.images .woocommerce-product-gallery__image img,
.woocommerce div.product div.images .wp-post-image {
    width: 100% !important;
    height: auto !important;
    display: block !important;
    object-fit: contain !important;
}

/* --- Single product: gallery thumbnails --- */
.woocommerce div.product div.images .flex-control-thumbs li img {
    aspect-ratio: 3 / 4 !important;
    object-fit: cover !important;
    width: 100% !important;
    height: auto !important;
}

/* ==========================================================================
   PHASE 1: Store/Brand Button (Cards + Single Product)
   ========================================================================== */

/* --- Store button in product loop cards --- */
.almarva-store-button {
    display: inline-block;
    font-size: 12px;
    line-height: 1.3;
    padding: 3px 10px;
    margin-top: 6px;
    border-radius: 20px;
    background: #f5f5f5;
    color: #00A859;
    border: 1px solid #cce8d9;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.almarva-store-button:hover {
    background: #00A859;
    color: #fff;
    border-color: #00A859;
    text-decoration: none;
}

.almarva-store-button--loop {
    display: block;
    text-align: center;
    margin: 6px auto 0;
    font-size: 11px;
    max-width: 90%;
}

/* --- Store button on single product page --- */
.almarva-store-meta {
    margin: 10px 0 5px;
    font-size: 14px;
}

.almarva-store-label {
    color: #666;
    font-weight: 600;
}

.almarva-store-button--single {
    font-size: 14px;
    padding: 5px 16px;
    font-weight: 600;
}

/* ==========================================================================
   PHASE 2: Store Page Product Grid (Responsive)
   ========================================================================== */

/* Desktop layout: sidebar + product grid */
.almarva-store-layout {
    display: flex;
    gap: 30px;
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 15px;
    align-items: flex-start;
}

.almarva-store-sidebar {
    width: 260px;
    min-width: 260px;
    flex-shrink: 0;
}

.almarva-store-main {
    flex: 1;
    min-width: 0;
}

/* Product grid responsive */
.almarva-store-page ul.products,
.almarva-store-main ul.products {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.almarva-store-page ul.products li.product,
.almarva-store-main ul.products li.product {
    width: 100% !important;
    margin: 0 !important;
    padding: 0;
    float: none !important;
}

/* Product card styling */
.almarva-store-page ul.products li.product,
.almarva-store-main ul.products li.product {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}

.almarva-store-page ul.products li.product:hover,
.almarva-store-main ul.products li.product:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* Product images: portrait ratio */
.almarva-store-page ul.products li.product a img,
.almarva-store-main ul.products li.product a img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    display: block;
    border-radius: 0;
}

/* Product title in cards */
.almarva-store-page ul.products li.product .woocommerce-loop-product__title,
.almarva-store-main ul.products li.product .woocommerce-loop-product__title {
    font-size: 13px;
    line-height: 1.4;
    padding: 8px 10px 0;
    margin: 0;
    font-weight: 500;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Price in cards */
.almarva-store-page ul.products li.product .price,
.almarva-store-main ul.products li.product .price {
    padding: 4px 10px;
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
}

/* Add to cart button in grid */
.almarva-store-page ul.products li.product .button,
.almarva-store-main ul.products li.product .button {
    margin: auto 10px 10px;
    border-radius: 8px;
    font-size: 12px;
    padding: 6px 12px;
    text-align: center;
}

/* Also style product archive grids similarly */
.almarva-product-archive ul.products {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.almarva-product-archive ul.products li.product {
    width: 100% !important;
    margin: 0 !important;
    float: none !important;
}

.almarva-product-archive ul.products li.product a img {
    aspect-ratio: 3 / 4;
    object-fit: cover;
    width: 100%;
}

/* ==========================================================================
   PHASE 3: Sidebar Filters (Desktop)
   ========================================================================== */

.almarva-filter-widget {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.almarva-filter-widget h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
    color: #1a1a1a;
}

/* Price range filter */
.almarva-price-filter {
    display: flex;
    gap: 10px;
    align-items: center;
}

.almarva-price-filter input[type="number"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
}

.almarva-price-filter input[type="number"]::-webkit-outer-spin-button,
.almarva-price-filter input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.almarva-price-filter input[type="number"]:focus {
    border-color: #00A859;
}

.almarva-price-separator {
    color: #999;
    font-weight: 600;
}

.almarva-filter-apply {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    background: #00A859;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.almarva-filter-apply:hover {
    background: #00914D;
}

.almarva-filter-reset {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    background: transparent;
    color: #999;
    border: 1px solid #eee;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
}

.almarva-filter-reset:hover {
    color: #333;
    border-color: #ccc;
}

/* Category filter checkboxes */
.almarva-cat-filter-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

.almarva-cat-filter-list li {
    margin-bottom: 8px;
}

.almarva-cat-filter-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #444;
    cursor: pointer;
    transition: color 0.2s;
}

.almarva-cat-filter-list label:hover {
    color: #00A859;
}

.almarva-cat-filter-list input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #00A859;
    cursor: pointer;
}

.almarva-cat-filter-list .cat-count {
    color: #999;
    font-size: 12px;
    margin-left: auto;
}

/* Sort dropdown */
.almarva-sort-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.almarva-sort-bar h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: #1a1a1a;
}

.almarva-sort-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    background: #fff;
}

/* ==========================================================================
   PHASE 4: Single Product Page Layout (Nivea-style)
   ========================================================================== */

/* Rating summary under title */
.almarva-rating-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0 10px;
    font-size: 15px;
}

.almarva-rating-empty {
    opacity: 0.6;
}

.almarva-stars {
    color: #ffb900;
    font-size: 18px;
    letter-spacing: 1px;
}

.almarva-rating-number {
    color: #1a1a1a;
    font-size: 15px;
}

.almarva-rating-count {
    color: #888;
    font-size: 13px;
}

/* Description section (replaces tabs) */
.almarva-description-section,
.almarva-reviews-section {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 15px;
}

.almarva-section-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
    color: #1a1a1a;
}

.almarva-description-content {
    font-size: 15px;
    line-height: 1.7;
    color: #444;
}

.almarva-description-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Hide default WooCommerce tabs if they somehow still render */
.almarva-single-product .woocommerce-tabs {
    display: none !important;
}

/* Reviews section styling */
.almarva-reviews-section .comment-form {
    margin-top: 20px;
}

.almarva-reviews-section .commentlist {
    list-style: none;
    padding: 0;
}

.almarva-reviews-section .commentlist .comment {
    padding: 15px 0;
    border-bottom: 1px solid #f0f0f0;
}

/* ==========================================================================
   PHASE 5: Mobile Store UI (Uzum-style)
   ========================================================================== */

/* --- Store Header (enhanced) --- */
.almarva-store-wrapper .store-header {
    position: relative;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

/* Mobile Store Header Enhancements */
.almarva-store-stats {
    display: flex;
    gap: 20px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.almarva-store-stat {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
}

.almarva-store-stat strong {
    display: block;
    font-size: 16px;
    color: #fff;
}

/* Store Tabs (Online Chat + About Store) */
.almarva-store-tabs {
    display: none; /* Hidden on desktop, shown on mobile */
    background: #fff;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    z-index: 100;
}

.almarva-store-tabs-inner {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
}

.almarva-store-tab {
    flex: 1;
    padding: 14px 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    cursor: pointer;
}

.almarva-store-tab:hover,
.almarva-store-tab.active {
    color: #00A859;
    border-bottom-color: #00A859;
}

.almarva-store-tab svg,
.almarva-store-tab .dashicons {
    vertical-align: middle;
    margin-right: 4px;
}

/* About store section */
.almarva-about-store {
    display: none;
    background: #fff;
    padding: 20px 15px;
    margin: 0 auto;
    max-width: 1200px;
}

.almarva-about-store.active {
    display: block;
}

.almarva-about-store p {
    font-size: 15px;
    line-height: 1.7;
    color: #444;
}

/* Pagination */
.almarva-pagination {
    margin-top: 40px;
    text-align: center;
    padding: 20px 0;
}

.almarva-pagination .page-numbers {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #ddd;
    margin: 0 3px;
    text-decoration: none;
    color: #333;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.almarva-pagination .page-numbers:hover {
    border-color: #00A859;
    color: #00A859;
}

.almarva-pagination .page-numbers.current {
    background: #00A859;
    color: #fff;
    border-color: #00A859;
}

/* ==========================================================================
   RESPONSIVE: Tablet (max-width: 992px)
   ========================================================================== */
@media (max-width: 992px) {
    /* Store layout: stack sidebar above products */
    .almarva-store-layout {
        flex-direction: column;
    }

    .almarva-store-sidebar {
        width: 100%;
        min-width: 0;
        display: flex;
        flex-wrap: wrap;
        gap: 15px;
    }

    .almarva-filter-widget {
        flex: 1;
        min-width: 200px;
    }

    /* 3 columns on tablet */
    .almarva-store-page ul.products,
    .almarva-store-main ul.products,
    .almarva-product-archive ul.products {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 15px;
    }
}

/* ==========================================================================
   RESPONSIVE: Mobile (max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {
    /* Show mobile store tabs */
    .almarva-store-tabs {
        display: block;
    }

    /* Hide desktop sidebar on mobile */
    .almarva-store-sidebar {
        display: none;
    }

    /* Stack layout */
    .almarva-store-layout {
        flex-direction: column;
        gap: 0;
        padding: 0 10px;
    }

    /* 2 columns mobile */
    .almarva-store-page ul.products,
    .almarva-store-main ul.products,
    .almarva-product-archive ul.products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }

    /* Store header mobile adjustments */
    .almarva-store-wrapper .store-header {
        height: auto;
        min-height: 200px;
        padding: 20px 15px;
    }

    .almarva-store-wrapper .store-info-container {
        flex-direction: column;
        text-align: center;
        align-items: center;
        gap: 12px;
    }

    .almarva-store-wrapper .store-title {
        font-size: 22px;
    }

    .almarva-store-wrapper .store-avatar img {
        width: 80px !important;
        height: 80px !important;
    }

    .almarva-store-stats {
        justify-content: center;
    }

    /* Product card mobile tweaks */
    .almarva-store-page ul.products li.product .woocommerce-loop-product__title,
    .almarva-store-main ul.products li.product .woocommerce-loop-product__title {
        font-size: 12px;
        padding: 6px 8px 0;
    }

    .almarva-store-page ul.products li.product .price,
    .almarva-store-main ul.products li.product .price {
        font-size: 13px;
        padding: 4px 8px;
    }

    .almarva-store-button--loop {
        font-size: 10px;
        padding: 2px 8px;
    }

    /* Sort bar mobile */
    .almarva-sort-bar {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .almarva-sort-bar h2 {
        font-size: 18px;
    }

    /* Single product sections */
    .almarva-description-section,
    .almarva-reviews-section {
        padding: 0 10px;
        margin: 20px auto;
    }

    .almarva-section-title {
        font-size: 17px;
    }

    /* Mobile filter toggle button */
    .almarva-mobile-filter-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        width: 100%;
        padding: 12px;
        margin-bottom: 15px;
        background: #fff;
        border: 1px solid #ddd;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 600;
        color: #333;
        cursor: pointer;
    }

    .almarva-mobile-filter-toggle:hover {
        border-color: #00A859;
        color: #00A859;
    }

    /* Show sidebar as overlay when toggled */
    .almarva-store-sidebar.mobile-open {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9999;
        background: #fff;
        padding: 20px;
        overflow-y: auto;
        animation: slideUp 0.3s ease;
    }

    .almarva-mobile-filter-close {
        display: none;
        width: 100%;
        padding: 12px;
        margin-bottom: 15px;
        background: #00A859;
        color: #fff;
        border: none;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
    }

    .almarva-store-sidebar.mobile-open .almarva-mobile-filter-close {
        display: block;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
}

/* ==========================================================================
   RESPONSIVE: Small Mobile (max-width: 480px)
   ========================================================================== */
@media (max-width: 480px) {
    .almarva-store-page ul.products,
    .almarva-store-main ul.products,
    .almarva-product-archive ul.products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }

    .almarva-store-page ul.products li.product .woocommerce-loop-product__title,
    .almarva-store-main ul.products li.product .woocommerce-loop-product__title {
        font-size: 11px;
    }

    .almarva-store-page ul.products li.product .price,
    .almarva-store-main ul.products li.product .price {
        font-size: 12px;
    }
}

/* ==========================================================================
   DESKTOP: Large screens (min-width: 1200px+)
   ========================================================================== */
@media (min-width: 769px) {
    /* Hide mobile-only elements on desktop */
    .almarva-store-tabs {
        display: none;
    }

    .almarva-mobile-filter-toggle {
        display: none;
    }

    .almarva-mobile-filter-close {
        display: none;
    }
}
