/* ============================================
   TopFarm Sidebar v14 – Unified Search, Category Filter, Sort, Wishlist & Load More
   ============================================ */

:root {
    --tf-green:        #4caf50;
    --tf-green-dark:   #388e3c;
    --tf-green-light:  #e8f5e9;
    --tf-green-mid:    #c8e6c9;
    --tf-text:         #333;
    --tf-text-light:   #777;
    --tf-border:       #e0e0e0;
    --tf-bg:           #fff;
    --tf-radius:       6px;
}

/* ── Mobile toggle ───────────────────────── */
#tf-mobile-toggle { display: none; }
@media ( max-width: 767px ) {
    #tf-mobile-toggle {
        display: block;
        width: 100%;
        padding: 12px 16px;
        background: var(--tf-green);
        color: #fff;
        border: none;
        border-radius: var(--tf-radius);
        font-size: 15px;
        font-weight: 600;
        font-family: inherit;
        cursor: pointer;
        text-align: center;
        margin-bottom: 12px;
        transition: background 0.2s;
    }
    #tf-mobile-toggle:hover,
    #tf-mobile-toggle.tf-mobile-toggle--open { background: var(--tf-green-dark); }
}

/* ── Search ──────────────────────────────── */
.tf-search-wrap { margin-bottom: 8px; }

.tf-search-form {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--tf-border);
    border-radius: var(--tf-radius);
    overflow: hidden;
    background: var(--tf-bg);
    transition: border-color 0.2s;
}
.tf-search-form:focus-within { border-color: var(--tf-green); }

.tf-search-input {
    flex: 1;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 9px 12px;
    font-size: 13.5px;
    color: var(--tf-text);
    background: transparent;
    min-width: 0;
}
.tf-search-input::placeholder { color: #aaa; }

.tf-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    background: var(--tf-green);
    border: none;
    cursor: pointer;
    color: #fff;
    transition: background 0.2s;
    flex-shrink: 0;
}
.tf-search-btn:hover { background: var(--tf-green-dark); }
.tf-search-btn svg { width: 16px; height: 16px; display: block; }

/* ── Sort dropdown ───────────────────────── */
.tf-sort-wrap { margin-bottom: 4px; }

.tf-sort-select-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.tf-sort-select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    padding: 10px 36px 10px 12px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--tf-text);
    background: var(--tf-bg);
    border: 1.5px solid var(--tf-border);
    border-radius: var(--tf-radius);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.4;
}
.tf-sort-select:focus,
.tf-sort-select:hover { border-color: var(--tf-green); }

.tf-sort-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--tf-text-light);
    display: flex;
    align-items: center;
}
.tf-sort-arrow svg { width: 16px; height: 16px; display: block; }

/* ── Category filter ─────────────────────── */
.tf-cat-filter { position: relative; }
.tf-cat-list { list-style: none; margin: 0; padding: 0; }
.tf-cat-list--root { border: 1.5px solid var(--tf-border); border-radius: var(--tf-radius); overflow: hidden; }
.tf-cat-list--root > .tf-cat-item + .tf-cat-item { border-top: 1px solid var(--tf-border); }

.tf-cat-item { background: var(--tf-bg); }
.tf-cat-row { display: flex; align-items: center; transition: background 0.15s; }
.tf-cat-row:hover { background: var(--tf-green-light); }
.tf-cat-item--active > .tf-cat-row { background: var(--tf-green); }
.tf-cat-item--active > .tf-cat-row:hover { background: var(--tf-green-dark); }

