/**
 * Maktab Tahqiqiya — Custom Styles
 *
 * RTL-first design for Urdu/Arabic text with Bootstrap 5 RTL.
 * Default font: Jameel Noori Nastaleeq (same as Angular frontend)
 * Settings: CSS custom properties overridden by settings.js from localStorage
 */

/* ============================================================
 * CSS Custom Properties — defaults (overridden by settings.js)
 * ============================================================ */

:root {
    /* Font families */
    --urdu-font: 'Jameel';
    --arabic-font: 'noorehira';
    --english-font: 'Segoe UI';
    --quran-font: 'saleem_quranfont';
    --hadith-font: 'noorehira';

    /* Font sizes */
    --urdu-font-size: 20px;
    --arabic-font-size: 20px;
    --english-font-size: 16px;
    --quran-font-size: 28px;
    --hadith-font-size: 20px;

    /* Line height */
    --urdu-line-height: 2.2;

    /* Colors */
    --text-color: #000000;
    --bg-color: #ffffff;
    --highlight-color: #ffff00;
    --link-color: #0066cc;

    /* Display */
    --max-width: 900px;
}

/* Dark mode overrides */
.dark-mode {
    --text-color: #e0e0e0 !important;
    --bg-color: #1a1a2e !important;
}

/* ============================================================
 * Font Face Declarations — from Angular frontend
 * ============================================================ */

