/* ==========================================================================
   Tribes Market - Homepage & Catalog Grid Styles
   ========================================================================== */

/* Header overrides removed — common.css is the Single Source of Truth for .header-inner and .brand-logo */

/* Search bar header element */
.search-wrapper {
    flex: 0 1 580px;
    position: relative;
    display: flex;
    align-items: stretch;
    background-color: var(--bg-surface-subtle);
    border-radius: 9999px;
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
    overflow: hidden;
    margin: 0;
}

.search-wrapper:focus-within {
    background-color: var(--bg-white);
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.search-input {
    flex: 1;
    min-width: 0;
    background-color: transparent;
    border: none;
    padding: 10px 16px;
    font-size: var(--font-body);
    font-family: inherit;
    color: var(--text-main);
    outline: none;
}

.search-input::placeholder {
    color: var(--text-subtle);
    font-size: var(--font-small);
}

.search-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    background: var(--brand-ochre);
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    padding: 0;
    flex-shrink: 0;
}

.search-submit-btn:hover {
    background: #92400e;
}

.search-submit-btn:active {
    background: #78350f;
}

.search-submit-btn svg {
    width: 17px;
    height: 17px;
    stroke: currentColor;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    white-space: nowrap;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-small);
    font-weight: 600;
    transition: color 0.15s;
}

.nav-link:hover {
    color: var(--brand-ochre);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.15s ease;
}

.icon-btn:hover {
    color: var(--text-main);
    background: var(--bg-surface-subtle);
}

.btn-seller-badge {
    background-color: var(--brand-tint-bg);
    color: var(--brand-tint-text);
    border: 1px solid var(--brand-tint-border);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: var(--font-small);
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}

.btn-seller-badge:hover {
    background-color: var(--brand-tint-border);
}

/* Full-Width Shop Layout with Slide-Out Filter Drawer */
.main-container {
    max-width: 1280px;
    width: 100%;
    margin: 16px auto 40px auto;
    padding: 0 clamp(12px, 3vw, 28px);
    box-sizing: border-box;
    display: block;
    flex-grow: 1;
    min-height: calc(100vh - 180px);
}

.catalog-content {
    min-width: 0;
    width: 100%;
}

/* Slide-Out Filter Drawer */
.filter-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.filter-drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.filter-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    max-width: 85vw;
    background: var(--bg-white);
    z-index: 1000;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.filter-drawer.open {
    transform: translateX(0);
}

.filter-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-page);
}

.filter-drawer-title {
    font-family: var(--font-sans);
    font-size: var(--font-heading-card);
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
}

.filter-drawer-close {
    background: transparent;
    border: none;
    font-size: var(--font-heading-section);
    color: var(--text-muted);
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    line-height: 1;
    border-radius: 6px;
    transition: color 0.15s ease;
}

.filter-drawer-close:hover {
    color: var(--text-main);
}

.filter-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    overscroll-behavior: contain;
}

.filter-group {
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 20px;
}

.filter-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--font-small);
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 14px;
    cursor: pointer;
    user-select: none;
}

.filter-options-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--font-small);
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.filter-checkbox-label:hover {
    color: var(--text-main);
}

.filter-checkbox-label input[type="radio"],
.filter-checkbox-label input[type="checkbox"] {
    accent-color: var(--brand-ochre);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

/* Catalog Controls & Grid */
.catalog-header {
    position: sticky;
    top: var(--sticky-header-height, 64px);
    z-index: 40;
    background-color: var(--bg-page);
    padding: 10px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

/* Seamless upward seal to permanently close any gap between toolbar and navbar */
.catalog-header::before {
    content: '';
    position: absolute;
    top: -24px;
    left: -24px;
    right: -24px;
    height: 24px;
    background-color: var(--bg-page);
    pointer-events: none;
}

.catalog-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-filter-drawer {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 7px 14px;
    font-size: var(--font-small);
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.btn-filter-drawer:hover {
    background: var(--brand-tint-bg);
    border-color: var(--brand-gold);
    color: var(--brand-ochre);
}

.results-count {
    font-size: var(--font-small);
    color: var(--text-muted);
    font-weight: 500;
}

.catalog-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 12px 0;
}

.catalog-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-group-pill {
    background-color: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 0 8px 0 10px;
    transition: border-color 0.15s ease;
}

.control-group-pill:hover,
.control-group-pill:focus-within {
    border-color: var(--border-strong);
}

.control-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

.control-select {
    background-color: transparent;
    border: none;
    padding: 7px 4px;
    font-size: var(--font-small);
    font-weight: 600;
    color: var(--text-main);
    outline: none;
    cursor: pointer;
    font-family: inherit;
    max-width: 170px;
    color-scheme: inherit;
}

.control-select option,
.control-select optgroup {
    background-color: var(--bg-white);
    color: var(--text-main);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: clamp(8px, 1.4vw, 16px);
}

.product-card {
    background-color: var(--bg-white);
    border-radius: var(--radius-card);
    border: 1px solid var(--border-light);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.08);
    border-color: var(--border-strong);
}

.product-thumb-link {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: var(--bg-surface-subtle);
    overflow: hidden;
    position: relative;
    text-decoration: none;
}

.product-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover .product-thumb-img {
    transform: scale(1.04);
}

.product-card-body {
    padding: clamp(6px, 1.2vw, 10px);
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: space-between;
}

.product-card-title {
    font-size: clamp(0.76rem, 1.1vw, 0.88rem);
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
    line-height: 1.3;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
}

.product-card-title:hover {
    color: var(--brand-ochre);
}

.product-card-store {
    font-size: clamp(0.65rem, 0.9vw, 0.74rem);
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 6px;
    gap: 6px;
}

.product-card-price {
    font-size: clamp(0.86rem, 1.3vw, 1.02rem);
    font-weight: 800;
    color: var(--brand-ochre);
    letter-spacing: -0.01em;
}

.cart-action-btn {
    background-color: var(--brand-tint-bg);
    color: var(--brand-brown);
    border: 1px solid var(--brand-tint-border);
    width: clamp(28px, 3.2vw, 32px);
    height: clamp(28px, 3.2vw, 32px);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.cart-action-btn:hover {
    background-color: var(--brand-ochre);
    color: white;
    border-color: var(--brand-ochre);
    transform: scale(1.05);
}

.whatsapp-action-btn {
    background-color: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.whatsapp-action-btn:hover {
    background-color: #22c55e;
    color: #ffffff;
    border-color: #16a34a;
    transform: scale(1.05);
}

.wishlist-heart-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-overlay-btn);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
    color: var(--text-muted);
    padding: 0;
}

.wishlist-heart-btn:hover {
    transform: scale(1.12);
    background: var(--bg-white);
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.2);
}

