/* ================================================================
   Alves & Sons — Catalogue Page
   Tapi-style sidebar filter layout
================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --dark-bg:    #1a1c1e;
    --darker-bg:  #151719;
    --card-dark:  #23262a;
    --card2:      #2c3035;
    --gold:       #d4a574;
    --gold-light: #e5b885;
    --grey:       #a0a0a0;
    --grey-light: #c8c8c8;
    --border:     rgba(255,255,255,0.06);
    --border2:    rgba(255,255,255,0.10);
    --sidebar-w:  260px;
    --header-h:   80px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--dark-bg);
    color: white;
    line-height: 1.6;
}

/* ── HEADER ──────────────────────────────────────────────────── */
header {
    position: fixed; top: 0; width: 100%; z-index: 900;
    background: rgba(26,28,30,0.96); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    height: var(--header-h);
}
.header-container {
    max-width: 1400px; margin: 0 auto; padding: 0 1.5rem;
    display: flex; justify-content: space-between; align-items: center;
    height: 100%;
}
.logo-section { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; }
.logo-section img { height: 44px; width: auto; }
.logo-text { color: var(--gold); font-weight: 600; letter-spacing: 0.1em; font-size: 0.82rem; text-transform: uppercase; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 1.25rem; }
.hdr-link { color: var(--grey); font-size: 0.875rem; font-weight: 500; text-decoration: none; transition: color 0.2s; }
.hdr-link:hover { color: white; }
.cart-button {
    position: relative; background: none;
    border: 1.5px solid var(--gold); color: var(--gold);
    padding: 0.55rem 1.1rem; border-radius: 9999px;
    cursor: pointer; transition: all 0.25s;
    display: flex; align-items: center; gap: 0.45rem;
    font-weight: 600; font-size: 0.82rem;
}
.cart-button:hover { background: var(--gold); color: var(--dark-bg); }
.cart-count {
    position: absolute; top: -7px; right: -7px;
    background: #e53e3e; color: white; border-radius: 50%;
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.68rem; font-weight: 700;
}