@font-face {
    font-family: 'Jameel';
    src: url('../fonts/urdu/Jameel-Noori-Nastaleeq.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Mehr Nastaliq Web';
    src: url('../fonts/mehr/Mehr_Nastaliq_Web.woff') format('woff'),
         url('../fonts/mehr/Mehr_Nastaliq_Web.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'saleem_quranfont';
    src: url('../fonts/arabic/PDMS_Saleem_QuranFont-signed.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'noorehira';
    src: url('../fonts/arabic/noorehira.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'KFGQPC_Naskh';
    src: url('../fonts/arabic/KFC_naskh.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'me_quran_font';
    src: url('../fonts/arabic/me_quran.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'usmanic_quranfont';
    src: url('../fonts/arabic/UthmanicHafs1 Ver09.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'sheherazade';
    src: url('../fonts/arabic/Scheherazade-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* ============================================================
 * Typography — Jameel Noori Nastaleeq as default
 * ============================================================ */

body {
    font-family: var(--urdu-font), 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', 'Noto Naskh Arabic', 'Amiri', 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    padding-top: 56px; /* Fixed navbar offset for all pages */
}

/* Apply Urdu font to all form elements and UI components */
input, textarea, select, button,
.btn, .form-control, .form-select, .form-check-label,
.nav-link, .dropdown-item, .list-group-item,
.card-title, .card-text, .modal-title, .modal-body,
h1, h2, h3, h4, h5, h6, p, span, a, label {
    font-family: var(--urdu-font), 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', 'Noto Naskh Arabic', 'Amiri', 'Segoe UI', sans-serif !important;
}

/* Book content — uses settings fonts */
.book-content .content-text {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: justify;
    font-family: var(--urdu-font), 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
    font-size: var(--urdu-font-size);
    line-height: var(--urdu-line-height);
    color: var(--text-color);
    background-color: var(--bg-color);
    max-width: var(--max-width);
}

/* Quran text — uses settings font */
.ayah-text-arabic, .quran-text, .arabic-ayah {
    font-family: var(--quran-font), 'noorehira', 'Amiri', serif !important;
    font-size: var(--quran-font-size);
}

/* Hadith Arabic — uses settings font */
.hadith-arabic, .arabic-text, .hadees-arabic {
    font-family: var(--hadith-font), 'noorehira', 'Amiri', serif !important;
    font-size: var(--hadith-font-size);
}

/* Hadith Urdu translation — uses settings font */
.hadith-urdu, .urdu-text, .hadees-urdu, .translation-text {
    font-family: var(--urdu-font), 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
    font-size: var(--urdu-font-size);
    line-height: var(--urdu-line-height);
}

/* Tafseer text — uses settings font */
.tafseer-content, .tafseer-text {
    font-family: var(--urdu-font), 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
    font-size: var(--urdu-font-size);
    line-height: var(--urdu-line-height);
}

/* Search highlights — uses settings color */
mark {
    background-color: var(--highlight-color) !important;
}

/* Links in content — uses settings color */
.book-content a, .content-text a {
    color: var(--link-color) !important;
}

/* Brailvi page content */
.brailvi-page-content {
    font-family: var(--urdu-font), 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
    font-size: var(--urdu-font-size);
    line-height: var(--urdu-line-height);
    color: var(--text-color);
    background-color: var(--bg-color);
}

/* ============================================================
 * Viewer Layout — fits in viewport
 * ============================================================ */

.viewer-layout {
    display: flex;
    height: calc(100vh - 56px); /* Subtract navbar height; body padding-top handles offset */
    overflow: hidden;
}

/* ============================================================
 * Viewer Sidebar — Enhanced with tabs
 * ============================================================ */

.viewer-sidebar {
    width: 280px;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    border-left: 1px solid #dee2e6;
    overflow: hidden;
}

.sidebar-header {
    padding: 12px;
    flex-shrink: 0;
    border-bottom: 1px solid #dee2e6;
}

/* Sidebar tabs */
#sidebarTabs {
    flex-shrink: 0;
    border-bottom: 1px solid #dee2e6;
    background: #fff;
}

#sidebarTabs .nav-link {
    padding: 8px 0;
    border: none;
    background: transparent;
    color: #6c757d;
}

#sidebarTabs .nav-link.active {
    color: #0d6efd;
    background: #f8f9fa;
    border-bottom: 2px solid #0d6efd;
}

#sidebarTabs .nav-link:hover {
    color: #0d6efd;
}

/* Sidebar tab content */
.sidebar-tab-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.sidebar-tab-content .tab-pane {
    height: 100%;
    overflow-y: auto;
}

/* Sidebar search box */
.sidebar-search-box {
    padding: 8px;
    border-bottom: 1px solid #dee2e6;
}

.sidebar-search-box .form-control {
    font-size: 0.85rem;
}

/* ============================================================
 * Category Tree — Collapsible tree structure
 * ============================================================ */

.cat-node {
    margin-bottom: 1px;
}

/* Tree category row (folder) */
.tree-category {
    position: relative;
}

.tree-toggle {
    width: 100%;
    text-align: right;
    color: #1a237e;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 6px 8px !important;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-start;
    direction: rtl;
    transition: background 0.15s ease;
}

.tree-toggle:hover {
    background: #e8eaf6;
    text-decoration: none;
    color: #0d47a1;
}

/* Chevron rotation on expand — RTL: bi-chevron-left points right (→) when closed, rotates to point down (↓) when expanded */
.tree-chevron {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    color: #6c757d;
}

.tree-toggle[aria-expanded="true"] .tree-chevron {
    transform: rotate(-90deg);
}

/* Folder icon for categories */
.tree-icon {
    font-size: 1rem;
    color: #ff9800;
    flex-shrink: 0;
}

.tree-toggle[aria-expanded="true"] .tree-icon {
    color: #f57c00;
}

/* Category label */
.tree-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
}

/* Book count badge */
.tree-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    flex-shrink: 0;
}

/* Collapsible children container */
.tree-children {
    border-right: 2px solid #e0e0e0;
    margin-right: 8px;
    padding-right: 4px;
}

/* Tree book link */
.tree-book-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    margin: 1px 0;
    border-radius: 4px;
    color: #495057;
    text-decoration: none;
    font-size: 0.85rem;
    direction: rtl;
    transition: background 0.15s ease, color 0.15s ease;
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
}

.tree-book-link:hover {
    background: #f5f5f5;
    color: #1a237e;
    text-decoration: none;
}

.tree-book-link.active {
    background: #e3f2fd !important;
    color: #1a237e !important;
    font-weight: 700;
}

/* Book icon */
.tree-book-icon {
    font-size: 0.8rem;
    color: #1976d2;
    flex-shrink: 0;
}

.tree-book-link.active .tree-book-icon {
    color: #0d47a1;
}

/* Book label */
.tree-book-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Active book check icon */
.tree-book-active {
    font-size: 0.85rem;
    color: #2e7d32;
    flex-shrink: 0;
}

/* Book type badge in category tree */
.tree-book-type-badge {
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 8px;
    color: #fff;
    flex-shrink: 0;
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    line-height: 1.4;
}

/* Book type colors matching Angular frontend */
.book-type-1 { background-color: #1976d2; } /* احمدی مسلمان کتب - primary blue */
.book-type-2 { background-color: #7b1fa2; } /* وہابی کتب - tertiary purple */
.book-type-3 { background-color: #c62828; } /* دوبندی کتب - error red */
.book-type-4 { background-color: #00838f; } /* اقبال متعلق تحقیق - secondary teal */
.book-type-5 { background-color: #2e7d32; } /* تفسیر قرآن - green */
.book-type-6 { background-color: #5d4037; } /* تفسیر دیگر - brown */

/* ============================================================
 * Title Tree — Collapsible book index (فہرست مضامین)
 * ============================================================ */

.title-node {
    margin-bottom: 1px;
}

/* Title tree item (parent with children) */
.tree-title-item {
    position: relative;
    padding-right: 4px !important; /* Space for chevron on right edge */
}

/* Title toggle button (chevron) — sits at right edge of parent item */
.title-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    padding: 2px 4px !important;
    color: #6c757d;
    z-index: 2;
    line-height: 1;
}

.title-toggle:hover {
    color: #1a237e;
}

/* Chevron rotation on expand — RTL */
.title-chevron {
    font-size: 0.65rem;
    transition: transform 0.2s ease;
    display: inline-block;
}

.title-toggle[aria-expanded="true"] .title-chevron {
    transform: rotate(-90deg);
}

/* Title link (both parent and leaf) */
.tree-title-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 24px 5px 8px; /* Extra right padding for chevron space */
    margin: 1px 0;
    border-radius: 4px;
    color: #495057;
    text-decoration: none;
    font-size: 0.85rem;
    direction: rtl;
    transition: background 0.15s ease, color 0.15s ease;
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    line-height: 1.8;
    position: relative;
}

.tree-title-link:hover {
    background: #f5f5f5;
    color: #1a237e;
    text-decoration: none;
}

.tree-title-link.active {
    background: #e8f5e9 !important;
    color: #2e7d32 !important;
    font-weight: 700;
    border-right: 3px solid #2e7d32;
    padding-right: 21px; /* 24px - 3px border = same visual content position */
}

/* Title icon */
.title-icon {
    font-size: 0.75rem;
    color: #1976d2;
    flex-shrink: 0;
}

.tree-title-link.active .title-icon {
    color: #2e7d32;
}

/* Title label — wrap long chapter titles instead of truncating */
.tree-title-label {
    flex: 1;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.6;
}

/* Title children container */
.title-children {
    border-right: 2px solid #e0e0e0;
    margin-right: 8px;
    padding-right: 4px;
}

/* Heading type styles */
.title-h1 .tree-title-link {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1a237e;
}

.title-h2 .tree-title-link {
    font-weight: 600;
    font-size: 0.9rem;
    color: #283593;
}

.title-h3 .tree-title-link {
    font-weight: 400;
    font-size: 0.85rem;
    color: #495057;
}

/* Legacy book-link (backward compatibility) */
.book-link {
    font-size: 0.8rem !important;
    padding: 3px 12px !important;
    border: none;
}

.book-link:hover {
    background: #e9ecef;
}

.book-link.active {
    background: #e3f2fd !important;
    color: #1a237e !important;
    font-weight: 700;
}

/* Title links */
.title-link {
    font-size: 0.85rem !important;
    border: none;
    border-radius: 4px;
    margin-bottom: 1px;
}

.title-link:hover {
    background: #e9ecef;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sidebar-nav .list-group-item {
    border: none;
    border-radius: 4px;
    margin-bottom: 2px;
    font-size: 0.9rem;
    padding: 6px 12px;
}

.sidebar-nav .list-group-item:hover {
    background-color: #e9ecef;
}

/* ============================================================
 * Book Info Header — Shows current book's title, author, category
 * ============================================================ */

.book-info-header {
    flex-shrink: 0;
    background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
    color: #fff;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 2px solid #0d47a1;
}

.book-info-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.book-info-icon i {
    font-size: 1.4rem;
    color: #fff;
}

.book-info-details {
    flex: 1;
    min-width: 0;
}

.book-info-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
}

.book-info-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.85);
}

.book-info-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

/* Book type in info header */
.book-info-type {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
}

.book-info-type.book-type-1 { background: rgba(25, 118, 210, 0.4); }
.book-info-type.book-type-2 { background: rgba(123, 31, 162, 0.4); }
.book-info-type.book-type-3 { background: rgba(198, 40, 40, 0.4); }
.book-info-type.book-type-4 { background: rgba(0, 131, 143, 0.4); }
.book-info-type.book-type-5 { background: rgba(46, 125, 50, 0.4); }
.book-info-type.book-type-6 { background: rgba(93, 64, 55, 0.4); }

.book-info-meta i {
    font-size: 0.75rem;
    opacity: 0.7;
}

.book-info-actions {
    flex-shrink: 0;
}

.book-info-actions .btn {
    color: rgba(255, 255, 255, 0.85);
    border-color: rgba(255, 255, 255, 0.3);
}

.book-info-actions .btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Active book highlight in category tree */
.sidebar-nav .book-link.active {
    background: #e3f2fd !important;
    color: #1a237e !important;
    font-weight: 700;
    border-right: 3px solid #1a237e;
}

.sidebar-nav .book-link.active:hover {
    background: #bbdefb !important;
}

/* ============================================================
 * Reader Controls — Navigation bar
 * ============================================================ */

.reader-controls {
    flex-shrink: 0;
    padding: 6px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: #fff;
    border-bottom: 1px solid #dee2e6;
}

.reader-controls .page-count {
    margin: 0 12px;
    min-width: 100px;
    text-align: center;
}

/* ============================================================
 * Viewer Toolbar — Enhanced
 * ============================================================ */

.viewer-toolbar {
    flex-shrink: 0;
    border-bottom: 1px solid #dee2e6;
    background: #fff;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.viewer-toolbar .divider {
    width: 1px;
    height: 20px;
    background: #dee2e6;
    margin: 0 4px;
}

/* Main content area */
.viewer-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Toolbar */
.viewer-toolbar {
    flex-shrink: 0;
    border-bottom: 1px solid #dee2e6;
    background: #fff;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Scrollable content area */
.viewer-content-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: #fff;
}

/* PDF viewer fills available space */
.pdf-viewer-container {
    height: 100%;
    width: 100%;
}

/* Text content padding */
.viewer-text-content {
    padding: 16px 24px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* Book content article — fit to viewport */
.book-content {
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', 'Amiri', serif;
    font-size: 1.5rem;
    line-height: 2.2;
    color: #212529;
    min-height: 0;
    /* Allow content to shrink to fit viewport */
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Bottom navigation */
.viewer-nav-bottom {
    flex-shrink: 0;
    border-top: 1px solid #dee2e6;
    background: #fff;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ============================================================
 * Custom Tags — Urdu/Arabic headings, Quran, Hadith, etc.
 * ============================================================ */

/* Urdu headings (urh1-urh8) */
.book-content h1.ur-h,
.book-content h2.ur-h,
.book-content h3.ur-h,
.book-content h4.ur-h,
.book-content h5.ur-h,
.book-content h6.ur-h {
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif;
    color: #1a5276;
    border-bottom: 2px solid #2980b9;
    padding-bottom: 6px;
    margin: 20px 0 12px 0;
    direction: rtl;
    text-align: right;
}

.book-content h1.ur-h { font-size: 1.8rem; border-bottom-width: 3px; }
.book-content h2.ur-h { font-size: 1.6rem; }
.book-content h3.ur-h { font-size: 1.4rem; }
.book-content h4.ur-h { font-size: 1.3rem; border-bottom-width: 1px; }
.book-content h5.ur-h { font-size: 1.2rem; border-bottom-style: dashed; }
.book-content h6.ur-h { font-size: 1.1rem; border-bottom-style: dotted; color: #2c3e50; }

/* Arabic headings (arh1-arh8) */
.book-content h1.ar-h,
.book-content h2.ar-h,
.book-content h3.ar-h,
.book-content h4.ar-h,
.book-content h5.ar-h,
.book-content h6.ar-h {
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif;
    color: #6c3483;
    border-bottom: 2px solid #8e44ad;
    padding-bottom: 6px;
    margin: 20px 0 12px 0;
    direction: rtl;
    text-align: right;
}

.book-content h1.ar-h { font-size: 1.8rem; border-bottom-width: 3px; }
.book-content h2.ar-h { font-size: 1.6rem; }
.book-content h3.ar-h { font-size: 1.4rem; }
.book-content h4.ar-h { font-size: 1.3rem; border-bottom-width: 1px; }
.book-content h5.ar-h { font-size: 1.2rem; border-bottom-style: dashed; }
.book-content h6.ar-h { font-size: 1.1rem; border-bottom-style: dotted; color: #7d3c98; }

/* Arabic inline text */
.book-content .ar-text {
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif;
    color: #6c3483;
    font-size: 1.1em;
}

/* Quran text */
.book-content .qr-text {
    font-family: 'saleem_quranfont', 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif;
    color: #1e8449;
    background: #eafaf1;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 1.15em;
    border-right: 3px solid #27ae60;
}

/* Hadith text */
.book-content .hd-text {
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif;
    color: #922b21;
    background: #fdedec;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 1.1em;
    border-right: 3px solid #e74c3c;
}

/* Urdu reference */
.book-content .ur-ref {
    color: #1a5276;
    font-size: 0.9em;
    font-style: italic;
    background: #eaf2f8;
    padding: 1px 4px;
    border-radius: 2px;
}

/* Arabic reference */
.book-content .ar-ref {
    font-family: 'Amiri', 'Noto Naskh Arabic', serif;
    color: #6c3483;
    font-size: 0.9em;
    font-style: italic;
    background: #f5eef8;
    padding: 1px 4px;
    border-radius: 2px;
}

/* ============================================================
 * Native Custom Tags — Rendered directly as HTML elements
 * (Matches Angular's DomSanitizer.bypassSecurityTrustHtml approach)
 * ============================================================ */

/* Urdu headings: <urh1>, <urh2> */
.book-content urh1,
.book-content urh2 {
    display: block;
    box-sizing: border-box;
    margin: 1.5rem 0 1rem 0;
    font-weight: 700;
    text-align: right;
    direction: rtl;
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
}

.book-content urh1:first-child,
.book-content urh2:first-child {
    margin-top: 0;
}

.book-content urh1 {
    font-size: 1.8rem;
    color: #1a5276;
    border-right: 3px solid #1a5276;
    padding-right: 0.75rem;
    padding-left: 0;
    margin-top: 1.5rem;
}

.book-content urh2 {
    font-size: 1.6rem;
    color: #2980b9;
    border-right: 2px solid #2980b9;
    padding-right: 0.5rem;
    padding-left: 0;
}

/* Arabic headings: <arh1>, <arh2> */
.book-content arh1,
.book-content arh2 {
    display: block;
    box-sizing: border-box;
    margin: 1.5rem 0 1rem 0;
    font-weight: 700;
    text-align: right;
    direction: rtl;
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
}

.book-content arh1:first-child,
.book-content arh2:first-child {
    margin-top: 0;
}

.book-content arh1 {
    font-size: 1.8rem;
    color: #6c3483;
    border-right: 3px solid #6c3483;
    padding-right: 0.75rem;
    padding-left: 0;
    margin-top: 1.5rem;
}

.book-content arh2 {
    font-size: 1.6rem;
    color: #8e44ad;
    border-right: 2px solid #8e44ad;
    padding-right: 0.5rem;
    padding-left: 0;
}

/* Urdu inline text: <ur> */
.book-content ur {
    display: inline;
    font-size: 1.5rem;
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
    color: #1a5276;
}

/* Arabic inline text: <ar> */
.book-content ar {
    display: inline;
    font-size: 1.5rem;
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
    color: #6c3483;
}

/* Quran text: <qr> */
.book-content qr {
    display: inline;
    font-size: 1.5rem;
    font-family: 'saleem_quranfont', 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
    color: #1e8449;
}

/* Hadith text: <hd> */
.book-content hd {
    display: inline;
    font-size: 1.5rem;
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
    color: #922b21;
}

/* Urdu verse: <urverse> */
.book-content urverse {
    display: block;
    font-size: 1.2rem;
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
    color: #1e8449;
    text-align: center;
    margin: 0.5rem 0;
}

/* Arabic reference: <arref> */
.book-content arref {
    display: inline;
    font-size: 1.2rem;
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
    color: #922b21;
}

/* Urdu reference: <urref> */
.book-content urref {
    display: inline;
    color: #1a5276;
    font-size: 0.9em;
    font-style: italic;
    background: #eaf2f8;
    padding: 1px 4px;
    border-radius: 2px;
}

/* English verse: <enverse> */
.book-content enverse {
    display: block;
    font-size: 1.1rem;
    color: #1a5276;
    text-align: center;
    margin: 0.5rem 0;
}

/* English reference: <enref> */
.book-content enref {
    display: inline;
    color: #1a5276;
    font-size: 0.9em;
    font-style: italic;
    direction: ltr;
}

/* English reference */
.book-content .en-ref {
    color: #1a5276;
    font-size: 0.9em;
    font-style: italic;
    direction: ltr;
    unicode-bidi: embed;
    background: #eaf2f8;
    padding: 1px 4px;
    border-radius: 2px;
}

/* Urdu verse */
.book-content .ur-verse {
    display: block;
    margin: 12px 20px;
    padding: 10px 16px;
    background: #fef9e7;
    border-right: 4px solid #f39c12;
    border-radius: 4px;
    font-style: italic;
}

/* Arabic verse */
.book-content .ar-verse {
    font-family: 'Amiri', 'Noto Naskh Arabic', serif;
    display: block;
    margin: 12px 20px;
    padding: 10px 16px;
    background: #eafaf1;
    border-right: 4px solid #27ae60;
    border-radius: 4px;
    font-size: 1.15em;
}

/* English verse */
.book-content .en-verse {
    display: block;
    margin: 12px 20px;
    padding: 10px 16px;
    background: #eaf2f8;
    border-right: 4px solid #2980b9;
    border-radius: 4px;
    font-style: italic;
    direction: ltr;
    unicode-bidi: embed;
}

/* ============================================================
 * Book Cards
 * ============================================================ */

.book-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.book-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.book-card .card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.book-card .card-title a:hover {
    color: #0d6efd !important;
}

/* Book thumbnail in card */
.book-thumbnail-wrapper {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #dee2e6;
}

.book-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
}

.book-thumbnail-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 3rem;
}


/* ============================================================
 * Navigation
 * ============================================================ */

.navbar-brand {
    font-family: 'Noto Nastaliq Urdu', serif;
    font-size: 1.4rem;
}

/* ============================================================
 * Pagination
 * ============================================================ */

.pagination .page-link {
    color: #0d6efd;
    border-radius: 4px;
    margin: 0 2px;
}

/* ============================================================
 * Search
 * ============================================================ */

.search-highlight {
    background-color: #fff3cd;
    padding: 1px 2px;
    border-radius: 2px;
}

/* Highlighted search snippets from backend <mark> tags */
mark, .mark {
    background-color: #fff3cd;
    color: #000;
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: bold;
}

/* Search result list items */
.list-group-item-action {
    transition: background-color 0.15s;
}

.list-group-item-action:hover {
    background-color: #f8f9fa;
}

/* Search scope tabs */
.nav-tabs .nav-link {
    color: #495057;
}

.nav-tabs .nav-link.active {
    color: #0d6efd;
    font-weight: 600;
}

.nav-tabs .nav-link i {
    margin-left: 4px;
}

/* ============================================================
 * Thumbnails
 * ============================================================ */

#thumbnailGrid .card {
    cursor: pointer;
    transition: border-color 0.2s;
}

#thumbnailGrid .card:hover {
    border-color: #0d6efd !important;
}

/* ============================================================
 * Auth Pages (Login, Register)
 * ============================================================ */

.auth-card .card-header {
    border-radius: 0.375rem 0.375rem 0 0 !important;
}

/* ============================================================
 * Favorites & Bookmarks
 * ============================================================ */

.favorite-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.favorite-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

/* ============================================================
 * Dictionary
 * ============================================================ */

.dictionary-card {
    transition: transform 0.2s;
}

.dictionary-card:hover {
    transform: translateY(-2px);
}

/* ============================================================
 * Admin Panel
 * ============================================================ */

.admin-stat-card {
    border-right: 4px solid #0d6efd;
}

/* ============================================================
 * Authoring
 * ============================================================ */

.authoring-action-card {
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.authoring-action-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12) !important;
}

/* Edit tabs */
#editTabs .nav-link {
    padding: 0.5rem 1rem;
}

#editTabs .nav-link.active {
    font-weight: 600;
    border-bottom-color: transparent;
}

.content-preview {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    line-height: 1.8;
}

/* ============================================================
 * Responsive
 * ============================================================ */

@media (max-width: 992px) {
    /* Hide sidebar on tablet, use offcanvas */
    .viewer-sidebar {
        display: none;
    }

    .viewer-layout {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .book-content {
        font-size: 1.1rem;
        line-height: 2;
    }

    .viewer-text-content {
        padding: 12px 16px;
    }

    .viewer-toolbar {
        flex-wrap: wrap;
        gap: 6px;
    }

    .viewer-nav-bottom {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    #bookSidebar {
        max-height: 300px;
    }

    .navbar-collapse {
        background-color: #343a40;
        padding: 1rem;
        border-radius: 0.5rem;
        margin-top: 0.5rem;
    }

    /* Custom tag responsive */
    .book-content h1.ur-h, .book-content h1.ar-h { font-size: 1.4rem; }
    .book-content h2.ur-h, .book-content h2.ar-h { font-size: 1.3rem; }
    .book-content h3.ur-h, .book-content h3.ar-h { font-size: 1.2rem; }
}

/* ============================================================
 * Scroll to Top Button
 * ============================================================ */

.scroll-top-btn {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 1060;
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-size: 1.2rem;
    transition: opacity 0.3s, transform 0.3s;
}

.scroll-top-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* ============================================================
 * Print
 * ============================================================ */

@media print {
    .navbar, footer, #bookSidebar, .border-bottom, .border-top, .scroll-top-btn {
        display: none !important;
    }

    .book-content {
        font-size: 12pt;
        line-height: 1.8;
    }
}

/* ============================================================
 * Hadith Viewer — Single Hadith Layout
 * ============================================================ */

.hadees-viewer-layout {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

/* Right Sidebar */
.hadees-sidebar {
    width: 230px;
    min-width: 230px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-left: 1px solid #dee2e6;
    overflow: hidden;
}

.hadees-sidebar-header {
    background: #0d6efd;
    color: #fff;
    padding: 12px;
    text-align: center;
    font-size: 1.2rem;
    font-family: 'Noto Nastaliq Urdu', serif;
    flex-shrink: 0;
}

.hadees-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.hadees-sidebar-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.hadees-sidebar-list li {
    padding: 0;
}

.hadees-sidebar-list li a {
    display: block;
    padding: 10px 16px;
    color: #212529;
    text-decoration: none;
    font-size: 1.1rem;
    font-family: 'Noto Nastaliq Urdu', serif;
    transition: background-color 0.15s;
}

.hadees-sidebar-list li a:hover {
    background: #e7f1ff;
}

.hadees-sidebar-list li.active a {
    background: #cfe2ff;
    font-weight: 600;
}

/* Main Content */
.hadees-main {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
}

/* Metadata Card */
.metadata-card {
    text-align: center;
    font-size: 1.2rem;
    line-height: 1.5;
}

.metadata-card .book-name {
    font-size: 1.4rem;
    font-weight: 600;
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
}

.metadata-card .kitab-name {
    font-size: 1.6rem;
    direction: rtl;
    margin-top: 12px;
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
}

.metadata-card .kitab-name-urdu {
    font-size: 1.2rem;
    margin-top: 4px;
    display: block;
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
}

.metadata-card .baab-name {
    direction: rtl;
    font-size: 1.4rem;
    margin-top: 16px;
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
}

.metadata-card .baab-name-urdu {
    margin-top: 4px;
    display: block;
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
}

.my-divider {
    margin: 0 10px;
    opacity: 0.5;
}

/* Navigation Bar */
.navigation-card {
    background: #0d6efd;
    border: none;
}

.navigation-card .nav-bar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    justify-content: space-between;
}

.navigation-card .nav-group {
    display: flex;
    gap: 4px;
    align-items: center;
}

.navigation-card .btn-outline-light {
    color: #fff;
    border-color: rgba(255,255,255,0.3);
}

.navigation-card .btn-outline-light:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.navigation-card .btn-outline-light[style*="opacity:0.5"] {
    pointer-events: none;
}

.hadith-counter {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
    color: #fff;
    font-size: 1.1rem;
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
}

.search-group .search-form {
    display: flex;
    gap: 4px;
}

.search-group .form-control {
    width: 200px;
}

/* Hadith Content Card */
.hadith-card {
    padding: 20px;
    min-height: 60vh;
}

.hadith-card .arabic-text {
    direction: rtl;
    text-align: justify;
    font-size: 30px;
    line-height: 2.2;
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
}

.hadith-card .urdu-text {
    direction: rtl;
    text-align: justify;
    font-size: 1.5rem;
    line-height: 2;
    margin-top: 20px;
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
}

.hadees-hashia {
    font-size: 1.5rem;
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
    line-height: 1.5;
}

.hadees-takhreej {
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
    font-size: 1.5rem;
    line-height: 1.8;
}

/* Hadith metadata card fonts */
.metadata-card .kitab-name,
.metadata-card .baab-name {
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
}

.metadata-card .book-name {
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
}

/* Hukam badge font */
.hadith-card .hukam {
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
}

/* Hadith Search Results */
.hadees-search-layout {
    min-height: calc(100vh - 56px);
}

.search-results-header {
    background: #e7f1ff;
    padding: 12px 0;
    font-size: 1.2rem;
    font-family: 'Noto Nastaliq Urdu', serif;
}

.search-results-header .spacer {
    flex: 1;
}

.hadees-search-layout .hadith-card .card-header {
    background: #0d6efd;
    color: #fff;
}

.hadees-search-layout .book-name {
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Noto Nastaliq Urdu', serif;
}

.hadees-search-layout .hadith-number {
    font-size: 1rem;
    padding: 4px 10px;
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

.hadees-search-layout .meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    color: gray;
    font-size: 1rem;
}

.hadees-search-layout .arabic-title,
.hadees-search-layout .urdu-title,
.hadees-search-layout .section-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin-top: 16px;
    margin-bottom: 8px;
}