.tf-cat-btn {
    flex: 1; display: flex; align-items: center; gap: 4px;
    padding: 11px 14px; font-size: 13.5px; font-weight: 500;
    color: var(--tf-text); background: none; border: none; cursor: pointer;
    text-align: left; line-height: 1.3; font-family: inherit; transition: color 0.15s;
}
.tf-cat-btn:hover { color: var(--tf-green-dark); }
.tf-cat-btn--active { color: #fff !important; font-weight: 600; }
.tf-cat-btn--active .tf-cat-count { color: rgba(255,255,255,0.8) !important; }
.tf-cat-btn--active .tf-cat-name::before { content: '✓ '; font-size: 11px; font-weight: 700; }

.tf-cat-count { color: var(--tf-text-light); font-size: 12px; font-weight: 400; margin-left: auto; padding-left: 4px; white-space: nowrap; }

.tf-cat-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; min-width: 38px;
    background: none; border: none; cursor: pointer; color: #bbb;
    padding: 0; transition: color 0.2s; flex-shrink: 0;
}
.tf-cat-toggle:hover { color: var(--tf-green); }
.tf-cat-item--active > .tf-cat-row .tf-cat-toggle { color: rgba(255,255,255,0.75); }
.tf-cat-item--active > .tf-cat-row .tf-cat-toggle:hover { color: #fff; }

.tf-toggle-icon { width: 14px; height: 14px; display: block; transition: transform 0.25s ease; }
.tf-cat-item--open > .tf-cat-row .tf-toggle-icon { transform: rotate(90deg); }

.tf-cat-list--children { border-top: 1px solid var(--tf-border); background: #fafafa; }
.tf-cat-list--children > .tf-cat-item + .tf-cat-item { border-top: 1px solid #f0f0f0; }
.tf-cat-list--children .tf-cat-btn                                                                       { padding-left: 26px; font-size: 13px; font-weight: 400; }
.tf-cat-list--children .tf-cat-list--children .tf-cat-btn                                               { padding-left: 40px; }
.tf-cat-list--children .tf-cat-list--children .tf-cat-list--children .tf-cat-btn                        { padding-left: 54px; }
.tf-cat-list--children .tf-cat-list--children .tf-cat-list--children .tf-cat-list--children .tf-cat-btn { padding-left: 68px; }
.tf-cat-list--children .tf-cat-list--children { background: #f5f5f5; }

.tf-clear-filter {
    display: block; width: 100%; margin-top: 8px; padding: 7px 12px;
    background: #fff; border: 1.5px solid var(--tf-border); border-radius: var(--tf-radius);
    color: var(--tf-text-light); font-size: 12.5px; cursor: pointer;
    text-align: center; transition: border-color 0.2s, color 0.2s; font-family: inherit;
}
.tf-clear-filter:hover { border-color: #e57373; color: #c62828; }

/* ── Grid loading state ──────────────────── */
.tf-grid-wrap { position: relative; }
.tf-loader { display: none !important; }
.tf-grid--loading {
    opacity: 0.4;
    filter: blur(3px);
    pointer-events: none;
    transition: opacity 0.2s ease, filter 0.2s ease;
}

/* ── Load more ───────────────────────────── */
.tf-load-more-wrap { text-align: center; margin: 30px 0; }

.tf-load-more-btn {
    display: inline-block;
    padding: 12px 40px;
    background: #fff;
    border: 2px solid var(--tf-green);
    border-radius: var(--tf-radius);
    color: var(--tf-green);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, color 0.2s;
    letter-spacing: 0.02em;
}
.tf-load-more-btn:hover { background: var(--tf-green); color: #fff; }
.tf-load-more-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.tf-load-more-count { font-weight: 400; font-size: 12px; opacity: 0.75; }

/* ── Heart / wishlist button ─────────────── */
.tf-heart-btn {
    position: absolute; top: 10px; right: 10px; z-index: 10;
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.92); border: none; border-radius: 50%;
    cursor: pointer; padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    transition: background 0.2s, transform 0.15s, color 0.2s;
    color: #bbb;
}
.tf-heart-btn:hover { background: #fff; transform: scale(1.1); color: #e53935; }
.tf-heart-btn--active { color: #e53935; }
.tf-heart-btn svg { width: 18px; height: 18px; display: block; transition: fill 0.2s, transform 0.2s; }
.tf-heart-btn--active svg { animation: tf-heart-pop 0.25s ease; }
@keyframes tf-heart-pop { 0% { transform: scale(1); } 50% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* ── Wishlist page ───────────────────────── */
.tf-wl-login-msg, .tf-wl-empty { padding: 30px 0; font-size: 15px; color: var(--tf-text-light); }
.tf-wl-login-msg a, .tf-wl-empty a { color: var(--tf-green); }

.tf-wishlist-grid { display: grid; grid-template-columns: repeat( auto-fill, minmax(200px, 1fr) ); gap: 24px; margin-top: 20px; }
.tf-wl-item { border: 1px solid var(--tf-border); border-radius: 8px; overflow: hidden; background: #fff; transition: box-shadow 0.2s; }
.tf-wl-item:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.tf-wl-image { position: relative; overflow: hidden; }
.tf-wl-image img { width: 100%; height: 200px; object-fit: cover; display: block; transition: transform 0.3s ease; }
.tf-wl-item:hover .tf-wl-image img { transform: scale(1.04); }
.tf-wl-remove {
    position: absolute; top: 8px; right: 8px; width: 28px; height: 28px;
    background: rgba(255,255,255,0.9); border: none; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: #999; transition: background 0.2s, color 0.2s; padding: 0;
}
.tf-wl-remove:hover { background: #fff; color: #c62828; }
.tf-wl-remove svg { width: 14px; height: 14px; }
.tf-wl-info { padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.tf-wl-name { font-size: 14px; font-weight: 600; color: var(--tf-text); text-decoration: none; line-height: 1.3; }
.tf-wl-name:hover { color: var(--tf-green); }
.tf-wl-price { font-size: 14px; color: var(--tf-green-dark); font-weight: 500; }
.tf-wl-cart {
    margin-top: 4px; display: inline-block; padding: 8px 14px;
    background: var(--tf-green); color: #fff !important;
    border-radius: var(--tf-radius); font-size: 13px; font-weight: 600;
    text-decoration: none !important; text-align: center;
    transition: background 0.2s; border: none; cursor: pointer; font-family: inherit;
}
.tf-wl-cart:hover { background: var(--tf-green-dark); }

/* ── No products ─────────────────────────── */
.tf-no-products { padding: 30px; text-align: center; color: var(--tf-text-light); font-size: 14px; }