/* ── HERO ────────────────────────────────────────────────────── */
.catalog-hero {
    padding: calc(var(--header-h) + 3.5rem) 1.5rem 3rem;
    text-align: center;
    background: linear-gradient(160deg, var(--darker-bg) 0%, var(--dark-bg) 100%);
    border-bottom: 1px solid var(--border);
}
.catalog-hero h1 {
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    font-weight: 800; margin-bottom: 0.6rem;
    background: linear-gradient(135deg, white 30%, var(--gold) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.catalog-hero p { font-size: 1rem; color: var(--grey); }

/* ── LAYOUT ──────────────────────────────────────────────────── */
.catalog-layout {
    max-width: 1400px; margin: 0 auto;
    display: flex; align-items: flex-start;
    padding: 2rem 1.5rem 4rem; gap: 2rem;
}

/* ── FILTER SIDEBAR ──────────────────────────────────────────── */
.filter-sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    position: sticky; top: calc(var(--header-h) + 1rem);
    max-height: calc(100vh - var(--header-h) - 2rem);
    overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin; scrollbar-color: rgba(212,165,116,0.25) transparent;
}
.filter-sidebar::-webkit-scrollbar { width: 3px; }
.filter-sidebar::-webkit-scrollbar-thumb { background: rgba(212,165,116,0.25); border-radius: 2px; }

.sidebar-header {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 0.875rem; margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.sidebar-title { font-size: 0.95rem; font-weight: 700; color: white; }
.sidebar-clear {
    background: none; border: none; color: var(--grey); font-size: 0.78rem;
    cursor: pointer; transition: color 0.2s; padding: 0;
}
.sidebar-clear:hover { color: var(--gold); }

/* Active chips */
.active-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; min-height: 0; margin-bottom: 0.5rem; }
.chip {
    display: inline-flex; align-items: center; gap: 0.3rem;
    background: rgba(212,165,116,0.12); border: 1px solid rgba(212,165,116,0.3);
    color: var(--gold); padding: 0.2rem 0.55rem;
    border-radius: 9999px; font-size: 0.72rem; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.chip:hover { background: rgba(212,165,116,0.22); }
.chip svg { width: 10px; height: 10px; flex-shrink: 0; }

/* Filter blocks */
.filter-block { border-bottom: 1px solid var(--border); }
.filter-block-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.85rem 0; cursor: pointer; user-select: none;
    font-size: 0.875rem; font-weight: 600; color: var(--grey-light);
    transition: color 0.15s;
}
.filter-block-head:hover { color: white; }
.fb-arrow { transition: transform 0.25s; flex-shrink: 0; }
.filter-block.collapsed .fb-arrow { transform: rotate(-90deg); }
.filter-block-body { padding-bottom: 0.75rem; }
.filter-block.collapsed .filter-block-body { display: none; }

/* Checkbox options */
.fc-option {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.35rem 0; cursor: pointer;
    font-size: 0.83rem; color: var(--grey);
    transition: color 0.15s; line-height: 1.4;
}
.fc-option:hover { color: white; }
.fc-option input[type="checkbox"] {
    width: 16px; height: 16px; flex-shrink: 0;
    accent-color: var(--gold); cursor: pointer;
    border-radius: 3px;
}
.fc-option input[type="checkbox"]:checked + span,
.fc-option:has(input:checked) { color: white; font-weight: 600; }
.fc-count { color: var(--grey); font-size: 0.75rem; margin-left: auto; }

/* Colour swatches in filter */
.colour-swatch-opt {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.3rem 0; cursor: pointer; font-size: 0.83rem;
    color: var(--grey); transition: color 0.15s;
}
.colour-swatch-opt:hover { color: white; }
.colour-swatch-opt input { accent-color: var(--gold); cursor: pointer; }
.c-dot {
    width: 18px; height: 18px; border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,0.2); flex-shrink: 0;
}
.fc-loading { font-size: 0.78rem; color: var(--grey); padding: 0.35rem 0; }

/* ── Colour swatch grid (Task 6A) ── */
.colour-swatch-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 0.4rem;
}
.colour-swatch-grid.collapsed {
    max-height: calc(28px * 2 + 6px); /* exactly 2 rows */
    overflow: hidden;
}
.colour-swatch-btn {
    width: 28px; height: 28px; border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer; flex-shrink: 0;
    transition: transform 0.15s, border-color 0.15s;
    position: relative;
}
.colour-swatch-btn:hover { transform: scale(1.15); }
.colour-swatch-btn.selected {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212,165,116,0.3);
}
/* hidden checkbox backing each swatch */
.colour-swatch-btn input[type="checkbox"] {
    position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%;
    cursor: pointer; margin: 0;
}

/* View more */
.fc-view-more {
    background: none; border: none; color: var(--gold);
    font-size: 0.78rem; font-weight: 600; cursor: pointer;
    padding: 0.35rem 0; transition: opacity 0.2s;
}
.fc-view-more:hover { opacity: 0.75; }

/* ── MAIN CONTENT ────────────────────────────────────────────── */
.catalog-main { flex: 1; min-width: 0; }

/* Sort bar */
.sort-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.875rem 1.25rem;
    background: var(--card-dark); border: 1px solid var(--border);
    border-radius: 0.625rem; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.sort-bar-left { display: flex; align-items: center; gap: 0.75rem; }