.wishlist-heart-btn.active {
    color: var(--accent-red);
    background: var(--bg-white);
}

.wishlist-heart-btn svg {
    width: 15px;
    height: 15px;
    transition: fill 0.15s ease, stroke 0.15s ease;
}

.product-micro-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: clamp(0.58rem, 0.8vw, 0.65rem);
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.badge-featured {
    background: var(--brand-tint-bg);
    color: var(--brand-tint-text);
    border: 1px solid var(--brand-tint-border);
}

.badge-discount {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}

.verified-store-badge {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-left: 4px;
    color: var(--info-text);
    flex-shrink: 0;
}

/* Featured Products First Row (Compact horizontal sliding strip) */
.featured-row-section {
    width: 100%;
    margin: 0 0 12px 0;
    padding: 0 0 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.featured-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

#featuredCarouselTrack {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: clamp(8px, 1.4vw, 14px);
    padding-bottom: 4px;
    scrollbar-width: none;
}

#featuredCarouselTrack::-webkit-scrollbar {
    display: none;
}

#featuredCarouselTrack .product-card {
    flex: 0 0 clamp(160px, 22vw, 220px);
    scroll-snap-align: start;
}

.featured-track-wrap {
    position: relative;
}

.featured-scroll-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-overlay-btn, rgba(255, 255, 255, 0.94));
    border: 1px solid var(--border-strong);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.16);
    z-index: 5;
    transition: opacity 0.2s ease, transform 0.15s ease, background-color 0.15s ease;
}

.featured-scroll-btn:hover,
.featured-scroll-btn:focus-visible {
    background: var(--brand-ochre);
    border-color: var(--brand-ochre);
    color: #ffffff;
}

.featured-scroll-btn.hidden {
    opacity: 0;
    pointer-events: none;
}

.featured-row-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-small);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--brand-ochre);
}

.featured-row-section .product-card {
    border: 1.5px solid var(--brand-tint-border);
}

@media (max-width: 1100px) {
    .product-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 859px) {
    .main-container { padding: 0 clamp(10px, 2.5vw, 16px); margin: 12px auto 40px auto; }
    .product-grid { grid-template-columns: repeat(3, 1fr); gap: clamp(8px, 1.4vw, 14px); }

    .catalog-header {
        position: sticky;
        top: var(--sticky-header-height, 108px);
        padding: 8px 0;
        margin-bottom: 8px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .catalog-header-left {
        display: contents;
    }
    .btn-filter-drawer {
        order: 1;
        padding: 6px 10px;
        font-size: var(--font-small);
    }
    .catalog-controls {
        order: 2;
        margin-left: auto;
        flex-wrap: nowrap;
        gap: 6px;
    }
    .control-group-pill {
        padding: 0 4px 0 7px;
    }
    .control-select {
        padding: 6px 2px;
        font-size: var(--font-xs);
        max-width: 120px;
    }
    .results-count {
        font-size: var(--font-xs);
    }
}

@media (max-width: 579px) {
    .main-container { padding: 0 clamp(8px, 2.5vw, 12px); margin: 8px auto 30px auto; }
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: clamp(8px, 2vw, 12px); }
    .product-card {
        border-radius: 10px;
    }
    .product-card-body {
        padding: 7px 8px;
    }
    .product-card-title {
        font-size: 0.74rem;
        font-weight: 700;
        line-height: 1.25;
        min-height: 2.5em;
        margin-bottom: 3px;
    }
    .product-card-store {
        font-size: 0.65rem;
        margin-bottom: 3px;
    }
    .product-card-bottom {
        padding-top: 4px;
        gap: 4px;
    }
    .product-card-price {
        font-size: 0.82rem;
        line-height: 1.2;
    }
    .cart-action-btn {
        width: 28px;
        height: 28px;
        border-radius: 6px;
    }
    .cart-action-btn svg {
        width: 15px;
        height: 15px;
    }
    .btn-filter-drawer { display: none; }
    .catalog-controls {
        margin-left: 0;
        width: 100%;
        display: flex;
        flex-wrap: nowrap;
        gap: 6px;
        box-sizing: border-box;
    }
    .control-group-pill {
        flex: 1 1 0%;
        min-width: 0;
        overflow: hidden;
    }
    .control-select {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        font-size: var(--font-xs);
        text-overflow: ellipsis;
    }
    .catalog-header {
        transition: top 0.24s ease;
    }
    body.mobile-bars-hidden .catalog-header {
        top: 0;
    }
    #featuredCarouselTrack {
        gap: 8px;
    }
    #featuredCarouselTrack .product-card {
        flex: 0 0 calc((100% - 8px) / 2);
    }
}