.hadees-search-layout .arabic-text {
    font-size: 1.3rem;
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
    line-height: 2;
    text-align: justify;
    direction: rtl;
}

.hadees-search-layout .urdu-text,
.hadees-search-layout .hashia,
.hadees-search-layout .takhreej {
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
    font-size: 1.1rem;
    line-height: 2;
    text-align: justify;
}

.hadees-search-layout .hashia {
    padding-top: 10px;
}

.hadees-search-layout .card-actions {
    display: flex;
    justify-content: flex-end;
    background: #f8f9fa;
    padding: 8px 16px;
    border-top: 1px solid #dee2e6;
}

.highlighted-search {
    background-color: #fff3cd;
    color: #000;
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: bold;
}

/* Metadata rows in modal */
.metadata-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #dee2e6;
}

.metadata-label {
    font-weight: 600;
    font-family: 'Noto Nastaliq Urdu', serif;
}

.metadata-value {
    word-break: break-word;
    font-family: 'Noto Nastaliq Urdu', serif;
}

/* Responsive Hadith Viewer */
@media (max-width: 992px) {
    .hadees-viewer-layout {
        flex-direction: column;
        height: auto;
    }

    .hadees-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 200px;
        border-left: none;
        border-bottom: 1px solid #dee2e6;
    }

    .hadees-main {
        min-height: 60vh;
    }
}

