/* ==========================================================================
   Alfalend Tooted — kataloog v2.1 (visual refresh)
   Bränd: pruun #3D1A00, roheline #7DC242, Poppins / Inter
   ========================================================================== */

/* ====================== MUUTUJAD & ÜMBRIS ========================= */
.af-tooted {
    --af-brown:  #3D1A00;
    --af-brown2: #5A2E12;
    --af-green:  #7DC242;
    --af-green-d:#5EA22C;
    --af-cream:  #FAF6F0;
    --af-line:   #ECE3D6;
    --af-ink:    #3a2c20;
    --af-muted:  #8a7a67;
    --af-card-sh:      0 2px 14px rgba(61,26,0,.07);
    --af-card-sh-hover:0 20px 48px rgba(61,26,0,.17);

    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 36px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 12px 20px 56px;
    font-family: 'Inter', system-ui, sans-serif;
    color: var(--af-ink);
    box-sizing: border-box;
}
.af-tooted *, .af-tooted *::before, .af-tooted *::after { box-sizing: border-box; }

/* ====================== KÜLGRIBA (DESKTOP — ALATI NÄHTAV) ========================= */
.af-t-sidebar {
    align-self: start;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 0;
    background: #FEFAF5;
    border: 1px solid var(--af-line);
    border-radius: 18px;
    padding: 22px 20px 20px;
}

/* Sulgemis-nupp ja filter-toggle — peidus desktopil */
.af-t-sidebar-close { display: none; }

/* Otsing */
.af-t-search {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}
.af-t-search .dashicons {
    position: absolute; left: 12px;
    color: var(--af-muted); font-size: 18px; width: 18px; height: 18px;
    pointer-events: none;
}
.af-t-search-input {
    width: 100%;
    padding: 11px 34px 11px 38px !important;
    border: 1.5px solid var(--af-line) !important;
    border-radius: 10px !important;
    font-size: 14px !important;
    font-family: inherit !important;
    background: #fff !important;
    color: var(--af-brown) !important;
    transition: border-color .15s, box-shadow .15s;
    box-shadow: none !important;
}
.af-t-search-input:focus {
    outline: none !important;
    border-color: var(--af-green) !important;
    box-shadow: 0 0 0 3px rgba(125,194,66,.16) !important;
}
.af-t-search-clear {
    position: absolute; right: 8px; border: none; background: none; cursor: pointer;
    font-size: 20px; line-height: 1; color: var(--af-muted); padding: 4px;
    transition: color .15s;
}
.af-t-search-clear:hover { color: var(--af-brown); }

/* Filtrisektsioonid */
.af-t-filter-block {
    border-top: 1px solid var(--af-line);
    padding-top: 16px;
    margin-top: 16px;
}
/* Esimene filter-blokk (Kategooriad) on otsingule järgnev – eemaldame top-äärise */
.af-t-search + .af-t-filter-block { border-top: none; padding-top: 0; margin-top: 0; }

/* Sektsiooni pealkiri rohelise indikaatoriga */
.af-t-filter-h {
    margin: 0 0 12px !important;
    font-family: 'Poppins', sans-serif !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    letter-spacing: .13em !important;
    text-transform: uppercase !important;
    color: var(--af-brown) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}
.af-t-filter-h::before {
    content: '';
    display: block;
    width: 3px;
    height: 13px;
    background: var(--af-green);
    border-radius: 2px;
    flex-shrink: 0;
}

