/* kfbeta16 — filter (bộ lọc anime) */

#af-wrap, #af-wrap * { box-sizing: border-box; }

#af-wrap {
    max-width: 1360px;
    min-height: 60vh;
    margin: 0 auto;
    padding: 0;
    background: transparent;
    color: var(--text1);
    font-family: var(--font);
}

/* =====================================================================
   BẢNG LỌC
   ===================================================================== */
#af-filters {
    position: relative;
    z-index: 10;
    padding: 6px 14px;
    background: var(--bg2);
    border: 0;
    border-radius: var(--radius-lg);
}

#af-filters-body {
    max-height: 640px;
    overflow: hidden;
    opacity: 1;
    transition: max-height .28s ease, opacity .2s ease;
}
#af-filters-body.collapsed { max-height: 0; opacity: 0; }

.af-inline-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-height: 140px;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    overflow-y: auto;
    white-space: nowrap;
}
.af-inline-row:first-child { border-top: 0; }

.af-inline-label {
    flex-shrink: 0;
    width: 64px;
    min-width: 64px;
    padding: 8px 0 0;
    color: var(--text3);
    font-size: var(--fs-xs);
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.af-inline-tags {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 0;
    white-space: normal;
}

.af-tag {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    background: var(--bg3);
    border: 0;
    border-radius: var(--r-pill);
    color: var(--text2);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color var(--tr), color var(--tr);
}
.af-tag:hover { background: var(--bg4); color: var(--text1); }
.af-tag.active { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.af-tag.loading-skeleton {
    width: 58px;
    height: 32px;
    color: transparent;
    pointer-events: none;
    background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
    background-size: 200% 100%;
    animation: kf-shimmer 1.4s infinite linear;
}

@media (max-width: 599px) {
    .af-inline-row { flex-direction: column; gap: 4px; max-height: 180px; }
    .af-inline-label { width: auto; padding-top: 2px; }
    .af-tag { min-height: 34px; }
}

/* =====================================================================
   THANH BỘ LỌC ĐANG CHỌN
   ===================================================================== */
#af-active-bar {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 10px 14px;
    background: var(--bg2);
    border: 0;
    border-radius: var(--radius);
    color: var(--text2);
    font-size: 12px;
}
#af-active-bar.visible { display: flex; }
#af-active-bar > strong { color: var(--text3); font-size: var(--fs-xs); letter-spacing: .08em; text-transform: uppercase; }
#af-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.af-active-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 6px 0 11px;
    background: var(--accent-soft);
    border: 0;
    border-radius: var(--r-pill);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.af-active-chip button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border-radius: 50%;
    background: none;
    color: var(--accent);
    font-size: 15px;
    line-height: 1;
    opacity: .75;
}
.af-active-chip button:hover { background: var(--accent); color: var(--on-accent); opacity: 1; }

#af-clear-btn {
    margin-left: auto;
    height: 28px;
    padding: 0 12px;
    background: var(--bg3);
    border: 0;
    border-radius: var(--r-pill);
    color: var(--text2);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
#af-clear-btn:hover { background: var(--red); color: #fff; }

/* =====================================================================
   HEADER KẾT QUẢ
   ===================================================================== */
#af-results-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 0 14px;
}
#af-count { color: var(--text2); font-size: 13px; }
#af-count span { color: var(--accent); font-weight: 800; }

#af-toggle-btn,
#af-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    background: var(--bg3);
    border: 0;
    border-radius: var(--radius);
    color: var(--text2);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    transition: background-color var(--tr), color var(--tr);
}
#af-toggle-btn:hover,
#af-share-btn:hover { background: var(--bg4); color: var(--text1); }
#af-toggle-btn.active { background: var(--accent-soft); color: var(--accent); }
#af-toggle-btn svg { transition: transform .2s; }
#af-toggle-btn.active svg { transform: rotate(180deg); }

/* =====================================================================
   LƯỚI KẾT QUẢ
   ===================================================================== */
#af-grid-wrap { padding: 0; }