@media (max-width: 768px) {
    .hadith-card .arabic-text {
        font-size: 1.4rem;
    }

    .hadith-card .urdu-text {
        font-size: 1.1rem;
    }

    .navigation-card .nav-bar-inner {
        flex-wrap: wrap;
        gap: 8px;
    }

    .search-group .form-control {
        width: 150px;
    }

    .hadith-counter {
        font-size: 0.9rem;
    }
}

/* ============================================================
   SHAMELA TAFSEER HTML TAGS
   ============================================================
   
   Shamela database stores formatted text with inline HTML tags:
   - <span class="ma"> = Matn Arabic (Arabic text within tafseer)
   - <span class="mu"> = Matn Urdu (Urdu text within tafseer)
   - Margin classes: mb0, mi0, mul0, ms18 (margin-bottom, margin-inline, etc.)
   
   These styles match the Angular frontend rendering.
   ============================================================ */

/* Matn Arabic - Arabic text embedded in tafseer/hadith */
.tafseer-content .ma,
.translation-text .ma,
.ayah-text-arabic .ma,
.urdu-text .ma,
.hadees-hashia .ma,
.hadees-takhreej .ma,
.hadith-card .ma {
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
    font-size: 1.1em;
    color: #1a237e;
    direction: rtl;
    unicode-bidi: embed;
}