/* Kategooriapuu */
.af-t-cats { list-style: none !important; margin: 0; padding: 0; }
.af-t-cats li { list-style: none !important; }
.af-t-cats-d1 { display: none; margin: 2px 0 4px 10px; padding-left: 8px; }
.af-t-cats-d2 { display: none; margin: 2px 0 4px 8px; padding-left: 8px; }
.af-t-cat-li.is-open > .af-t-cats-d1,
.af-t-cat-li.is-open > .af-t-cats-d2 { display: block; }
.af-t-cat-row { display: flex; align-items: center; gap: 2px; }
.af-t-cat {
    flex: 1; min-width: 0;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    background: none; border: none; cursor: pointer; text-align: left;
    padding: 6px 8px; border-radius: 8px;
    font-family: 'Inter', sans-serif; font-size: 13.5px; color: var(--af-ink);
    transition: background .15s, color .15s;
}
.af-t-cat:hover { background: rgba(125,194,66,.12); color: var(--af-brown); }
.af-t-cat.is-active { background: var(--af-green); color: #fff; font-weight: 600; }
.af-t-cat.is-active .af-t-cat-count { background: rgba(255,255,255,.28); color: #fff; }
.af-t-cat-name { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; white-space: normal; word-break: break-word; line-height: 1.35; }
.af-t-cat-count {
    flex-shrink: 0; font-size: 11px; color: var(--af-muted);
    background: var(--af-cream); border-radius: 20px; padding: 1px 8px; min-width: 22px; text-align: center;
}
.af-t-cat-exp {
    flex-shrink: 0; background: none; border: none; cursor: pointer; color: var(--af-muted);
    padding: 4px; display: flex; border-radius: 6px;
}
.af-t-cat-exp:hover { color: var(--af-brown); background: rgba(125,194,66,.12); }
.af-t-cat-exp .dashicons { font-size: 16px; width: 16px; height: 16px; transition: transform .2s; }
.af-t-cat-li.is-open > .af-t-cat-row > .af-t-cat-exp .dashicons { transform: rotate(180deg); }

/* Omadused (checkboxid) */
.af-t-props { display: flex; flex-direction: column; gap: 2px; }
.af-t-check { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 5px 6px; border-radius: 7px; }
.af-t-check:hover { background: rgba(125,194,66,.1); }
.af-t-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.af-t-check-box {
    flex-shrink: 0; width: 18px; height: 18px; border: 1.5px solid #cbbda8; border-radius: 5px;
    position: relative; background: #fff; transition: background .15s, border-color .15s;
}
.af-t-check input:checked + .af-t-check-box { background: var(--af-green); border-color: var(--af-green); }
.af-t-check input:checked + .af-t-check-box::after {
    content: ''; position: absolute; left: 5px; top: 1.5px; width: 5px; height: 10px;
    border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.af-t-check input:focus-visible + .af-t-check-box { box-shadow: 0 0 0 3px rgba(125,194,66,.25); }
.af-t-check-label { font-size: 13.5px; color: var(--af-ink); line-height: 1.4; }

/* Hind */
.af-t-price { display: flex; align-items: center; gap: 8px; }
.af-t-price input {
    width: 100%; padding: 9px 10px !important; border: 1.5px solid var(--af-line) !important;
    border-radius: 8px !important; font-size: 13px !important; font-family: inherit !important;
    background: #fff !important; color: var(--af-brown) !important; box-shadow: none !important;
}
.af-t-price input:focus {
    outline: none !important; border-color: var(--af-green) !important;
    box-shadow: 0 0 0 3px rgba(125,194,66,.16) !important;
}
.af-t-price-sep { color: var(--af-muted); flex-shrink: 0; }

/* Reset-nupp */
.af-t-reset {
    margin-top: 18px;
    background: none; border: 1.5px solid var(--af-line); border-radius: 10px; cursor: pointer;
    padding: 10px 14px; font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 600;
    color: var(--af-brown2); transition: border-color .15s, color .15s, background .15s;
    text-align: center;
}
.af-t-reset:hover { border-color: var(--af-green); color: var(--af-green-d); background: rgba(125,194,66,.07); }

/* ====================== PÕHIALA ========================= */
.af-t-main { min-width: 0; }
.af-t-page-title {
    margin: 0 0 20px !important; font-family: 'Poppins', sans-serif !important;
    font-size: clamp(24px, 3vw, 34px) !important; font-weight: 700 !important; color: var(--af-brown) !important;
}

.af-t-toolbar {
    display: flex; align-items: center; gap: 14px;
    padding-bottom: 18px; margin-bottom: 24px; border-bottom: 1px solid var(--af-line);
    flex-wrap: wrap;
}
.af-t-count { font-size: 14px; color: var(--af-muted); display: flex; align-items: baseline; gap: 4px; }
.af-t-count strong {
    font-family: 'Poppins', sans-serif; font-size: 18px; font-weight: 700; color: var(--af-brown);
}
.af-t-sort { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--af-muted); margin-left: auto; }
.af-t-orderby {
    border: 1.5px solid var(--af-line) !important; border-radius: 8px !important;
    padding: 8px 30px 8px 12px !important; font-size: 13px !important;
    font-family: inherit !important; color: var(--af-brown) !important; background: #fff !important;
    cursor: pointer; box-shadow: none !important; transition: border-color .15s;
}
.af-t-orderby:focus { outline: none !important; border-color: var(--af-green) !important; }

/* Aktiivsed filterkibid */
.af-t-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.af-t-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(125,194,66,.11); border: 1px solid rgba(125,194,66,.38); border-radius: 999px;
    padding: 5px 10px 5px 13px; font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 500;
    color: var(--af-green-d); cursor: pointer; transition: border-color .15s, background .15s;
}
.af-t-chip:hover { border-color: var(--af-green); background: rgba(125,194,66,.2); }
.af-t-chip-x { font-size: 16px; line-height: 1; color: var(--af-green-d); opacity: .5; }
.af-t-chip:hover .af-t-chip-x { opacity: 1; }
/* Alamkategooria chip — natuke erinev visuaal */
.af-t-chip-sub {
    background: transparent;
    border-color: rgba(125,194,66,.28);
    color: var(--af-muted);
    font-size: 12px;
}
.af-t-chip-sub::before { content: '↳ '; opacity: .6; }
.af-t-chip-sub:hover { background: rgba(125,194,66,.1); border-color: var(--af-green); color: var(--af-green-d); }
.af-t-chip-sub .af-t-chip-x { color: var(--af-muted); }
.af-t-chip-sub:hover .af-t-chip-x { color: var(--af-green-d); }

/* ====================== RUUDUSTIK ========================= */
.af-t-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
    gap: 22px;
    transition: opacity .2s;
}
.af-t-grid.is-loading { opacity: .38; pointer-events: none; }

