/**
 * Library block (reader) — from library9 structure.
 * Depends on page.css; overrides .library-* for accordion with subcategory/subgroup.
 */

/* --- Sidebar Tabs --- */
.sidebar-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid rgba(74, 150, 152, 0.15);
    margin-bottom: 16px;
}
.sidebar-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-gray);
    transition: all 0.25s ease;
    position: relative;
    white-space: nowrap;
}
.sidebar-tab-btn::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: transparent;
    transition: background 0.25s ease;
}
.sidebar-tab-btn:hover {
    color: var(--text-dark);
}
.sidebar-tab-btn.active {
    color: var(--teal);
}
.sidebar-tab-btn.active::after {
    background: var(--teal);
}
.sidebar-tab-btn svg {
    stroke: currentColor;
    flex-shrink: 0;
}
.sidebar-tab-panel {
    display: none;
}
.sidebar-tab-panel.active {
    display: block;
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    direction: ltr;
}
.sidebar-section-header .sidebar-section-title {
    margin-bottom: 0;
}
.lang-toggle {
    display: flex;
    align-items: center;
    background: rgba(74, 150, 152, 0.08);
    border-radius: 12px;
    padding: 2px;
    border: 1px solid rgba(74, 150, 152, 0.15);
}
.lang-toggle-btn {
    width: 26px;
    height: 22px;
    border: none;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-gray);
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lang-toggle-btn.active {
    background: var(--teal);
    color: var(--white);
    box-shadow: 0 1px 4px rgba(74, 150, 152, 0.3);
}
#library-dir-wrap .library-accordion {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.library-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(74, 150, 152, 0.1);
}
.library-actions a {
    font-size: 12px;
    color: var(--teal);
    text-decoration: none;
    font-weight: 600;
}
.library-actions a:hover {
    text-decoration: underline;
}
.library-category {
    border-radius: 10px;
    overflow: hidden;
    background: rgba(74, 150, 152, 0.04);
    border: 1px solid rgba(74, 150, 152, 0.1);
}
.library-category-header {
    width: 100%;
    padding: 12px 14px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    transition: all 0.3s ease;
    text-align: left;
    position: relative;
}
.library-category-header:hover {
    background: rgba(74, 150, 152, 0.08);
}
.library-category-header .category-icon {
    width: 22px;
    min-width: 22px;
    max-width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--teal);
    color: var(--white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Montserrat', sans-serif;
    font-size: 11px;
    font-weight: 700;
    flex: none;
    box-sizing: border-box;
}
.library-category-header > span[data-ru] {
    flex: 1;
}
.library-category-header > .chevron-icon {
    width: 16px;
    height: 16px;
    stroke: var(--text-gray);
    stroke-width: 2;
    fill: none;
    transition: transform 0.3s ease;
}
.library-category.expanded > .library-category-header > .chevron-icon {
    transform: rotate(180deg);
}
.library-category-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}
.library-category.expanded > .library-category-content {
    max-height: 5000px;
}
.library-subcategory {
    border-top: 1px solid rgba(74, 150, 152, 0.08);
}
.library-subcategory-header {
    width: 100%;
    padding: 9px 14px 9px 46px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-family: 'Montserrat', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--teal);
    transition: all 0.3s ease;
    text-align: left;
    position: relative;
}
.library-subcategory-header:hover {
    background: rgba(74, 150, 152, 0.06);
}
.library-subcategory-header > .chevron-icon {
    width: 14px;
    height: 14px;
    stroke: var(--text-gray);
    fill: none;
    transition: transform 0.3s ease;
}
.library-subcategory.expanded > .library-subcategory-header > .chevron-icon {
    transform: rotate(180deg);
}
.library-subcategory-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}
.library-subcategory.expanded > .library-subcategory-content {
    max-height: 3000px;
}
.library-subgroup {
    border-top: 1px solid rgba(74, 150, 152, 0.05);
}
.library-subgroup-header {
    width: 100%;
    padding: 8px 14px 8px 46px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-family: 'Open Sans', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-gray);
    transition: all 0.3s ease;
    text-align: left;
    position: relative;
}
.library-subgroup-header > .chevron-icon {
    width: 12px;
    height: 12px;
    stroke: var(--text-gray);
    fill: none;
    transition: transform 0.25s ease;
}
.library-subgroup.expanded > .library-subgroup-header > .chevron-icon {
    transform: rotate(180deg);
}
.library-subgroup-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.library-subgroup.expanded > .library-subgroup-content {
    max-height: 2000px;
}
.library-book {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 10px 62px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 13px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}
.library-book:hover {
    background: rgba(74, 150, 152, 0.06);
    border-left-color: var(--teal);
}
.library-book.active {
    background: var(--yellow);
    border-left-color: var(--teal);
    font-weight: 600;
}
.library-book .book-hebrew {
    font-size: 11px;
    color: var(--text-gray);
    opacity: 0.8;
    direction: rtl;
}
.library-category.has-active {
    border-color: rgba(74, 150, 152, 0.45);
    background: rgba(74, 150, 152, 0.07);
}
.library-category.has-active > .library-category-header {
    color: var(--teal);
}
.library-subcategory.has-active > .library-subcategory-header {
    color: var(--teal);
    background: rgba(74, 150, 152, 0.06);
}
.library-subgroup.has-active > .library-subgroup-header {
    color: var(--text-dark);
    background: rgba(252, 221, 109, 0.25);
}
#library-dir-wrap[dir="rtl"] {
    direction: rtl;
    text-align: right;
}
#library-dir-wrap[dir="rtl"] .library-subcategory-header {
    padding: 9px 46px 9px 14px;
}
#library-dir-wrap[dir="rtl"] .library-subgroup-header {
    padding: 8px 46px 8px 14px;
}
#library-dir-wrap[dir="rtl"] .library-book {
    flex-direction: row-reverse;
    padding: 10px 62px 10px 14px;
    border-left: none;
    border-right: 3px solid transparent;
}
#library-dir-wrap[dir="rtl"] .library-book:hover,
#library-dir-wrap[dir="rtl"] .library-book.active {
    border-right-color: var(--teal);
}