/* Matn Urdu - Urdu text embedded in tafseer/hadith */
.tafseer-content .mu,
.translation-text .mu,
.ayah-text-arabic .mu,
.urdu-text .mu,
.hadees-hashia .mu,
.hadees-takhreej .mu,
.hadith-card .mu {
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
    font-size: 1em;
    color: #333;
    direction: rtl;
    unicode-bidi: embed;
}

/* Margin utility classes from Shamela */
.tafseer-content .mb0,
.translation-text .mb0,
.urdu-text .mb0,
.hadees-hashia .mb0,
.hadees-takhreej .mb0 {
    margin-bottom: 0;
}

.tafseer-content .mi0,
.translation-text .mi0,
.urdu-text .mi0,
.hadees-hashia .mi0,
.hadees-takhreej .mi0 {
    margin-inline: 0;
}

.tafseer-content .mul0,
.translation-text .mul0,
.urdu-text .mul0,
.hadees-hashia .mul0,
.hadees-takhreej .mul0 {
    margin-logical-start: 0;
}

.tafseer-content .ms18,
.translation-text .ms18,
.urdu-text .ms18,
.hadees-hashia .ms18,
.hadees-takhreej .ms18 {
    margin-inline-start: 18px;
}

/* ============================================================
   SHAMELA HADITH INLINE CLASSES
   ============================================================
   These classes appear in hadith Urdu text from the Shamela database.
   Matches Angular frontend global styles.css.
   ============================================================ */

/* Heading color - used for section headings like "تخریج" */
.heading-color {
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
    color: #1e88e4;
    font-size: 1.5rem;
    font-weight: 600;
}

/* Font hadith - used for hadith reference text */
.font-hadith {
    font-family: 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
    font-size: 1.1em;
}

/* Bold text */
.mb1 {
    font-weight: 600;
}

/* Margin/section classes from Shamela */
.ms14 {
    font-size: 1.15rem;
    line-height: 2.2;
}

.ms18 {
    display: block;
    margin: 1.5rem 0 1rem;
    padding-right: 12px;
    border-right: 4px solid #1b5e20;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1b5e20;
}

.ms22 {
    display: block;
    text-align: center;
    margin: 2rem 0 1.5rem;
    font-size: 1.8rem;
    font-weight: 700;
    color: #7b1fa2;
}

/* General tafseer content styling */
.tafseer-content {
    direction: rtl;
    text-align: justify;
    line-height: 2.2;
    font-size: 1.3rem;
    padding: 8px;
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
}

.tafseer-content p {
    margin-bottom: 12px;
    line-height: 2.2;
}

.tafseer-content h1,
.tafseer-content h2,
.tafseer-content h3,
.tafseer-content h4,
.tafseer-content h5 {
    text-align: right;
    margin-top: 16px;
    margin-bottom: 8px;
}

/* Translation text styling */
.translation-text {
    direction: rtl;
    text-align: justify;
    line-height: 2;
    font-size: 1.3rem;
    padding: 16px;
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
}

/* Arabic ayah text styling */
.ayah-text-arabic {
    direction: rtl;
    text-align: center;
    font-size: 2.2rem;
    line-height: 2.2;
    font-family: 'saleem_quranfont', 'noorehira', 'Amiri', 'Noto Naskh Arabic', serif !important;
    padding: 16px;
}

/* ============================================================
   SHAMELA BOOK VIEWER
   ============================================================
   Matches the Angular wahhabi-book-viewer component layout exactly.
   Two-column flexbox: right column (TOC, 300px) + left column (book content).
   ============================================================ */

.wahhabi-book-main-container {
    display: flex;
    flex-direction: row;
    gap: 16px;
    padding: 16px;
    position: relative;
    height: calc(100vh - 56px);
}

.wahhabi-book-main-container .loading-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
}