.btn-filter-toggle {
    display: none; align-items: center; gap: 0.4rem;
    background: none; border: 1.5px solid var(--border2);
    color: var(--grey-light); padding: 0.5rem 0.875rem;
    border-radius: 0.375rem; cursor: pointer; font-size: 0.82rem;
    font-weight: 600; transition: all 0.2s;
}
.btn-filter-toggle:hover { border-color: var(--gold); color: var(--gold); }
.fc-badge {
    background: var(--gold); color: var(--dark-bg);
    border-radius: 9999px; font-size: 0.65rem; font-weight: 800;
    padding: 0.05rem 0.4rem; min-width: 18px; text-align: center;
}
.results-count { font-size: 0.82rem; color: var(--grey); }
.results-count strong { color: white; font-weight: 700; }
.sort-bar-right { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.sort-label { font-size: 0.82rem; color: var(--grey); white-space: nowrap; }
.sort-select {
    padding: 0.5rem 0.75rem;
    background: var(--dark-bg); border: 1px solid var(--border2);
    border-radius: 0.375rem; color: white; font-size: 0.82rem;
    cursor: pointer; transition: border-color 0.2s; outline: none;
}
.sort-select:focus { border-color: var(--gold); }

/* Loading */
.loading-container { text-align: center; padding: 4rem; color: var(--grey); }
.loading-spinner {
    width: 44px; height: 44px; margin: 0 auto 1rem;
    border: 3px solid rgba(255,255,255,0.08);
    border-top-color: var(--gold); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── PRODUCTS GRID ───────────────────────────────────────────── */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem; padding-bottom: 4rem;
}

.product-card {
    background: var(--card-dark); border: 1px solid var(--border);
    border-radius: 0.75rem; overflow: hidden;
    display: flex; flex-direction: column;
    cursor: pointer; transition: border-color 0.25s, transform 0.25s, box-shadow 0.25s;
}
.product-card:hover {
    border-color: rgba(212,165,116,0.4); transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}
.product-image { aspect-ratio: 4/3; background: var(--card2); overflow: hidden; position: relative; }
.product-image img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform 0.6s;
}
.product-card:hover .product-image img { transform: scale(1.07); }

.product-badge {
    position: absolute; top: 0.75rem; right: 0.75rem;
    background: var(--gold); color: var(--dark-bg);
    padding: 0.25rem 0.6rem; border-radius: 9999px;
    font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
}

.product-content {
    padding: 1.25rem; flex: 1; display: flex; flex-direction: column; gap: 0.35rem;
}
.product-category {
    color: var(--gold); font-size: 0.7rem;
    text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700;
}
.product-name { font-size: 1.05rem; font-weight: 700; color: white; line-height: 1.35; }
.product-description {
    color: var(--grey); font-size: 0.8rem; line-height: 1.55;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    flex: 1;
}
.product-specs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.1rem; }
.spec-tag {
    background: rgba(212,165,116,0.08); color: var(--gold);
    padding: 0.18rem 0.55rem; border-radius: 9999px; font-size: 0.68rem; font-weight: 600;
}
.product-colors { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.1rem; }
.color-dots { display: flex; gap: 3px; }
.color-dot {
    width: 14px; height: 14px; border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,0.15);
}
.colors-label { font-size: 0.72rem; color: var(--grey); }

.product-footer {
    display: flex; justify-content: space-between; align-items: flex-end;
    padding-top: 0.875rem; border-top: 1px solid var(--border); margin-top: auto;
    gap: 0.75rem;
}
/* Consistent card body height so a grid of accessories/underlays with varying
   description lengths lines up (price footer always pinned to the bottom). */
.product-content { min-height: 190px; }
.product-footer .price-unit { line-height: 1.3; }
.product-price { font-size: 1.4rem; font-weight: 800; color: var(--gold); }
.price-unit { font-size: 0.7rem; color: var(--grey); }
.view-details-btn {
    background: none; border: 1.5px solid var(--gold);
    color: var(--gold); padding: 0.5rem 1rem; border-radius: 9999px;
    cursor: pointer; font-size: 0.78rem; font-weight: 700;
    transition: all 0.2s; white-space: nowrap;
}
.view-details-btn:hover { background: var(--gold); color: var(--dark-bg); }

.no-products {
    text-align: center; padding: 4rem 1rem; color: var(--grey);
    grid-column: 1/-1;
}
.no-products h3 { font-size: 1.35rem; margin-bottom: 0.5rem; color: var(--grey-light); }
.no-products button {
    margin-top: 1.25rem; background: var(--gold); color: var(--dark-bg);
    border: none; padding: 0.75rem 1.75rem; border-radius: 9999px;
    font-weight: 700; font-size: 0.875rem; cursor: pointer; transition: opacity 0.2s;
}
.no-products button:hover { opacity: 0.85; }