/* ====================== TOOTEKAART ========================= */
.af-t-card {
    display: flex; flex-direction: column;
    position: relative;
    text-decoration: none !important; color: inherit;
    background: #fff;
    border: 1px solid var(--af-line);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--af-card-sh);
    transition: transform .3s cubic-bezier(.2,.7,.2,1), box-shadow .3s, border-color .3s;
}
.af-t-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--af-card-sh-hover);
    border-color: transparent;
}
/* Roheline aktsent-riba alumisel äärel */
.af-t-card::before {
    content: '';
    position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
    background: var(--af-green);
    transform: scaleX(0); transform-origin: left;
    transition: transform .38s cubic-bezier(.2,.7,.2,1);
    z-index: 5; border-radius: 0 0 2px 2px;
}
.af-t-card:hover::before { transform: scaleX(1); }

/* Pildiplokk */
.af-t-card-media {
    position: relative; display: block;
    aspect-ratio: 1 / 1; overflow: hidden;
    background: linear-gradient(135deg, #f5ede0 0%, #ece3ce 100%);
}
/* Gradient-ülekat — ilmub hoverimisel */
.af-t-card-media::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,.03) 0%, rgba(0,0,0,.52) 100%);
    opacity: 0; transition: opacity .38s; z-index: 1; pointer-events: none;
}
.af-t-card:hover .af-t-card-media::after { opacity: 1; }