/* Right column — Table of Contents */
.wahhabi-book-main-container .right-column {
    flex: 0 0 300px;
    width: 300px;
    text-align: right;
    direction: rtl;
    height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    background: #f5f5f5;
    padding: 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Left column — Book content */
.wahhabi-book-main-container .left-column {
    flex: 1;
    text-align: right;
    direction: rtl;
    height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    background: #f5f5f5;
    padding: 16px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* TOC Header — matches Angular .toc-header */
.wahhabi-toc .toc-header {
    font-size: 1.5rem;
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
    padding: 8px 0;
    text-align: center;
    background-color: #1a237e;
    color: #fff;
    border-radius: 12px 12px 0 0;
}

.wahhabi-toc .toc-title {
    font-weight: 700;
}

/* TOC Items — matches Angular .toc-item */
.wahhabi-toc .toc-item {
    display: flex;
    align-items: start;
    padding: 8px 12px;
    cursor: pointer;
    direction: rtl;
    font-family: 'Jameel', 'Mehr Nastaliq Web', 'Noto Nastaliq Urdu', serif !important;
    transition: background-color 0.2s ease;
}

.wahhabi-toc .toc-item:hover {
    background-color: #e8eaf6;
    color: #1a237e;
}

.wahhabi-toc .toc-item.active {
    background-color: #c5cae9;
    color: #1a237e;
    font-weight: 600;
}

.wahhabi-toc .toc-item .title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wahhabi-toc .toc-item .spacer {
    flex: 0 0 4px;
    width: 4px;
    min-width: 4px;
    margin: 0 2px;
}

.wahhabi-toc .toc-item .page {
    min-width: 40px;
    text-align: left;
    font-size: 0.85rem;
    color: #666;
}

/* TOC heading types — matches Angular h1/h2/h3 classes */
.wahhabi-toc .toc-item.h1 {
    font-size: 1.2rem;
    font-weight: 700;
}

.wahhabi-toc .toc-item.h2 {
    font-size: 1.05rem;
    font-weight: 600;
    padding-right: 20px;
}

.wahhabi-toc .toc-item.h3 {
    font-size: 1rem;
    padding-right: 40px;
}

/* Book container — matches Angular .book-container */
.wahhabi-book-main-container .book-container {
    direction: rtl;
    max-width: 900px;
    margin: auto;
    padding: 16px;
}

/* Book header — matches Angular .book-header */
.wahhabi-book-main-container .book-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    background: #1a237e;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    gap: 8px;
    flex-wrap: wrap;
}

.wahhabi-book-main-container .book-header .btn-icon {
    color: #fff;
    background: transparent;
    border: none;
    padding: 4px 8px;
}

.wahhabi-book-main-container .book-header .btn-icon:hover {
    background: rgba(255,255,255,0.1);
}

.wahhabi-book-main-container .book-header .btn-icon:disabled {
    opacity: 0.5;
}

.wahhabi-book-main-container .book-header .spacer {
    flex: 1 1 auto;
}

.wahhabi-book-main-container .book-header .page-number {
    font-size: 1.2rem;
    font-weight: bold;
    white-space: nowrap;
    padding: 0 8px;
}

/* Search field in book header */
.wahhabi-book-main-container .book-header .search-field-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.wahhabi-book-main-container .book-header .search-field-wrapper .form-control {
    width: 180px;
    font-size: 0.85rem;
}

.wahhabi-book-main-container .book-header .form-check-label {
    color: #fff;
    font-size: 0.85rem;
    margin-right: 4px;
}

.wahhabi-book-main-container .book-header .form-check-input {
    margin: 0;
}

.wahhabi-book-main-container .book-header .form-check-input:checked {
    background-color: #fff;
    border-color: #fff;
}

/* Book page content — matches Angular .book-page */
.wahhabi-book-main-container .book-page {
    min-height: 80vh;
    line-height: 2;
    font-size: 1.5rem;
    padding: 16px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #fff;
    direction: rtl;
    text-align: justify;
    font-family: 'jameel', 'Noto Nastaliq Urdu', 'Amiri', 'noorehira', serif;
}

/* Book page content with inline Shamela HTML tags */
.wahhabi-book-main-container .book-page .ma {
    font-family: 'Amiri', 'noorehira', serif;
    font-size: 1.1em;
    color: #1a237e;
    direction: rtl;
    unicode-bidi: embed;
}

.wahhabi-book-main-container .book-page .mu {
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif;
    font-size: 1em;
    color: #333;
    direction: rtl;
    unicode-bidi: embed;
}

.wahhabi-book-main-container .book-page .mb0 { margin-bottom: 0; }
.wahhabi-book-main-container .book-page .mi0 { margin-inline: 0; }
.wahhabi-book-main-container .book-page .mul0 { margin-logical-start: 0; }
.wahhabi-book-main-container .book-page .ms18 { margin-inline-start: 18px; }

.wahhabi-book-main-container .book-page .heading-color {
    font-family: 'Amiri', 'noorehira', serif;
    color: #1e88e4;
    font-size: 1.5rem;
    font-weight: 600;
}

.wahhabi-book-main-container .book-page .font-hadith {
    font-family: 'Amiri', 'noorehira', serif;
    font-size: 1.1em;
}

.wahhabi-book-main-container .book-page .mb1 { font-weight: 600; }

.wahhabi-book-main-container .book-page .ms14 {
    font-size: 1.15rem;
    line-height: 2.2;
}

.wahhabi-book-main-container .book-page .ms22 {
    display: block;
    text-align: center;
    margin: 2rem 0 1.5rem;
    font-size: 1.8rem;
    font-weight: 700;
    color: #7b1fa2;
}

/* Footnotes — matches Angular .footnotes */
.wahhabi-book-main-container .footnotes {
    margin-top: 16px;
    border-top: 1px solid #ccc;
    padding-top: 10px;
    direction: rtl;
    text-align: justify;
    font-size: 1.2rem;
    line-height: 2;
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif;
    color: #555;
}

.wahhabi-book-main-container .footnotes .ma {
    font-family: 'Amiri', 'noorehira', serif;
    font-size: 1.1em;
    color: #1a237e;
}

.wahhabi-book-main-container .footnotes .mu {
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif;
    font-size: 1em;
    color: #333;
}

/* TOC empty state */
.wahhabi-toc .toc-empty {
    padding: 16px;
    text-align: center;
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif;
}

/* Responsive — matches Angular behavior */
@media (max-width: 992px) {
    .wahhabi-book-main-container {
        flex-direction: column;
        height: auto;
    }

    .wahhabi-book-main-container .right-column {
        flex: none;
        width: 100%;
        height: auto;
        max-height: 300px;
    }

    .wahhabi-book-main-container .left-column {
        height: auto;
        min-height: 60vh;
    }

    .wahhabi-book-main-container .book-page {
        min-height: 60vh;
    }
}

@media (max-width: 576px) {
    .wahhabi-book-main-container .book-header {
        flex-direction: column;
        align-items: stretch;
    }

    .wahhabi-book-main-container .book-header .spacer {
        display: none;
    }

    .wahhabi-book-main-container .book-header .search-field-wrapper .form-control {
        width: 100%;
    }

    .wahhabi-book-main-container .book-page {
        font-size: 1.2rem;
        padding: 12px;
    }
}

/* ============================================================
 * Wahhabi Books List — Three-Panel Layout
 * Matches Angular wahhabi-books-list component
 * ============================================================ */

.wahhabi-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 56px);
    overflow: hidden;
}

/* Toolbar */
.wahhabi-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #1a237e, #283593);
    color: #fff;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.wahhabi-toolbar-title {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Amiri', 'Noto Naskh Arabic', serif;
}

.wahhabi-search-field {
    position: relative;
    width: 250px;
}

/* Spacer — small width in toolbar */
.wahhabi-toolbar .spacer {
    flex: 0 0 8px;
    width: 8px;
    min-width: 8px;
}

.wahhabi-search-field .form-control {
    padding-right: 32px;
    border-radius: 20px;
    border: none;
    font-size: 0.9rem;
}

.wahhabi-search-field i {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

/* Main container */
.wahhabi-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ============================================================
 * LEFT COLUMN: Book Viewer
 * ============================================================ */

.wahhabi-book-viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f5f5f5;
}

/* Welcome screen (no book selected) */
.wahhabi-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #6c757d;
}

.wahhabi-welcome .welcome-icon {
    font-size: 4rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

.wahhabi-welcome h3 {
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif;
    color: #495057;
    margin-bottom: 0.5rem;
}

.wahhabi-welcome p {
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif;
    font-size: 1.1rem;
}

/* Book content area */
.wahhabi-book-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 12px;
    padding: 12px;
    direction: rtl;
}

/* TOC panel (right side of book viewer) */
.wahhabi-toc {
    flex: 0 0 400px;
    width: 400px;
    min-width: 400px;
    height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.wahhabi-toc .toc-header {
    font-size: 1.5rem;
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif;
    padding: 16px 12px;
    text-align: center;
    background-color: #1a237e;
    color: #fff;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
    line-height: 2;
}

.wahhabi-toc .toc-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
}

.wahhabi-toc .toc-item {
    display: flex;
    align-items: start;
    padding: 10px 8px;
    cursor: pointer;
    border-radius: 6px;
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif;
    direction: rtl;
    line-height: 2;
    margin-bottom: 2px;
}

.wahhabi-toc .toc-item:hover {
    background-color: #e8eaf6;
    color: #1a237e;
}

.wahhabi-toc .toc-item.active {
    background-color: #c5cae9;
    color: #1a237e;
    font-weight: 600;
}

.wahhabi-toc .toc-item .page {
    min-width: 40px;
    text-align: left;
    font-size: 0.95rem;
    color: #6c757d;
}

.wahhabi-toc .toc-item.h1 {
    font-size: 1.2rem;
    font-weight: 700;
}

.wahhabi-toc .toc-item.h2 {
    font-size: 1.05rem;
    font-weight: 600;
    padding-right: 20px;
}

