/* ===== Books listing: search + sort sidebar panel ===== */
.books-filter {
    --bf-accent: var(--first-color, #008375);
    --bf-surface: var(--body-box-color, #fff);
    --bf-text: var(--title-color, #0f172a);
    --bf-muted: var(--text-color, #64748b);
    --bf-border: rgba(0, 131, 117, 0.16);
    --bf-soft: color-mix(in srgb, var(--bf-accent) 9%, transparent);
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    border-radius: 1rem;
    background: var(--bf-surface);
    border: 1px solid var(--bf-border);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

body.dark-theme .books-filter,
html.dark-theme .books-filter {
    --bf-border: rgba(0, 212, 187, 0.22);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.books-filter__head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.85rem;
    color: var(--bf-accent);
    font-size: 0.92rem;
    font-weight: 700;
}

.books-filter__head i {
    font-size: 1.05rem;
}

.books-filter__search {
    position: relative;
    display: block;
    margin-bottom: 0.85rem;
}

.books-filter__search > i.bi-search {
    position: absolute;
    top: 50%;
    right: 0.85rem;
    transform: translateY(-50%);
    color: var(--bf-accent);
    font-size: 1rem;
    pointer-events: none;
}

.books-filter__input {
    width: 100%;
    padding: 0.72rem 2.5rem 0.72rem 2.35rem;
    border-radius: 0.8rem;
    border: 1px solid var(--bf-border);
    background: color-mix(in srgb, var(--bf-surface) 92%, var(--bf-soft));
    color: var(--bf-text);
    font-family: var(--body-font, inherit);
    font-size: 0.9rem;
    font-weight: 560;
    line-height: 1.4;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.books-filter__input::placeholder {
    color: var(--bf-muted);
    font-weight: 500;
    opacity: 0.9;
}

.books-filter__input:hover {
    border-color: color-mix(in srgb, var(--bf-accent) 45%, transparent);
}

.books-filter__input:focus {
    outline: none;
    border-color: var(--bf-accent);
    box-shadow: 0 0 0 3px rgba(0, 131, 117, 0.16);
    background: var(--bf-surface);
}

.books-filter__clear {
    position: absolute;
    top: 50%;
    left: 0.45rem;
    transform: translateY(-50%);
    width: 1.7rem;
    height: 1.7rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--bf-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.books-filter__clear:hover,
.books-filter__clear:focus-visible {
    background: var(--bf-soft);
    color: var(--bf-accent);
    outline: none;
}

.books-filter__clear[hidden] {
    display: none !important;
}

.books-filter__label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--bf-muted);
    font-size: 0.78rem;
    font-weight: 650;
}

.books-filter__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.books-filter__chip {
    appearance: none;
    border: 1px solid var(--bf-border);
    background: transparent;
    color: var(--bf-text);
    border-radius: 999px;
    padding: 0.38rem 0.72rem;
    font-size: 0.78rem;
    font-weight: 650;
    line-height: 1.3;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.books-filter__chip:hover {
    border-color: color-mix(in srgb, var(--bf-accent) 50%, transparent);
    background: var(--bf-soft);
    color: var(--bf-accent);
}

.books-filter__chip.is-active {
    background: var(--bf-accent);
    border-color: var(--bf-accent);
    color: #fff;
    box-shadow: 0 6px 14px rgba(0, 131, 117, 0.22);
}

.books-filter__chip:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 131, 117, 0.18);
}

.books-filter__chip:active {
    transform: scale(0.98);
}

@media (prefers-reduced-motion: reduce) {
    .books-filter__input,
    .books-filter__chip,
    .books-filter__clear {
        transition: none;
    }
}

/* Mobile category bottom sheet — desktop list-group stays unchanged */
.books-cat-sheet-trigger {
    display: none;
}

.books-cat-sheet {
    display: none;
}

@media (max-width: 767.98px) {
    .books-categories-nav {
        display: none !important;
    }

    .books-cat-sheet-trigger {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0.7rem;
        width: 100%;
        min-height: 48px;
        margin: 0 0 0.85rem;
        padding: 0 1rem;
        border: 1px solid var(--bf-border, rgba(0, 131, 117, 0.16));
        border-radius: 1rem;
        background: var(--body-box-color, #fff);
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
        color: var(--title-color, #0f172a);
        font-size: 0.92rem;
        font-weight: 700;
        text-align: start;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.2s ease, border-color 0.2s ease, transform 0.18s ease, box-shadow 0.2s ease;
    }

    .books-cat-sheet-trigger__icon {
        color: var(--first-color, #008375);
        font-size: 1.1rem;
        line-height: 1;
    }

    .books-cat-sheet-trigger:hover,
    .books-cat-sheet-trigger:focus-visible {
        border-color: var(--first-color, #008375);
        box-shadow: 0 0 0 3px rgba(0, 131, 117, 0.16);
        outline: none;
    }

    .books-cat-sheet-trigger:active {
        transform: scale(0.985);
        background: color-mix(in srgb, var(--first-color, #008375) 8%, #ffffff);
    }

    body.dark-theme .books-cat-sheet-trigger,
    html.dark-theme .books-cat-sheet-trigger {
        background: var(--body-box-color, #1e1e1e);
        border-color: rgba(0, 212, 187, 0.22);
        color: var(--title-color, #f8fafc);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    }

    body.dark-theme .books-cat-sheet-trigger:active,
    html.dark-theme .books-cat-sheet-trigger:active {
        background: color-mix(in srgb, var(--first-color, #00d4bb) 18%, #1e1e1e);
    }

    .books-filter {
        margin-top: 0;
    }

    .books-cat-sheet {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 2000;
        pointer-events: none;
    }

    .books-cat-sheet.is-open {
        pointer-events: auto;
    }

    .books-cat-sheet[hidden] {
        display: none !important;
    }

    .books-cat-sheet__backdrop {
        position: absolute;
        inset: 0;
        z-index: 1;
        background: rgba(8, 28, 26, 0.46);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        opacity: 0;
        transition: opacity 0.28s ease;
    }

    .books-cat-sheet.is-open .books-cat-sheet__backdrop {
        opacity: 1;
    }

    .books-cat-sheet__panel {
        position: absolute;
        inset-inline: 0;
        bottom: 0;
        z-index: 2;
        width: 100%;
        max-height: min(82vh, 640px);
        display: flex;
        flex-direction: column;
        border-radius: 24px 24px 0 0;
        background: linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.96) 0%,
            rgba(244, 250, 248, 0.98) 100%
        );
        backdrop-filter: blur(22px) saturate(1.35);
        -webkit-backdrop-filter: blur(22px) saturate(1.35);
        box-shadow: 0 -16px 48px rgba(0, 131, 117, 0.16);
        border: 1px solid rgba(255, 255, 255, 0.55);
        border-bottom: 0;
        padding-bottom: 0.5rem;
        transform: translate3d(0, 100%, 0);
        transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
        will-change: transform;
    }

    .books-cat-sheet.is-open .books-cat-sheet__panel {
        transform: translate3d(0, 0, 0);
    }

    body.dark-theme .books-cat-sheet__panel,
    html.dark-theme .books-cat-sheet__panel {
        background: linear-gradient(
            180deg,
            rgba(28, 42, 40, 0.9) 0%,
            rgba(18, 26, 25, 0.96) 100%
        );
        border-color: rgba(255, 255, 255, 0.08);
        box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.38);
    }

    .books-cat-sheet__handle {
        width: 42px;
        height: 5px;
        margin: 0.45rem auto 0;
        border-radius: 99px;
        background: color-mix(in srgb, var(--first-color, #008375) 28%, #d5e8e4);
    }

    body.dark-theme .books-cat-sheet__handle,
    html.dark-theme .books-cat-sheet__handle {
        background: rgba(255, 255, 255, 0.28);
    }

    .books-cat-sheet__header {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.2rem 0.9rem 0.35rem;
        min-height: 44px;
    }

    .books-cat-sheet__title {
        flex: 1;
        margin: 0;
        font-size: 1rem;
        font-weight: 700;
        color: var(--title-color, #0f172a);
        line-height: 1.4;
        transition: opacity 0.22s ease, transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .books-cat-sheet__back,
    .books-cat-sheet__close {
        width: 40px;
        height: 40px;
        border: 0;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: color-mix(in srgb, var(--first-color, #008375) 10%, transparent);
        color: var(--first-color, #008375);
        flex-shrink: 0;
        cursor: pointer;
        transition: background 0.18s ease, transform 0.18s ease;
    }

    .books-cat-sheet__back[hidden] {
        visibility: hidden;
        display: inline-flex !important;
        pointer-events: none;
    }

    .books-cat-sheet__back:active,
    .books-cat-sheet__close:active {
        transform: scale(0.94);
        background: color-mix(in srgb, var(--first-color, #008375) 18%, transparent);
    }

    .books-cat-sheet__body {
        position: relative;
        overflow: hidden;
        padding: 0 0.85rem 0.75rem;
    }

    .books-cat-sheet__viewport {
        --books-cat-row-h: 52px;
        --books-cat-row-gap: 0.4rem;
        position: relative;
        box-sizing: border-box;
        height: calc(var(--books-cat-row-h) * 5 + var(--books-cat-row-gap) * 4);
        min-height: calc(var(--books-cat-row-h) * 5 + var(--books-cat-row-gap) * 4);
        max-height: calc(var(--books-cat-row-h) * 5 + var(--books-cat-row-gap) * 4);
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .books-cat-sheet__viewport::-webkit-scrollbar {
        width: 0;
        height: 0;
        display: none;
    }

    .books-cat-sheet__more {
        position: absolute;
        inset-inline: 0.85rem;
        bottom: 0.75rem;
        z-index: 4;
        height: 2.1rem;
        display: flex;
        align-items: flex-end;
        justify-content: center;
        pointer-events: none;
        opacity: 0;
        visibility: hidden;
        background: linear-gradient(
            180deg,
            rgba(244, 250, 248, 0) 0%,
            rgba(244, 250, 248, 0.92) 70%,
            rgba(244, 250, 248, 0.98) 100%
        );
        transform: translateY(4px);
        transition: opacity 0.22s ease, visibility 0.22s ease, transform 0.22s ease;
    }

    body.dark-theme .books-cat-sheet__more,
    html.dark-theme .books-cat-sheet__more {
        background: linear-gradient(
            180deg,
            rgba(18, 26, 25, 0) 0%,
            rgba(18, 26, 25, 0.88) 70%,
            rgba(18, 26, 25, 0.96) 100%
        );
    }

    .books-cat-sheet__more.is-visible {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .books-cat-sheet__more i {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: color-mix(in srgb, var(--first-color, #008375) 12%, #ffffff);
        color: var(--first-color, #008375);
        font-size: 1rem;
        box-shadow: 0 4px 12px rgba(0, 131, 117, 0.16);
        animation: books-cat-more-bounce 1.15s ease-in-out infinite;
    }

    body.dark-theme .books-cat-sheet__more i,
    html.dark-theme .books-cat-sheet__more i {
        background: color-mix(in srgb, var(--first-color, #00d4bb) 18%, #1e1e1e);
        color: var(--first-color, #00d4bb);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
    }

    @keyframes books-cat-more-bounce {
        0%, 100% { transform: translateY(0); }
        50% { transform: translateY(5px); }
    }

    .books-cat-sheet__list {
        display: flex;
        flex-direction: column;
        gap: var(--books-cat-row-gap, 0.4rem);
        width: 100%;
        min-height: 0;
        will-change: transform, opacity;
        transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.32s ease;
    }

    .books-cat-sheet__list.is-leaving {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        pointer-events: none;
    }

    .books-cat-sheet__list.is-entering {
        position: relative;
        z-index: 1;
    }

    .books-cat-row {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        box-sizing: border-box;
        width: 100%;
        margin: 0;
        min-height: var(--books-cat-row-h, 52px);
        height: var(--books-cat-row-h, 52px);
        max-height: var(--books-cat-row-h, 52px);
        flex-shrink: 0;
        overflow: hidden;
        padding: 0 0.85rem;
        border: 0;
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.72);
        color: var(--title-color, #0f172a);
        text-decoration: none;
        text-align: start;
        font-size: 0.95rem;
        font-weight: 600;
        box-shadow: 0 1px 8px rgba(0, 131, 117, 0.06);
        cursor: pointer;
        transition: background 0.18s ease, transform 0.18s ease, color 0.18s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .books-cat-row__icon {
        width: 34px;
        height: 34px;
        border-radius: 11px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: color-mix(in srgb, var(--first-color, #008375) 12%, transparent);
        color: var(--first-color, #008375);
        flex-shrink: 0;
    }

    .books-cat-row__label {
        flex: 1;
        line-height: 1.35;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .books-cat-row__chevron {
        color: var(--text-color, #64748b);
        font-size: 0.9rem;
    }

    .books-cat-row:hover,
    .books-cat-row:focus-visible {
        background: color-mix(in srgb, var(--first-color, #008375) 10%, #ffffff);
        color: var(--title-color, #0f172a);
        outline: none;
    }

    .books-cat-row:active {
        transform: scale(0.985);
        background: color-mix(in srgb, var(--first-color, #008375) 16%, #ffffff);
    }

    .books-cat-row.is-active {
        background: color-mix(in srgb, var(--first-color, #008375) 14%, #ffffff);
        box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--first-color, #008375) 28%, transparent);
    }

    body.dark-theme .books-cat-row,
    html.dark-theme .books-cat-row {
        background: rgba(255, 255, 255, 0.05);
        color: var(--title-color, #f8fafc);
        box-shadow: none;
    }

    body.dark-theme .books-cat-row:hover,
    body.dark-theme .books-cat-row:focus-visible,
    body.dark-theme .books-cat-row:active,
    body.dark-theme .books-cat-row.is-active,
    html.dark-theme .books-cat-row:hover,
    html.dark-theme .books-cat-row:focus-visible,
    html.dark-theme .books-cat-row:active,
    html.dark-theme .books-cat-row.is-active {
        background: color-mix(in srgb, var(--first-color, #00d4bb) 22%, transparent);
    }

    body.books-cat-sheet-open {
        overflow: hidden;
    }

    @media (prefers-reduced-motion: reduce) {
        .books-cat-sheet__list,
        .books-cat-sheet__title,
        .books-cat-sheet__more,
        .books-cat-sheet__more i {
            transition: none;
            animation: none;
        }
    }
}

@media (min-width: 768px) {
    .books-cat-sheet-trigger,
    .books-cat-sheet {
        display: none !important;
    }
}

/* Mobile books cards: compact horizontal layout */
@media (max-width: 575.98px) {
    #books-container > [class*="col-"] {
        margin-top: 0.75rem !important;
    }

    #books-container .style-box-books {
        display: grid;
        grid-template-columns: 72px minmax(0, 1fr);
        grid-template-areas:
            "image title"
            "image actions"
            "summary summary";
        gap: 0.35rem 0.75rem;
        align-items: start;
        padding: 0.7rem 0.75rem;
        border-radius: 14px;
        box-shadow: 0 1px 10px rgba(0, 0, 0, 0.06);
    }

    #books-container .style-box-books:hover,
    #books-container .style-box-books:active {
        transform: translateY(-5px);
        box-shadow: 0px 8px 25px rgba(0, 0, 0, 0.15);
    }

    #books-container .style-box-books .card__row,
    #books-container .style-box-books .card__head {
        display: contents;
    }

    #books-container .style-box-books .card__image {
        grid-area: image;
        width: 72px;
        margin-bottom: 0;
        border-radius: 8px;
        align-self: start;
    }

    #books-container .style-box-books .card__img {
        width: 72px;
        height: 96px;
        aspect-ratio: auto;
        object-fit: cover;
        display: block;
    }

    #books-container .style-box-books:hover .card__img,
    #books-container .style-box-books:active .card__img {
        transform: scale(1.05);
    }

    #books-container .style-box-books .card__book {
        grid-area: title;
        font-size: 0.95rem;
        margin: 0;
        line-height: 1.35;
        width: 100%;
        text-align: right;
        direction: rtl;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    #books-container .style-box-books .card__book i {
        font-size: 0.85rem;
        margin-top: 0;
    }

    #books-container .style-box-books .card__actions {
        grid-area: actions;
        margin-top: 0;
        padding-top: 0;
        align-self: end;
    }

    #books-container .style-box-books .card__author {
        font-size: 0.78rem;
        max-width: calc(100% - 42px);
        transform: none;
        text-align: start;
    }

    #books-container .style-box-books .card__button i {
        font-size: 1.35rem;
    }

    #books-container .style-box-books .card__summary {
        grid-area: summary;
        margin: 0.35rem 0 0;
        max-height: none;
        height: auto;
        -webkit-line-clamp: 3;
        font-size: 0.8rem;
        line-height: 1.55;
    }
}
