/* com_books front-end
   Re-theme by overriding the variables on .bks-wrapper in your template CSS. */
.bks-wrapper {
    --bk-accent: #12a89d;
    --bk-accent-dark: #0d8a81;
    --bk-ink: #1f2d3d;
    --bk-muted: #6b7785;
    --bk-line: #dde3e8;
    --bk-title-bg: #eaf6fb;
    --bk-strip-bg: #f1f9fc;
    --bk-card: #fff;
    --bk-link: #4a45b1;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
    color: var(--bk-ink);
}
.bks-wrapper *, .bks-wrapper *::before, .bks-wrapper *::after { box-sizing: border-box; }

/* ---------- Toolbar ---------- */
.bks-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 22px;
    padding: 12px;
    background: var(--bk-strip-bg);
    border: 1px solid var(--bk-line);
    border-radius: 10px;
}
.bks-search { display: flex; flex: 1 1 340px; min-width: 240px; gap: 6px; }
.bks-search-input {
    min-width: 0;
    flex: 1 1 auto;
    height: 42px;
    border: 1px solid var(--bk-line);
    border-radius: 999px;
    padding: 0 18px;
    background: #fff;
}
.bks-search-input:focus { border-color: var(--bk-accent); box-shadow: 0 0 0 3px rgba(18, 168, 157, .2); outline: 0; }