.wahhabi-toc .toc-item.h3 {
    font-size: 1rem;
    padding-right: 40px;
}

/* Book main area (left side of book viewer) */
.wahhabi-book-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    height: 90vh;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 20px;
    direction: rtl;
}

.wahhabi-book-main .book-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    background: #1a237e;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.wahhabi-book-main .book-header .btn-icon {
    color: #fff;
    border: none;
}

.wahhabi-book-main .book-header .btn-icon:hover {
    color: #c5cae9;
}

.wahhabi-book-main .book-header .page-number {
    font-size: 1.1rem;
    font-weight: bold;
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif;
    min-width: 120px;
    text-align: center;
}

.wahhabi-book-main .book-header .book-search-field {
    width: 180px;
}

/* Spacer in book header — small width */
.wahhabi-book-main .book-header .spacer {
    flex: 0 0 8px;
    width: 8px;
    min-width: 8px;
}

.wahhabi-book-main .book-header .form-switch .form-check-label {
    color: #fff;
    font-size: 0.85rem;
}

/* Book page content */
.wahhabi-book-main .book-page {
    line-height: 2.2;
    font-size: 1.5rem;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #fff;
    min-height: 70vh;
    direction: rtl;
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif;
}

.wahhabi-book-main .book-page .ma {
    font-family: 'Amiri', 'noorehira', serif;
    font-size: 1.1em;
    color: #1a237e;
    direction: rtl;
}

.wahhabi-book-main .book-page .mu {
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif;
    font-size: 1em;
    color: #333;
    direction: rtl;
}

.wahhabi-book-main .book-page .heading-color {
    font-family: 'Amiri', 'noorehira', serif;
    color: #1e88e4;
    font-size: 1.5rem;
    font-weight: 600;
}

.wahhabi-book-main .book-page .font-hadith {
    font-family: 'Amiri', 'noorehira', serif;
    font-size: 1.1em;
}

.wahhabi-book-main .book-page .mb1 { font-weight: 600; }

.wahhabi-book-main .book-page .ms14 {
    font-size: 1.15rem;
    line-height: 2.2;
}

.wahhabi-book-main .book-page .ms18 {
    color: #2e7d32;
    font-weight: 600;
    border-right: 3px solid #2e7d32;
    padding-right: 8px;
}

.wahhabi-book-main .book-page .ms22 {
    display: block;
    text-align: center;
    margin: 2rem 0 1.5rem;
    font-size: 1.8rem;
    font-weight: 700;
    color: #7b1fa2;
}

.wahhabi-book-main .book-page .mb0 { margin-bottom: 0; }
.wahhabi-book-main .book-page .mi0 { margin-inline: 0; }
.wahhabi-book-main .book-page .mul0 { margin-logical-start: 0; }

/* Footnotes */
.wahhabi-book-main .footnotes {
    margin-top: 16px;
    border-top: 1px solid #ccc;
    padding-top: 10px;
    direction: rtl;
    text-align: justify;
    font-size: 1.2rem;
    line-height: 2;
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif;
    color: #555;
}

/* ============================================================
 * RIGHT COLUMN: Library Navigation
 * ============================================================ */

.wahhabi-nav {
    flex: 0 0 350px;
    width: 350px;
    min-width: 350px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border-right: 1px solid #ddd;
    transition: margin-left 0.3s ease, min-width 0.3s ease, width 0.3s ease;
}

.wahhabi-nav.collapsed {
    margin-left: -350px;
    min-width: 0;
    width: 0;
    border: none;
    overflow: hidden;
}

.wahhabi-nav .nav-tabs {
    flex-shrink: 0;
    border-bottom: 2px solid #dee2e6;
}

.wahhabi-nav .nav-tabs .nav-link {
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif !important;
    font-size: 1.1rem;
    font-weight: 600;
    color: #6c757d;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 12px 20px;
    line-height: 2;
}

.wahhabi-nav .nav-tabs .nav-link.active {
    color: #1a237e;
    border-bottom-color: #1a237e;
    background: transparent;
}

.wahhabi-nav .nav-tabs .nav-link:hover {
    color: #1a237e;
    border-bottom-color: #1a237e;
}

.wahhabi-nav .tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Accordion book links */
.wahhabi-nav .accordion-item {
    border: none;
    border-bottom: 1px solid #eee;
}

.wahhabi-nav .accordion-button {
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif !important;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    background: #f8f9fa;
    padding: 14px 16px;
    box-shadow: none;
    line-height: 2;
}

.wahhabi-nav .accordion-button:not(.collapsed) {
    background: #e8eaf6;
    color: #1a237e;
}

.wahhabi-nav .accordion-button::after {
    margin-left: auto;
}

.wahhabi-nav .accordion-body {
    padding: 6px 8px;
}

.wahhabi-nav .book-link {
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif !important;
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 1.05rem;
    color: #333;
    direction: rtl;
    line-height: 2;
    margin-bottom: 2px;
}

.wahhabi-nav .book-link:hover {
    background: #e8eaf6;
    color: #1a237e;
}

.wahhabi-nav .book-link.active {
    background: #c5cae9;
    color: #1a237e;
    font-weight: 600;
}

/* ============================================================
 * Responsive — Wahhabi Books List
 * ============================================================ */

@media (max-width: 992px) {
    .wahhabi-book-content {
        flex-direction: column;
    }

    .wahhabi-toc {
        flex: none;
        width: 100%;
        min-width: 100%;
        height: auto;
        max-height: 300px;
    }

    .wahhabi-book-main {
        height: auto;
        min-height: 60vh;
    }

    .wahhabi-nav {
        position: fixed;
        left: 0;
        top: 56px;
        bottom: 0;
        z-index: 1050;
        box-shadow: 4px 0 8px rgba(0, 0, 0, 0.2);
    }

    .wahhabi-nav.collapsed {
        margin-left: -350px;
    }
}

@media (max-width: 576px) {
    .wahhabi-toolbar {
        padding: 8px 12px;
    }

    .wahhabi-toolbar-title {
        font-size: 1.2rem;
    }

    .wahhabi-search-field {
        width: 180px;
    }

    .wahhabi-book-content {
        padding: 8px;
        gap: 8px;
    }

    .wahhabi-book-main .book-header {
        flex-direction: column;
        align-items: stretch;
    }

    .wahhabi-book-main .book-header .spacer {
        display: none;
    }

    .wahhabi-book-main .book-page {
        font-size: 1.2rem;
        padding: 12px;
        min-height: 50vh;
    }
}

/* ============================================================
 * Brailvi RTF Hybrid Viewport — matches Angular parseRtfToHtmlString()
 * ============================================================ */

.rtf-hybrid-viewport {
    direction: rtl;
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif !important;
}

.rtf-hybrid-viewport h1 {
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif !important;
    font-weight: 700;
    color: #1a237e;
    margin: 16px 0 8px 0;
}

.rtf-hybrid-viewport h2 {
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif !important;
    font-weight: 600;
    color: #283593;
    margin: 12px 0 6px 0;
}

.rtf-hybrid-viewport p {
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif !important;
    margin: 4px 0;
    line-height: 2;
}

.rtf-hybrid-viewport strong {
    font-weight: 700;
}

.inline-arabic {
    font-family: 'Amiri', 'noorehira', serif !important;
    font-size: 1.1em;
    color: #1565c0;
}

.inline-urdu {
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif !important;
}

.brailvi-page-text {
    direction: rtl;
    font-family: 'jameel', 'Noto Nastaliq Urdu', serif !important;
    line-height: 2;
}

/* ============================================================
 * Search Results Page
 * ============================================================ */

.search-result-item {
    padding: 16px 20px;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.search-result-item:hover {
    background-color: #e3f2fd;
}

.search-result-item:active {
    background-color: #bbdefb;
}

.search-result-item h6 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a237e;
}

.search-result-item .badge {
    font-size: 0.85rem;
    padding: 4px 10px;
}