@media (max-width: 479px) {
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: clamp(6px, 1.8vw, 10px); }
}

/* Storefront Banner, Announcement Bar & Active Filter Badge (Compact TikTok-Style Header) */
.storefront-buyer-banner {
    position: relative;
    overflow: hidden;
    color: white;
    border-bottom: 3px solid var(--brand-gold);
    background: #292524;
}

.storefront-cover-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: brightness(0.65);
}

.storefront-cover-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.6) 50%, rgba(0,0,0,0.35) 100%);
}

.storefront-banner-inner {
    position: relative;
    z-index: 2;
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px clamp(12px, 3vw, 28px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

.storefront-identity-group {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1 1 260px;
    min-width: 0;
}

.storefront-logo-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2.5px solid var(--brand-gold);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    background: var(--brand-gold);
    color: var(--text-main);
    font-weight: 800;
    font-size: var(--font-heading-section);
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.storefront-text-block {
    min-width: 0;
    flex: 1;
}

.storefront-title-line {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-bottom: 4px;
}

.storefront-banner-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(1.15rem, 2.2vw, 1.55rem);
    font-weight: 800;
    margin: 0;
    line-height: 1.2;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.storefront-banner-bio {
    font-size: var(--font-small);
    color: #fef3c7;
    max-width: 640px;
    line-height: 1.35;
    margin: 0;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.storefront-banner-meta {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: var(--font-xs);
    color: #fde68a;
    flex-wrap: wrap;
}

.storefront-location-link {
    color: #fde68a;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.15s ease;
}

.storefront-location-link:hover {
    color: #ffffff;
    text-decoration: underline;
}

.storefront-item-count-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.storefront-actions-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.storefront-wa-btn {
    background: #15803d;
    border: 1px solid #166534;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    font-size: var(--font-small);
    font-weight: 700;
    border-radius: 9999px;
    box-shadow: 0 3px 10px rgba(21,128,61,0.3);
    color: white;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.storefront-wa-btn:hover {
    background: #166534;
}

.store-announcement-bar {
    background: #78350f;
    color: #fef3c7;
    font-size: var(--font-small);
    font-weight: 600;
    text-align: center;
    padding: 7px 16px;
    border-bottom: 1px solid #b45309;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

@media (max-width: 579px) {
    .storefront-banner-inner {
        padding: 12px 12px 16px 12px;
        gap: 10px;
    }
    .storefront-identity-group {
        gap: 10px;
        flex: 1 1 100%;
    }
    .storefront-logo-wrapper {
        width: 50px;
        height: 50px;
        font-size: 1rem;
    }
    .storefront-title-line {
        gap: 2px 10px;
        margin-bottom: 2px;
    }
    .storefront-banner-title {
        font-size: 1.08rem;
    }
    .storefront-banner-bio {
        font-size: 0.76rem;
        line-height: 1.3;
        -webkit-line-clamp: 2;
    }
    .storefront-actions-group {
        width: 100%;
        margin-bottom: 2px;
    }
    .storefront-wa-btn {
        width: 100%;
        justify-content: center;
        padding: 8px 14px;
        font-size: 0.78rem;
    }
    .store-announcement-bar {
        padding: 5px 12px;
        font-size: 0.76rem;
    }
    body.is-storefront-view .catalog-header {
        display: none;
    }
}

body.is-storefront-view .catalog-controls {
    display: none !important;
}

.active-filter-badge {
    align-items: center;
    gap: 6px;
    background: var(--info-bg);
    border: 1px solid var(--info-border);
    color: var(--info-text);
    font-size: var(--font-xs);
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 9999px;
}

.active-filter-badge-clear {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-weight: 800;
    font-size: var(--font-body);
    padding: 0;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