.af-t-card-img {
    width: 100% !important; height: 100% !important;
    object-fit: cover; display: block;
    transition: transform .55s cubic-bezier(.2,.7,.2,1);
}
.af-t-card:hover .af-t-card-img { transform: scale(1.07); }

.af-t-card-ph {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    color: #d8cbb8;
}
.af-t-card-ph .dashicons { font-size: 44px; width: 44px; height: 44px; }

/* Kategooria pill pildil (vasakus alanurgas) */
.af-t-card-cat {
    position: absolute; bottom: 12px; left: 12px; z-index: 2;
    font-family: 'Poppins', sans-serif; font-size: 10px; font-weight: 700;
    letter-spacing: .08em; text-transform: uppercase;
    color: rgba(255,255,255,.96);
    background: rgba(40,15,0,.70);
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 999px; padding: 4px 11px;
    max-width: calc(100% - 88px);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* „Vaata →" nupp (paremas alanurgas, ilmub hoverimisel) */
.af-t-card-arrow {
    position: absolute; right: 12px; bottom: 12px; z-index: 2;
    display: inline-flex; align-items: center;
    background: var(--af-green); color: #fff; border-radius: 999px;
    font-family: 'Poppins', sans-serif; font-size: 12px; font-weight: 600;
    padding: 7px 14px; white-space: nowrap; line-height: 1;
    opacity: 0; transform: translateY(8px);
    transition: opacity .28s, transform .28s;
}
.af-t-card:hover .af-t-card-arrow { opacity: 1; transform: translateY(0); }

/* Kaardi info */
.af-t-card-body { display: flex; flex-direction: column; gap: 7px; padding: 16px 18px 20px; }
.af-t-card-title {
    font-family: 'Poppins', sans-serif; font-size: 15px; font-weight: 600; line-height: 1.35;
    color: var(--af-brown);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    transition: color .2s;
}
.af-t-card:hover .af-t-card-title { color: var(--af-green-d); }
.af-t-card-price { font-size: 16px; font-weight: 700; color: var(--af-brown2); margin-top: 2px; }
.af-t-price-pre { font-size: 12px; font-weight: 400; color: var(--af-muted); margin-right: 3px; }
.af-t-price-unit { font-size: 12px; font-weight: 400; color: var(--af-muted); }

/* Tühi tulemus */
.af-t-empty {
    grid-column: 1 / -1; text-align: center; padding: 64px 20px; color: var(--af-muted);
}
.af-t-empty .dashicons { font-size: 42px; width: 42px; height: 42px; color: #cbbda8; margin-bottom: 12px; }
.af-t-empty p { margin: 4px 0; font-size: 16px; color: var(--af-brown); }
.af-t-empty-sub { font-size: 14px !important; color: var(--af-muted) !important; }

/* Lae veel */
.af-t-loadmore-wrap { display: flex; justify-content: center; margin-top: 38px; }
.af-t-loadmore {
    background: var(--af-green); color: #fff; border: none; border-radius: 12px;
    padding: 14px 38px; font-family: 'Poppins', sans-serif; font-size: 14px; font-weight: 600;
    cursor: pointer; box-shadow: 0 4px 18px rgba(125,194,66,.28);
    transition: background .15s, transform .18s, box-shadow .18s;
}
.af-t-loadmore:hover {
    background: var(--af-green-d);
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(125,194,66,.38);
}
.af-t-loadmore.is-loading { opacity: .6; pointer-events: none; transform: none; }

/* Filtri-nupp toolbar'is — peidus desktopil, nähtav mobiilis */
.af-t-filter-toggle {
    display: none;
    flex-shrink: 0;
    align-items: center; gap: 7px;
    background: var(--af-surface-strong, var(--af-brown)); color: var(--af-on-surface-strong, #fff); border: none; border-radius: 10px;
    padding: 9px 14px;
    font-family: 'Poppins', sans-serif; font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background .15s, box-shadow .15s;
    box-shadow: 0 3px 10px rgba(61,26,0,.2);
}
.af-t-filter-toggle:hover { background: var(--af-surface-strong, var(--af-brown2)); box-shadow: 0 4px 14px rgba(61,26,0,.28); }
.af-t-filter-toggle .dashicons { font-size: 17px; width: 17px; height: 17px; }

/* ====================== RESPONSIVE ========================= */
@media (max-width: 900px) {
    .af-tooted { grid-template-columns: 1fr; gap: 0; }

    /* Filter-toggle nähtav mobiilis */
    .af-t-filter-toggle { display: inline-flex; }

    /* Sidebar muutub slide-in sahtliks */
    .af-t-sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        width: 88%; max-width: 360px;
        z-index: 100000; overflow-y: auto;
        max-height: none;
        background: #FEFAF5;
        border: none; border-right: 1px solid var(--af-line); border-radius: 0;
        padding: 16px 20px 28px;
        transform: translateX(-100%);
        transition: transform .28s ease;
        box-shadow: 4px 0 40px rgba(0,0,0,.14);
    }
    .af-t-sidebar-open .af-t-sidebar { transform: translateX(0); }
    .af-t-sidebar-open::before {
        content: ''; position: fixed; inset: 0;
        background: rgba(61,26,0,.42); z-index: 99999;
    }

    /* Sulgemis-nupp nähtav mobiilis */
    .af-t-sidebar-close {
        display: flex;
        align-self: flex-end;
        background: none; border: none; cursor: pointer;
        font-size: 26px; line-height: 1; color: var(--af-muted);
        padding: 4px 6px; border-radius: 7px;
        margin-bottom: 8px; transition: color .15s, background .15s;
    }
    .af-t-sidebar-close:hover { color: var(--af-brown); background: var(--af-cream); }
}
@media (max-width: 620px) {
    .af-t-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
    .af-t-card-title { font-size: 14px; }
    .af-t-card-body { padding: 12px 13px 14px; gap: 5px; }
    .af-t-card-price { font-size: 15px; }
    .af-t-card-cat { font-size: 9px; padding: 3px 9px; bottom: 8px; left: 8px; }
    .af-t-card-arrow { font-size: 11px; padding: 6px 11px; right: 8px; bottom: 8px; }
    .af-t-toolbar { gap: 10px; }
    .af-t-filter-toggle { padding: 8px 12px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
    .af-t-card, .af-t-card-img, .af-t-card-arrow, .af-t-sidebar, .af-t-card::before {
        transition: none !important;
    }
    .af-t-card:hover { transform: none; }
    .af-t-card:hover .af-t-card-img { transform: none; }
    .af-t-card:hover::before { transform: scaleX(1); }
}

/* ====================== WOOCOMMERCE LISAD ========================= */
.af-t-badge {
    position: absolute; top: 10px; left: 10px; z-index: 3;
    font-family: 'Poppins', sans-serif; font-size: 11px; font-weight: 700; letter-spacing: .02em;
    padding: 4px 11px; border-radius: 999px; color: #fff;
}
.af-t-badge-sale { background: var(--af-green); }
.af-t-badge-oos {
    background: rgba(95,75,62,.82); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    left: auto; right: 10px;
}
.af-t-card.is-oos .af-t-card-media { opacity: .72; }

/* WooCommerce get_price_html() */
.af-t-card-price { margin-top: 2px; font-size: 16px; font-weight: 700; color: var(--af-brown2); }
.af-t-card-price del { color: var(--af-muted); font-weight: 400; font-size: 13px; margin-right: 4px; }
.af-t-card-price ins { text-decoration: none; color: var(--af-green-d); }
.af-t-card-price .woocommerce-Price-amount { white-space: nowrap; }

.af-t-note { font-size: 13px; color: var(--af-muted); margin: 0; }