.search-snippet {
    direction: rtl;
    font-family: 'Noto Nastaliq Urdu', 'Noto Naskh Arabic', serif;
    line-height: 2;
    color: #495057;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-right: 3px solid #0d6efd;
}

.search-snippet mark {
    background-color: #fff3cd;
    color: #000;
    padding: 1px 4px;
    border-radius: 2px;
}

/* Scope tabs styling */
.nav-tabs .nav-link {
    color: #6c757d;
    font-size: 1rem;
}

.nav-tabs .nav-link.active {
    color: #0d6efd;
    font-weight: 600;
}

.nav-tabs .nav-link:hover:not(.active) {
    color: #0d6efd;
    border-color: #e3f2fd;
}

/* ============================================================
 * Homepage — Modern Landing Page Styles
 * ============================================================ */

/* Hero Section */
.homepage-hero {
    position: relative;
    background: linear-gradient(135deg, #1a237e 0%, #0d47a1 50%, #01579b 100%);
    padding: 5rem 1rem 4rem 1rem;
    overflow: hidden;
}

.homepage-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.3;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.2) 100%);
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-title {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    font-size: 3.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 0.5rem;
}

.hero-title i {
    margin-left: 0.5rem;
}

.hero-subtitle {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    font-size: 1.5rem;
    opacity: 0.9;
    margin-bottom: 1rem;
}

.hero-stats {
    font-size: 1.1rem;
    opacity: 0.85;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.hero-stat-item {
    font-weight: 500;
}

.hero-stat-divider {
    opacity: 0.6;
}

.hero-search-form {
    max-width: 700px;
    margin: 0 auto;
}

.hero-search-form .input-group {
    border-radius: 50px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.hero-search-form .input-group-text {
    border-right: none;
}

.hero-search-form .form-control {
    border-left: none;
    height: 55px;
    font-size: 1.1rem;
}

.hero-search-form .form-control:focus {
    box-shadow: none;
    border-color: transparent;
}

.hero-search-form .btn-warning {
    border-radius: 50px;
    height: 55px;
    font-weight: 600;
}

.hero-actions .btn {
    border-radius: 50px;
    padding: 0.5rem 1.5rem;
    font-weight: 500;
}

/* Statistics Cards */
.stat-card {
    padding: 2rem 1rem;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem auto;
    font-size: 1.5rem;
    color: white;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 1.1rem;
    color: #6c757d;
}

/* Section Headers */
.section-title {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    font-size: 2rem;
    font-weight: 700;
    color: #1a237e;
    margin-bottom: 0.5rem;
}

.section-title i {
    margin-left: 0.5rem;
}

.section-subtitle {
    font-size: 1.1rem;
    color: #6c757d;
}

/* Collection Cards */
.collection-card {
    display: block;
    padding: 2rem 1.5rem;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    background: #fff;
    transition: all 0.3s ease;
    text-align: center;
    height: 100%;
}

.collection-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border-color: transparent;
    text-decoration: none;
}

.collection-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem auto;
    font-size: 1.8rem;
    color: white;
}

.collection-title {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: #212529;
    margin-bottom: 0.5rem;
}

.collection-desc {
    font-size: 0.95rem;
    color: #6c757d;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.collection-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: #0d6efd;
    transition: color 0.2s ease;
}

.collection-card:hover .collection-link {
    color: #0a58ca;
}

/* Featured Book Cards */
.featured-book-card {
    transition: transform 0.2s, box-shadow 0.2s;
    border-radius: 8px;
    overflow: hidden;
}

.featured-book-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.featured-book-card .card-title {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.featured-book-card .card-title a:hover {
    color: #0d6efd !important;
}

/* Feature Cards */
.feature-card {
    padding: 2rem 1.5rem;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    background: #fff;
    transition: all 0.3s ease;
    height: 100%;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border-color: transparent;
}

.feature-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem auto;
    font-size: 1.8rem;
    color: white;
}

.feature-title {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: #212529;
    margin-bottom: 0.5rem;
}

.feature-desc {
    font-size: 0.95rem;
    color: #6c757d;
    margin-bottom: 1rem;
    line-height: 1.6;
}

/* Quick Link Cards */
.quick-link-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #212529;
    transition: all 0.3s ease;
    text-decoration: none;
    height: 100%;
}

.quick-link-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-color: #0d6efd;
    color: #0d6efd;
    text-decoration: none;
}

.quick-link-card i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.quick-link-card span {
    font-size: 1rem;
    font-weight: 500;
}

/* Homepage Responsive */
@media (max-width: 992px) {
    .hero-title {
        font-size: 2.5rem;
    }
    
    .hero-subtitle {
        font-size: 1.2rem;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .homepage-hero {
        padding: 3rem 1rem 2.5rem 1rem;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .hero-stats {
        font-size: 0.9rem;
    }
    
    .hero-search-form .form-control {
        height: 45px;
        font-size: 1rem;
    }
    
    .hero-search-form .btn-warning {
        height: 45px;
        padding: 0.5rem 1rem;
    }
    
    .hero-actions .btn {
        margin-bottom: 0.5rem;
        width: 100%;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .collection-card {
        padding: 1.5rem 1rem;
    }
    
    .quick-link-card {
        padding: 1rem 0.5rem;
    }
    
    .quick-link-card i {
        font-size: 1.5rem;
    }
    
    .quick-link-card span {
        font-size: 0.9rem;
    }
}

/* ============================================================
 * Advanced Search Modal
 * ============================================================ */

.adv-category-tree .tree-node {
    border-bottom: 1px solid #f0f0f0;
}

.adv-category-tree .tree-label {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    font-size: 1rem;
    line-height: 2;
}

.adv-category-tree .tree-chevron {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    display: inline-block;
}

.adv-category-tree .tree-toggle {
    color: #6c757d;
}

.adv-category-tree .tree-toggle:hover {
    color: #0d6efd;
}

.adv-category-tree .form-check-label {
    cursor: pointer;
    width: 100%;
}

.adv-category-tree .form-check-input {
    cursor: pointer;
}

.adv-category-tree .badge {
    font-size: 0.7rem;
    padding: 2px 6px;
}

.history-item {
    cursor: pointer;
    transition: background-color 0.2s;
    border-radius: 4px;
    margin-bottom: 4px;
}

.history-item:hover {
    background-color: #f0f7ff;
}

/* Modal RTL adjustments */
#advancedSearchModal .modal-content {
    direction: rtl;
}

#advancedSearchModal .modal-body {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
}

#advancedSearchModal .nav-tabs .nav-link {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    font-size: 0.95rem;
    line-height: 1.8;
}

#advancedSearchModal .list-group-item {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    line-height: 2;
}

/* ============================================================
 * Homepage — Collection Stats
 * ============================================================ */

.collection-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.collection-stats span {
    background: rgba(0, 0, 0, 0.06);
    color: #495057;
    font-size: 0.8rem;
    padding: 2px 10px;
    border-radius: 20px;
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
}

/* ============================================================
 * Homepage — Highlight Cards (Quran & Hadith)
 * ============================================================ */

.highlight-card {
    border-radius: 16px;
    padding: 2.5rem 2rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.highlight-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.highlight-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
}

.highlight-card h3 {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.highlight-card > p {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    font-size: 1.1rem;
    line-height: 2;
    margin-bottom: 1.5rem;
    opacity: 0.9;
}

.highlight-features {
    list-style: none;
    padding: 0;
    margin: 0 0 2rem 0;
}

.highlight-features li {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    font-size: 1.05rem;
    line-height: 2.2;
    padding: 0.25rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.highlight-features li i {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.highlight-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: auto;
}

.highlight-actions .btn {
    font-family: 'Noto Nastaliq Urdu', 'Amiri', serif;
    font-size: 1rem;
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
}

/* Responsive for highlight cards */
@media (max-width: 991px) {
    .highlight-card {
        padding: 2rem 1.5rem;
    }
    .highlight-card h3 {
        font-size: 1.6rem;
    }
    .highlight-icon {
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }
}