#af-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 10px;
}
@media (min-width: 560px)  { #af-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px)  { #af-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 14px; } }
@media (min-width: 1200px) { #af-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

.af-card {
    min-width: 0;
    background: var(--bg2);
    border: 0;
    border-radius: var(--radius);
    overflow: hidden;
    animation: af-fadein .25s ease both;
    -webkit-tap-highlight-color: transparent;
    transition: background-color var(--tr);
}
.af-card:hover { background: var(--bg3); }
.af-card:active { opacity: .85; }
.af-card a { display: block; color: inherit; text-align: left; text-decoration: none; }

.af-card-thumb {
    position: relative;
    display: block;
    aspect-ratio: var(--thumb-ratio);
    background: var(--bg3);
    overflow: hidden;
}
.af-card-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s ease;
}
@media (hover: hover) {
    .af-card:hover .af-card-thumb img { transform: scale(1.05); }
}
.af-card-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--bg5);
    font-size: 1.6rem;
}

.af-card-noti {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    max-width: calc(100% - 16px);
    padding: 3px 8px;
    background: var(--accent);
    border-radius: var(--r-sm);
    color: var(--on-accent);
    font-size: var(--fs-xs);
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.af-card-year {
    position: absolute;
    right: 8px;
    bottom: 8px;
    padding: 2px 7px;
    background: rgba(8, 9, 12, .82);
    border-radius: var(--r-sm);
    color: var(--text1);
    font-size: var(--fs-xs);
    font-weight: 700;
}

.af-card-body { padding: 10px 10px 12px; }
.af-card-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    min-height: calc(1.4em * 2);
    margin-bottom: 6px;
    color: var(--text1);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    overflow: hidden;
    word-break: break-word;
    transition: color var(--tr);
}
.af-card:hover .af-card-title { color: var(--accent); }
.af-card-meta {
    color: var(--text3);
    font-size: var(--fs-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.af-card-type {
    display: inline;
    margin-right: 6px;
    padding-right: 6px;
    border-right: 1px solid var(--border2);
    color: var(--accent2);
    font-size: inherit;
    font-weight: 700;
}

/* Skeleton */
.af-sk-card { background: var(--bg2); border: 0; border-radius: var(--radius); overflow: hidden; }
.af-sk-thumb,
.af-sk-line {
    background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
    background-size: 200% 100%;
    animation: kf-shimmer 1.4s infinite linear;
}
.af-sk-thumb { aspect-ratio: var(--thumb-ratio); }
.af-sk-line { height: 12px; margin: 12px 10px 0; border-radius: 4px; }
.af-sk-line.short { width: 55%; height: 10px; margin-bottom: 14px; }

/* =====================================================================
   PHÂN TRANG
   ===================================================================== */
#af-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 28px;
    padding: 0;
}
.af-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    background: var(--bg3);
    border: 0;
    border-radius: var(--radius);
    color: var(--text1);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color var(--tr), color var(--tr);
}
.af-page-btn:hover:not(:disabled) { background: var(--bg4); color: var(--accent); }
.af-page-btn.active { background: var(--accent); color: var(--on-accent); }
.af-page-btn.active:hover { background: var(--accent-hover) !important; color: var(--on-accent) !important; }
.af-page-btn:disabled { background: var(--bg2); color: var(--text3); opacity: .6; cursor: default; }
span.af-page-btn { background: transparent; color: var(--text3); }

.af-go-wrap { display: flex; align-items: center; gap: 6px; margin-left: 6px; }
.af-go-input {
    width: 56px;
    height: 40px;
    background: var(--bg);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    color: var(--text1);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    transition: border-color var(--tr);
}
.af-go-input:focus { border-color: var(--accent); }
#af-go-btn { background: var(--accent); color: var(--on-accent); }
#af-go-btn:hover { background: var(--accent-hover); color: var(--on-accent); }

/* Trạng thái rỗng */
#af-empty { display: none; padding: 60px 20px; color: var(--text3); text-align: center; }
#af-empty.visible { display: block; }
#af-empty svg { color: var(--bg5); }
#af-empty p { margin-top: 12px; font-size: var(--fs); }

@keyframes af-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes af-fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
