/* =============================================================
   Archive Product Page — Leon Dio
   ============================================================= */

/* ── Container override (global has 40px, reduce for archive) ── */
#archive-product-page .container {
    padding: 0 20px;
}

/* ── Archive Header ─────────────────────────────────────────── */
.archive-header {
    background: var(--secondary);
    text-align: center;
    padding-bottom: 64px;
}

/* Force flex column to guarantee DOM order: image → title → desc */
.archive-header .container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.archive-header .archive-title {
    color: #fff;
    margin: 0 0 20px;
    order: 2;
}

.archive-desc {
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
    line-height: 1.8;
    max-width: 680px;
    order: 3;
}

.archive-featured-img {
    width: 100%;
    margin-bottom: 48px;
    border-radius: 16px;
    overflow: hidden;
    order: 1;
}

.archive-featured-img img,
img.archive-cat-img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    border-radius: 16px;
}

@media (min-width: 769px) {
    .archive-featured-img img,
    img.archive-cat-img {
        max-height: 500px;
    }
}

/* ── Filter Bar ─────────────────────────────────────────────── */
.archive-filter-bar {
    background: #fff;
    border-top: 1px solid #ebebeb;
    border-bottom: 1px solid #ebebeb;
    z-index: 90;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* JS sticky class — activated via scroll listener (overflow-x:hidden on body breaks CSS sticky) */
/* top is set dynamically by JS to match actual header height */
.archive-filter-bar.is-sticky {
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
}

/* Spacer injected by JS to prevent layout jump when bar goes fixed */
.archive-filter-bar-spacer {
    display: none;
}
.archive-filter-bar-spacer.active {
    display: block;
}

.filter-form {
    display: flex;
    align-items: stretch;
    gap: 8px;
    flex-wrap: nowrap;   /* single row always */
    padding: 12px 0;
}

.filter-group {
    flex: 1;
    min-width: 100px;
}

.filter-select {
    appearance: none;
    -webkit-appearance: none;
    background: #f8f8f8 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E") no-repeat right 10px center;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 9px 26px 9px 10px;
    font-size: 13px;
    color: var(--text-dark);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.12);
}

.filter-select:hover {
    border-color: var(--primary);
}

.filter-clear {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 9px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    white-space: nowrap;
    align-self: flex-end;
    transition: all 0.2s;
}

.filter-clear:hover {
    color: #c0392b;
    border-color: #c0392b;
    background: #fff5f5;
}

/* ── Mega Menu (Category filter) ──────────────────────────── */
.filter-mega-group {
    position: relative;
    flex: 1;
    min-width: 100px;
}

.filter-mega-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    height: 100%;
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 9px 10px;
    font-size: 13px;
    color: var(--text-dark);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    white-space: nowrap;
    overflow: hidden;
    font-family: inherit;
}

.filter-mega-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-mega-btn:hover,
.filter-mega-group.open .filter-mega-btn {
    border-color: var(--primary);
    background: #fff;
}

.filter-mega-group.open .filter-mega-btn .fa-chevron-down {
    transform: rotate(180deg);
}

.filter-mega-btn .fa-chevron-down {
    font-size: 10px;
    color: #999;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.filter-mega-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 560px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    z-index: 200;
    padding: 16px;
}

.filter-mega-group.open .filter-mega-dropdown {
    display: block;
}

.mega-cols {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0 20px;
}

.mega-col {
    border-right: 1px solid #f0f0f0;
    padding-right: 16px;
}

.mega-col:last-child {
    border-right: none;
    padding-right: 0;
}

.mega-brand {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dark);
    text-decoration: none;
    margin-bottom: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    letter-spacing: 0.02em;
    transition: color 0.15s;
}

.mega-brand:hover,
.mega-brand.active {
    color: var(--primary);
}