/* ── FOOTER ──────────────────────────────────────────────────── */
footer {
    background: var(--darker-bg); border-top: 1px solid var(--border);
    padding: 2.5rem 1.5rem;
}
.footer-content {
    max-width: 1400px; margin: 0 auto;
    display: flex; flex-direction: column; align-items: center; gap: 1rem;
}
.footer-logo { display: flex; align-items: center; gap: 0.75rem; }
.footer-logo img { height: 42px; }
.footer-text { text-align: center; color: var(--grey); font-size: 0.8rem; }
.footer-text p { margin-bottom: 0.25rem; }

/* ── TOAST ───────────────────────────────────────────────────── */
.toast {
    position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 10000;
    background: var(--card-dark); border: 1.5px solid var(--gold);
    border-radius: 0.625rem; padding: 1rem 1.5rem;
    display: flex; align-items: center; gap: 0.75rem;
    color: white; font-size: 0.875rem;
    transform: translateX(120%); transition: transform 0.3s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.toast.show { transform: translateX(0); }

/* ── MOBILE SIDEBAR OVERLAY ──────────────────────────────────── */
.sidebar-overlay {
    display: none; position: fixed; inset: 0; z-index: 800;
    background: rgba(0,0,0,0.6);
}
.sidebar-overlay.open { display: block; }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .catalog-layout { gap: 1.5rem; padding: 1.5rem 1rem 3rem; }
    --sidebar-w: 240px;
}

@media (max-width: 768px) {
    :root { --header-h: 64px; }
    .logo-text { font-size: 0.7rem; }
    .catalog-hero { padding: calc(var(--header-h) + 2rem) 1rem 2rem; }
    .catalog-layout { padding: 1rem 1rem 3rem; }

    /* Sidebar becomes a slide-in drawer */
    .filter-sidebar {
        position: fixed; top: 0; left: -100%; width: 80%; max-width: 300px;
        height: 100vh; z-index: 850; background: var(--darker-bg);
        border-right: 1px solid var(--border); padding: 1.25rem;
        transition: left 0.3s ease; max-height: 100vh;
        overflow-y: auto;
    }
    .filter-sidebar.open { left: 0; }
    .btn-filter-toggle { display: flex; min-height: 44px; }
    /* min(100%,…) avoids horizontal overflow on small tablets/phones */
    .products-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 1rem; }
    .cart-button { min-height: 44px; }
}

/* Telemóvel: header limpo e sem aperto — logo (=home) + conta + cesta */
@media (max-width: 600px) {
    .header-container { padding: 0 1rem; }
    .header-actions { gap: 0.6rem; }
    .hdr-link { display: none; }                /* esconde Home / Materials & Accessories no telemóvel */
    .logo-text { display: none; }               /* logo circular já identifica a marca */
    .logo-section img { height: 40px; }
    .cart-button { min-height: 44px; }
}

@media (max-width: 480px) {
    .logo-text { display: none; }
    .products-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    .product-content { padding: 0.875rem; min-height: 0; }   /* reset desktop min-height on phones */
    .product-name { font-size: 0.92rem; }
    .product-price { font-size: 1.15rem; }
    .view-details-btn { font-size: 0.72rem; padding: 0.5rem 0.75rem; min-height: 38px; }
    .toast { left: 1rem; right: 1rem; transform: translateY(120%); }
    .toast.show { transform: translateY(0); }
    /* Keep the "Materials & Accessories" nav link reachable; just shrink it */
    .hdr-link { font-size: 0.78rem; padding: 0.35rem 0.4rem; }
}

/* Avoid sticky hover lift on touch devices */
@media (hover: none) {
    .product-card:hover { transform: none; box-shadow: none; }
    .product-card:active { border-color: rgba(212,165,116,0.4); }
}