.bks-search-btn,
.bks-clear-search {
    height: 42px;
    padding: 0 20px;
    border-radius: 999px;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    font-weight: 700;
    font-size: 14px;
    transition: background-color .18s ease, box-shadow .18s ease;
}
.bks-search-btn { border: 0; background: var(--bk-accent); color: #fff; }
.bks-search-btn:hover, .bks-search-btn:focus { background: var(--bk-accent-dark); box-shadow: 0 4px 12px rgba(18, 168, 157, .35); }
.bks-clear-search { border: 1px solid var(--bk-line); color: var(--bk-muted); background: #fff; }
.bks-clear-search:hover { color: var(--bk-ink); border-color: var(--bk-accent); }

.bks-filter { display: flex; align-items: center; gap: 8px; }
.bks-filter-label { margin: 0; font-weight: 700; color: var(--bk-muted); font-size: 14px; white-space: nowrap; }
.bks-filter-select {
    min-width: 170px;
    height: 42px;
    padding: 6px 34px 6px 14px;
    border: 1px solid var(--bk-line);
    border-radius: 999px;
    font-size: 14px;
    color: #222 !important;
    background-color: #fff !important;
}
.bks-filter-select--year { min-width: 120px; }
.bks-filter-select:focus { border-color: var(--bk-accent); box-shadow: 0 0 0 3px rgba(18, 168, 157, .2); outline: 0; }
.bks-filter-select option { color: #222 !important; background: #fff !important; }

.bks-result-info { margin: -6px 0 16px; color: var(--bk-muted); font-size: 14px; }

/* ---------- Book card ---------- */
.bks-list { display: flex; flex-direction: column; gap: 18px; }

.bks-card {
    padding: 20px 20px 16px;
    background: var(--bk-card);
    border: 1px solid var(--bk-line);
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

/* Title bar with the thin strip under it */
.bks-card-title {
    position: relative;
    margin: 0 0 30px;
    padding: 20px 20px;
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.7;
    text-align: right;
    background: var(--bk-title-bg);
    border-right: 4px solid var(--bk-accent);
}
.bks-card-title::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    bottom: -17px;
    height: 10px;
    background: var(--bk-strip-bg);
    border-right: 4px solid var(--bk-accent);
}
.bks-card-title a { color: inherit; text-decoration: none; }
.bks-card-title a:hover, .bks-card-title a:focus { color: var(--bk-accent-dark); text-decoration: none; }

.bks-subtitle { margin: -10px 0 22px; padding-right: 24px; color: var(--bk-muted); font-size: 1.05rem; line-height: 1.8; }

.bks-card-body { display: flex; align-items: flex-start; gap: 20px; margin-top: 4px; }

.bks-cover { flex: 0 0 150px; width: 150px; display: block; line-height: 0; }
.bks-cover img {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border: 1px solid var(--bk-line);
    background: #f3f5f7;
    border-radius: 2px;
}
.bks-cover--large { flex-basis: 220px; width: 220px; }

.bks-info { flex: 1 1 auto; min-width: 0; text-align: right; }

.bks-meta { margin: 0; padding: 0 22px 0 0; list-style: disc; }
.bks-meta li { margin: 0 0 6px; line-height: 1.9; font-size: 14.5px; }
.bks-meta li strong { font-weight: 700; margin-inline-start: 2px; }
.bks-meta a { color: var(--bk-link); text-decoration: none; }
.bks-meta a:hover { text-decoration: underline; }

.bks-desc {
    margin: 16px 0 0;
    padding: 4px 16px 4px 0;
    border-right: 3px solid #e4e7ea;
    color: #7b8490;
    font-size: 14.5px;
    line-height: 2;
    text-align: justify;
}

/* ---------- Footer: "read more" + buttons ---------- */
.bks-card-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;   /* RTL: left side, like the reference design */
    gap: 8px;
    margin-top: 16px;
}

.bks-more {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 10px;
    border: 1px solid var(--bk-accent);
    border-radius: 4px;
    background: #fff;
    color: #222;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.7;
    text-decoration: none;
}
.bks-more span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bks-more:hover, .bks-more:focus { background: var(--bk-title-bg); color: #000; text-decoration: none; }
.bks-icon { flex: 0 0 auto; color: var(--bk-accent-dark); }

.bks-btn,
.bks-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 4px 16px;
    border: 1px solid var(--bk-accent);
    border-radius: 4px;
    background: #fff;
    color: var(--bk-accent-dark);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.5;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .18s ease, color .18s ease, box-shadow .18s ease;
}
.bks-btn:hover, .bks-btn:focus { background: var(--bk-title-bg); color: var(--bk-accent-dark); text-decoration: none; }
.bks-btn--solid { background: var(--bk-accent); color: #fff; }
.bks-btn--solid:hover, .bks-btn--solid:focus { background: var(--bk-accent-dark); color: #fff; box-shadow: 0 4px 12px rgba(18, 168, 157, .3); }

.bks-back { margin-bottom: 14px; border-color: var(--bk-line); color: var(--bk-muted); }
.bks-back:hover, .bks-back:focus { border-color: var(--bk-accent); color: var(--bk-accent-dark); text-decoration: none; }

/* ---------- Single book ---------- */
.bks-card--single { padding: 22px 24px 26px; }
.bks-card--single .bks-card-title { font-size: 1.6rem; }
.bks-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.bks-section { margin-top: 32px; }
.bks-section-title {
    margin: 0 0 12px;
    padding: 8px 14px;
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--bk-title-bg);
    border-right: 4px solid var(--bk-accent);
}
.bks-richtext { line-height: 2.05; text-align: justify; }
.bks-richtext table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.bks-richtext th, .bks-richtext td { border: 1px solid var(--bk-line); padding: 6px 10px; }

/* ---------- Empty state & pagination ---------- */
.bks-empty { padding: 28px; text-align: center; color: var(--bk-muted); border: 1px dashed var(--bk-line); border-radius: 8px; background: var(--bk-strip-bg); }

.bks-pagination { margin-top: 26px; display: flex; justify-content: center; }
.bks-pagination .pagination { margin: 0; flex-wrap: wrap; gap: 4px; }
.bks-pagination .page-link { min-width: 38px; text-align: center; border-radius: 8px !important; color: var(--bk-accent-dark); border-color: var(--bk-line); }
.bks-pagination .page-item.active .page-link { background: var(--bk-accent); border-color: var(--bk-accent); color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 767.98px) {
    .bks-toolbar { display: block; }
    .bks-search, .bks-filter { width: 100%; margin-bottom: 10px; }
    .bks-filter-select { flex: 1 1 auto; min-width: 0; width: 100%; }
    .bks-card { padding: 14px 12px 12px; }
    .bks-card-title { font-size: 1.15rem; padding: 14px 14px; margin-bottom: 26px; }
    .bks-card-body { flex-direction: column; align-items: stretch; gap: 14px; }
    .bks-cover, .bks-cover--large { align-self: center; flex-basis: auto; width: 150px; }
    .bks-card-foot { justify-content: stretch; }
    .bks-more { flex: 1 1 100%; }
    .bks-card--single { padding: 14px 12px 18px; }
    .bks-subtitle { padding-right: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .bks-btn, .bks-search-btn { transition: none; }
}

/* ---------- Active filter chips ---------- */
.bks-active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: -6px 0 18px;
    font-size: 14px;
    color: var(--bk-muted);
}
.bks-chip {
    display: inline-flex;
    gap: 4px;
    padding: 3px 12px;
    border: 1px solid var(--bk-accent);
    border-radius: 999px;
    background: var(--bk-title-bg);
    color: var(--bk-ink);
}
.bks-chip-clear { color: var(--bk-accent-dark); font-weight: 700; text-decoration: none; }
.bks-chip-clear:hover { text-decoration: underline; }
.bks-meta a.bks-filter-link { color: var(--bk-link); }

/* ---------- Product-style gallery (single book) ---------- */
.bks-gallery { flex: 0 0 240px; width: 240px; max-width: 100%; }
.bks-gallery-main { display: block; line-height: 0; cursor: zoom-in; }
.bks-gallery-main img {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border: 1px solid var(--bk-line);
    background: #f3f5f7;
    border-radius: 3px;
}
.bks-gallery-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.bks-gallery-thumbs li { margin: 0; width: calc((100% - 24px) / 4); }
.bks-gallery-thumb {
    display: block;
    width: 100%;
    padding: 0;
    border: 2px solid var(--bk-line);
    border-radius: 3px;
    background: #fff;
    line-height: 0;
    cursor: pointer;
    overflow: hidden;
}
.bks-gallery-thumb img { width: 100%; aspect-ratio: 1 / 1.4; object-fit: cover; display: block; }
.bks-gallery-thumb:hover, .bks-gallery-thumb:focus-visible { border-color: var(--bk-accent); outline: 0; }
.bks-gallery-thumb.is-active { border-color: var(--bk-accent); box-shadow: 0 0 0 1px var(--bk-accent); }

/* ---------- Lightbox ---------- */
.bks-lb-open { overflow: hidden; }
.bks-lb {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 56px 64px 12px;
    background: rgba(10, 14, 20, .92);
}
.bks-lb[hidden] { display: none; }
.bks-lb-stage { flex: 1 1 auto; min-height: 0; width: 100%; margin: 0; display: flex; align-items: center; justify-content: center; }
.bks-lb-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 2px; box-shadow: 0 8px 40px rgba(0, 0, 0, .5); }
.bks-lb-count { margin-top: 8px; color: #cfd6dd; font-size: 13px; direction: ltr; unicode-bidi: isolate; }
.bks-lb-strip { display: flex; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; max-width: 100%; overflow-x: auto; }
.bks-lb-strip li { flex: 0 0 auto; margin: 0; }
.bks-lb-strip button { display: block; width: 46px; padding: 0; border: 2px solid transparent; border-radius: 3px; background: none; opacity: .6; cursor: pointer; line-height: 0; overflow: hidden; }
.bks-lb-strip button img { width: 100%; aspect-ratio: 1 / 1.4; object-fit: cover; display: block; }
.bks-lb-strip button:hover, .bks-lb-strip button.is-active { opacity: 1; border-color: #fff; }

.bks-lb-btn {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
}
.bks-lb-btn:hover, .bks-lb-btn:focus-visible { background: rgba(255, 255, 255, .3); outline: 0; }
.bks-lb-close { top: 10px; inset-inline-end: 12px; font-size: 32px; }
.bks-lb-prev, .bks-lb-next { top: 50%; transform: translateY(-50%); }
.bks-lb-btn.is-left { left: 10px; }
.bks-lb-btn.is-right { right: 10px; }

@media (max-width: 767.98px) {
    .bks-gallery { align-self: center; flex-basis: auto; width: 220px; }
    .bks-lb { padding: 52px 8px 8px; }
    .bks-lb-prev, .bks-lb-next { top: auto; bottom: 64px; transform: none; width: 40px; height: 40px; }
}

/* ---------- Layout switch (list / grid) ---------- */
.bks-layout-switch { display: flex; justify-content: flex-end; gap: 6px; margin: 0 0 14px; }
.bks-layout-switch[hidden] { display: none; }
.bks-layout-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 4px 14px;
    border: 1px solid var(--bk-line);
    border-radius: 999px;
    background: #fff;
    color: var(--bk-muted);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.bks-layout-btn:hover, .bks-layout-btn:focus-visible { border-color: var(--bk-accent); color: var(--bk-accent-dark); outline: 0; }
.bks-layout-btn[aria-pressed="true"] { background: var(--bk-accent); border-color: var(--bk-accent); color: #fff; }

/* ---------- Grid layout ---------- */
.bks-list[data-layout="grid"] {
    display: grid;
    grid-template-columns: repeat(var(--bks-cols, 3), minmax(0, 1fr));
    gap: 18px;
    align-items: stretch;
}
.bks-list[data-layout="grid"] .bks-card { display: flex; flex-direction: column; padding: 14px 14px 12px; }
.bks-list[data-layout="grid"] .bks-card-title {
    order: 2;
    margin: 14px 0 0;
    padding: 10px 12px;
    font-size: 1rem;
    line-height: 1.8;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.bks-list[data-layout="grid"] .bks-card-title::after { display: none; }
.bks-list[data-layout="grid"] .bks-card-body { display: contents; }
.bks-list[data-layout="grid"] .bks-cover { order: 1; width: 62%; max-width: 190px; margin: 0 auto; }
.bks-list[data-layout="grid"] .bks-info { order: 3; margin-top: 0; }
.bks-list[data-layout="grid"] .bks-meta { margin-top: 12px; padding-right: 18px; }
.bks-list[data-layout="grid"] .bks-meta li { font-size: 13.5px; line-height: 1.8; margin-bottom: 3px; }
/* Compact cards: keep the essentials, the rest is on the book page. */
.bks-list[data-layout="grid"] .bks-desc,
.bks-list[data-layout="grid"] .bks-meta-isbn,
.bks-list[data-layout="grid"] .bks-meta-pages { display: none; }
.bks-list[data-layout="grid"] .bks-card-foot { order: 4; margin-top: auto; padding-top: 12px; justify-content: stretch; }
.bks-list[data-layout="grid"] .bks-more { flex: 1 1 100%; justify-content: center; }
.bks-list[data-layout="grid"] .bks-more-title { display: none; }
.bks-list[data-layout="grid"] .bks-btn { flex: 1 1 auto; }

@media (max-width: 991.98px) {
    .bks-list[data-layout="grid"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 519.98px) {
    .bks-list[data-layout="grid"] { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Bar under the title of a single book ---------- */
.bks-card.bks-has-topbar .bks-card-title { margin-bottom: 0; }
.bks-card.bks-has-topbar .bks-card-title::after { display: none; }
.bks-card--single .bks-subtitle { margin: 0; padding: 10px 24px 0 0; }
.bks-topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin: 8px 0 22px;
    padding: 8px 14px;
    background: var(--bk-strip-bg);
    border-right: 4px solid var(--bk-accent);
    font-size: 13.5px;
    color: var(--bk-muted);
}
.bks-topmeta { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; padding: 0; list-style: none; }
.bks-topmeta li { display: inline-flex; align-items: center; gap: 5px; line-height: 1.9; }
.bks-topmeta a { color: var(--bk-link); text-decoration: none; }
.bks-topmeta a:hover { text-decoration: underline; }
.bks-topmeta-value { color: var(--bk-ink); font-weight: 600; }
.bks-topicon { flex: 0 0 auto; color: var(--bk-accent-dark); opacity: .9; }
.bks-crumb-sep { margin: 0 3px; color: var(--bk-muted); }
.bks-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.bks-tool {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 11px;
    border: 1px solid var(--bk-line);
    border-radius: 999px;
    background: #fff;
    color: var(--bk-ink);
    font: inherit;
    font-size: 13px;
    line-height: 1.7;
    text-decoration: none;
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease;
}
.bks-tool:hover, .bks-tool:focus { border-color: var(--bk-accent); background: var(--bk-title-bg); color: var(--bk-accent-dark); text-decoration: none; }
.bks-tool.is-done { border-color: var(--bk-accent); color: var(--bk-accent-dark); }

@media (max-width: 767.98px) {
    .bks-card--single .bks-subtitle { padding-right: 14px; }
    .bks-topbar { padding: 8px 10px; }
}

/* ---------- Print ---------- */
@media print {
    .bks-noprint, .bks-gallery-thumbs, .bks-actions, .bks-lb { display: none !important; }
    .bks-wrapper { color: #000; }
    .bks-card { box-shadow: none !important; border-color: #999 !important; }
    .bks-topbar { background: none; border-right-color: #999; }
    .bks-topmeta a, .bks-meta a { color: #000; text-decoration: none; }
    .bks-card-title { background: none !important; border-right-color: #999 !important; }
    .bks-card-title::after { display: none !important; }
}
.bks-print { max-width: 900px; margin: 0 auto; }

/* Bar in the list cards: lighter, and without tools in the grid */
.bks-card:not(.bks-card--single) .bks-topbar { margin: 8px 0 14px; padding: 5px 12px; font-size: 13px; }
.bks-list[data-layout="grid"] .bks-tools { display: none; }
.bks-list[data-layout="grid"] .bks-topbar { margin: 0 0 8px; padding: 4px 8px; }

/* ---------- Related books ---------- */
.bks-related { margin-top: 34px; }
.bks-related-grid { display: grid; grid-template-columns: repeat(var(--bks-rel-cols, 4), minmax(0, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; }
.bks-related-item { display: flex; flex-direction: column; gap: 6px; text-align: center; padding: 10px; border: 1px solid var(--bk-line); border-radius: 8px; background: var(--bk-card); }
.bks-related-item .bks-related-cover { display: block; line-height: 0; }
.bks-related-item img { width: 100%; max-width: 130px; aspect-ratio: 2 / 3; object-fit: cover; border: 1px solid var(--bk-line); border-radius: 2px; background: #f3f5f7; }
.bks-related-title { font-weight: 700; font-size: .95rem; line-height: 1.7; }
.bks-related-title a { color: var(--bk-ink); text-decoration: none; }
.bks-related-title a:hover { color: var(--bk-accent-dark); }
.bks-related-by { font-size: .85rem; color: var(--bk-muted); }
@media (max-width: 767.98px) { .bks-related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media print { .bks-related { display: none !important; } }