.mega-subitems {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mega-subitems li {
    margin: 0;
}

.mega-subitems a {
    display: block;
    font-size: 12.5px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 5px 6px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    line-height: 1.4;
}

.mega-subitems a:hover,
.mega-subitems a.active {
    color: var(--primary);
    background: rgba(197,160,89,0.06);
}

/* ── Result Count ───────────────────────────────────────────── */
.archive-result-count {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 28px;
}

/* ── Products Section ───────────────────────────────────────── */
.archive-products {
    background: #fff;
}

/* ── Pagination ─────────────────────────────────────────────── */
.leon-pagination {
    margin-top: 48px;
    margin-bottom: 8px;
}

/* paginate_links() type=list outputs <ul class="page-numbers"> */
.leon-pagination .page-numbers {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.leon-pagination .page-numbers li {
    margin: 0;
    padding: 0;
    list-style: none;
}

.leon-pagination .page-numbers a,
.leon-pagination .page-numbers span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 14px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-dark);
    text-decoration: none;
    background: #fff;
    transition: all 0.2s;
    font-family: inherit;
    line-height: 1;
}

.leon-pagination .page-numbers a:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(197,160,89,0.06);
}

/* Active page */
.leon-pagination .page-numbers .current {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 700;
}

/* Dots separator */
.leon-pagination .page-numbers .dots {
    border: none;
    background: transparent;
    color: var(--text-muted);
    min-width: 24px;
    padding: 0 4px;
}

/* Prev / Next: icon only, square */
.leon-pagination .page-numbers .prev,
.leon-pagination .page-numbers .next {
    min-width: 40px;
    padding: 0;
    font-size: 12px;
}

.leon-pagination li span.current {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

/* ── No Products ────────────────────────────────────────────── */
.archive-no-products {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.archive-no-products i {
    font-size: 48px;
    color: #ddd;
    display: block;
    margin-bottom: 20px;
}

.archive-no-products p {
    font-size: 16px;
    margin-bottom: 24px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .filter-form { gap: 10px; }
    .filter-group { min-width: 100px; }
    .filter-mega-group { min-width: 100px; }

    /* Dropdown: keep wide but shift left if overflows */
    .filter-mega-dropdown { min-width: 480px; }
}

@media (max-width: 768px) {
    /* Archive header */
    .archive-header { padding-bottom: 40px; }
    #archive-product-page .container { padding: 0 12px; }
    .archive-header .archive-title { font-size: 28px !important; }
    .archive-desc { font-size: 14px; }
    .archive-featured-img { margin-bottom: 28px; }

    /* Fix product grid on mobile */
    .product-grid { gap: 10px !important; }
    .product-img { height: 180px !important; }

    /* Filter bar: still 1 row, tighter */
    .filter-form { gap: 6px; padding: 10px 0; }
    .filter-select { font-size: 12px; padding: 8px 22px 8px 8px; }
    .filter-mega-btn { font-size: 12px; padding: 8px 8px; }

    /* Mega dropdown: full viewport width */
    .filter-mega-dropdown {
        min-width: unset;
        width: calc(100vw - 32px);
        left: 0;
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Stack brand columns vertically */
    .mega-cols { grid-template-columns: 1fr; gap: 0; }

    .mega-col {
        border-right: none;
        border-bottom: 1px solid #f0f0f0;
        padding-right: 0;
        padding-bottom: 12px;
        margin-bottom: 12px;
    }

    .mega-col:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }

    /* Sub-items as horizontal pills */
    .mega-subitems { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
    .mega-subitems li { flex: none; }
    .mega-subitems a {
        background: #f5f5f5;
        border-radius: 20px;
        padding: 4px 12px;
        font-size: 12px;
        white-space: nowrap;
    }
    .mega-subitems a.active,
    .mega-subitems a:hover { background: rgba(197,160,89,0.12); }

    /* Products grid */
    .product-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
}

@media (max-width: 480px) {
    .archive-header .archive-title { font-size: 22px !important; }
    #archive-product-page .container { padding: 0 10px; }
    .filter-form { gap: 5px; }
    .filter-select,
    .filter-mega-btn { font-size: 11px; }
    .product-img { height: 150px !important; }
}
