/* ==========================================================================
   نور من القرآن — تنسيق صفحة الأحاديث النبوية (hadith.css)
   ألوان الهوية: البنفسجي #8E44AD / #9B59B6 — الوردي #F8B4D9
   ========================================================================== */

:root {
    --hd-purple: var(--primary-purple, #9B59B6);
    --hd-purple-deep: var(--secondary-purple, #8E44AD);
    --hd-pink: var(--soft-pink, #F8B4D9);
    --hd-line: rgba(155, 89, 182, .18);
    --hd-line-soft: rgba(155, 89, 182, .10);
    --hd-glass: rgba(255, 255, 255, .72);
    --hd-glass-strong: rgba(255, 255, 255, .92);
    --hd-shadow-sm: 0 6px 22px rgba(142, 68, 173, .07);
    --hd-shadow-md: 0 16px 45px rgba(142, 68, 173, .13);
    --hd-shadow-lg: 0 26px 70px rgba(142, 68, 173, .18);
    --hd-radius: 22px;
}

/* ==================== الحاوية العامة ==================== */
.hadith-app-container {
    padding-bottom: 90px;
    padding-top: 20px;
    min-height: calc(100vh - 400px);
    position: relative;
    z-index: 2;
}

/* ==================== الهيدر ==================== */
.hadith-hero-inner {
    position: relative;
    z-index: 2;
}

.hadith-tag {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
}

.hadith-hero-title {
    font-family: var(--font-secondary);
    color: var(--hd-purple-deep);
    font-weight: 800;
    font-size: clamp(2rem, 4.6vw, 3.2rem);
    line-height: 1.35;
    margin-bottom: .9rem;
}

.hadith-hero-sub {
    color: var(--text-dark);
    opacity: .85;
    font-size: clamp(1rem, 1.6vw, 1.12rem);
    line-height: 2.1;
    max-width: 46ch;
    margin-bottom: 0;
}

.hadith-divider {
    justify-content: flex-start;
}

/* بطاقة الاقتباس */
.hadith-quote-card {
    position: relative;
    margin: 0;
    padding: 42px 34px 32px;
    border-radius: 28px 28px 28px 90px;
    background: var(--hd-glass);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border: 1px solid rgba(255, 255, 255, .6);
    box-shadow: var(--hd-shadow-md);
    overflow: hidden;
    text-align: center;
}

.hadith-quote-card::before {
    content: '';
    position: absolute;
    inset: 10px;
    border: 1px dashed var(--hd-line);
    border-radius: 22px 22px 22px 78px;
    pointer-events: none;
}

.hadith-quote-card .quote-mark {
    display: block;
    font-family: var(--font-secondary);
    font-size: 3.4rem;
    line-height: .6;
    color: var(--hd-pink);
    margin-bottom: 14px;
}

.hadith-quote-card blockquote {
    font-family: var(--font-secondary);
    font-size: clamp(1.4rem, 2.6vw, 1.85rem);
    font-weight: 700;
    line-height: 2;
    color: var(--hd-purple-deep);
    margin: 0 0 16px;
}

.hadith-quote-card figcaption {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: .9rem;
    font-weight: 700;
    color: var(--hd-purple);
    background: rgba(155, 89, 182, .08);
    border: 1px solid var(--hd-line);
    padding: 6px 16px;
    border-radius: 30px;
}

.hadith-quote-card .quote-glow {
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    top: -90px;
    left: -70px;
    background: radial-gradient(circle, rgba(248, 180, 217, .45), transparent 68%);
    pointer-events: none;
}

/* ==================== لوحة البحث ==================== */
.filter-card {
    background: var(--hd-glass);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border-radius: var(--hd-radius);
    padding: 28px 28px 22px;
    box-shadow: var(--hd-shadow-md);
    margin-bottom: 46px;
    border: 1px solid rgba(255, 255, 255, .6);
    position: relative;
    overflow: hidden;
}

.filter-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--hd-pink), var(--hd-purple), transparent);
}

.filter-card-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.filter-icon {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    color: #fff;
    font-size: 1.05rem;
    background: linear-gradient(135deg, var(--hd-purple), var(--hd-purple-deep));
    box-shadow: 0 8px 20px rgba(142, 68, 173, .28);
}

.filter-title {
    font-family: var(--font-primary);
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--hd-purple-deep);
    margin: 0;
}

.filter-note {
    margin: 2px 0 0;
    font-size: .85rem;
    color: var(--text-light);
}

.search-wrapper {
    position: relative;
}

.search-wrapper i {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--hd-purple);
    pointer-events: none;
}

.search-wrapper .form-control {
    padding-right: 52px;
    border-radius: 30px;
    border: 1px solid var(--hd-line);
    height: 56px;
    font-size: 1.05rem;
    background: rgba(255, 255, 255, .85);
    transition: all .3s ease;
}

.search-wrapper .form-control:focus {
    border-color: var(--hd-purple);
    box-shadow: 0 0 0 4px rgba(155, 89, 182, .12);
    background: #fff;
}

.select-wrapper .form-select {
    height: 56px;
    border-radius: 30px;
    padding-right: 22px;
    padding-left: 42px;
    font-weight: 600;
    color: var(--text-dark);
    border: 1px solid var(--hd-line) !important;
    background-color: rgba(255, 255, 255, .85) !important;
    transition: all .3s ease;
}

.select-wrapper .form-select:focus {
    border-color: var(--hd-purple) !important;
    box-shadow: 0 0 0 4px rgba(155, 89, 182, .12) !important;
    background-color: #fff !important;
}

/* دليل الدرجات */
.grade-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--hd-line);
}

.legend-label {
    font-size: .85rem;
    font-weight: 700;
    color: var(--text-light);
}

.legend-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    font-weight: 700;
    padding: 5px 14px;
    border-radius: 30px;
}

.legend-sahih { background: #e8f8f0; color: #1e9e63; border: 1px solid rgba(46, 204, 113, .45); }
.legend-hasan { background: #fef9e7; color: #b7930c; border: 1px solid rgba(241, 196, 15, .45); }
.legend-daeef { background: #fdedec; color: #d0453a; border: 1px solid rgba(231, 76, 60, .40); }

/* ==================== عناوين الأقسام ==================== */
.books-section { margin-bottom: 50px; }
.hadiths-section { margin-bottom: 20px; }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 22px;
}

.section-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-primary);
    font-weight: 800;
    color: var(--hd-purple-deep);
    margin: 0;
    font-size: 1.3rem;
}

.section-heading .arch-lamp {
    position: relative;
    display: inline-flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: 50% 50% 50% 12px;
    color: var(--hd-purple);
    background: linear-gradient(135deg, rgba(155, 89, 182, .12), rgba(248, 180, 217, .25));
    border: 1px solid var(--hd-line);
}

.section-hint {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: .85rem;
    color: var(--text-light);
    background: rgba(255, 255, 255, .6);
    border: 1px dashed var(--hd-line);
    padding: 6px 14px;
    border-radius: 30px;
}

/* ==================== بطاقات الكتب ==================== */
.book-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 16px;
}

.book-btn {
    position: relative;
    background: var(--hd-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--hd-line);
    padding: 24px 16px 20px;
    border-radius: 20px 20px 20px 40px;
    text-align: center;
    transition: all .35s cubic-bezier(.175, .885, .32, 1.275);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    height: 100%;
    overflow: hidden;
}

.book-btn::after {
    content: '';
    position: absolute;
    inset: auto -30% -60% -30%;
    height: 90px;
    background: radial-gradient(circle, rgba(248, 180, 217, .35), transparent 70%);
    opacity: 0;
    transition: opacity .35s ease;
}

.book-btn i {
    font-size: 1.75rem;
    color: var(--hd-purple);
    transition: all .3s;
}

.book-btn span {
    font-weight: 700;
    font-family: var(--font-primary);
    color: var(--text-dark);
    font-size: 1rem;
    position: relative;
    z-index: 1;
}

.book-btn small {
    color: var(--text-light);
    font-size: .78rem;
    position: relative;
    z-index: 1;
}

.book-btn:hover {
    transform: translateY(-6px);
    border-color: var(--hd-purple);
    box-shadow: var(--hd-shadow-md);
    background: var(--hd-glass-strong);
}

.book-btn:hover::after { opacity: 1; }
.book-btn:hover i { transform: scale(1.08); }

.book-btn.active {
    background: linear-gradient(140deg, var(--hd-purple), var(--hd-purple-deep));
    border-color: var(--hd-purple-deep);
    color: #fff;
    box-shadow: 0 18px 40px rgba(142, 68, 173, .35);
}

.book-btn.active i,
.book-btn.active span,
.book-btn.active small { color: #fff !important; }

.book-btn.active small {
    background: rgba(255, 255, 255, .18) !important;
    border-color: rgba(255, 255, 255, .35) !important;
}

.book-buttons::-webkit-scrollbar { height: 6px; }
.book-buttons::-webkit-scrollbar-thumb { background: rgba(155, 89, 182, .3); border-radius: 10px; }

/* ==================== شريط المعلومات ==================== */
.hadith-info-alert {
    background: var(--hd-glass-strong);
    color: var(--hd-purple-deep);
    padding: 16px 24px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    border: 1px solid var(--hd-line);
    border-right: 4px solid var(--hd-purple);
    box-shadow: var(--hd-shadow-sm);
}

.hadith-info-alert i { color: var(--hd-purple); }

/* ==================== بطاقة الحديث ==================== */
.hadith-card {
    background: var(--hd-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px 24px 24px 60px;
    padding: 26px 26px 22px;
    border: 1px solid var(--hd-line);
    position: relative;
    transition: all .4s cubic-bezier(.165, .84, .44, 1);
    height: 100%;
    box-shadow: var(--hd-shadow-sm);
    overflow: hidden;
}

/* قوس المحراب العلوي */
.hadith-card::before {
    content: '';
    position: absolute;
    top: -1px;
    right: 0;
    left: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--hd-pink), var(--hd-purple), transparent);
    opacity: .45;
    transition: opacity .3s;
}

/* زخرفة خفيفة في الزاوية */
.hadith-card::after {
    content: '\f5d0';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: 18px;
    bottom: 14px;
    font-size: 2.6rem;
    color: rgba(155, 89, 182, .06);
    pointer-events: none;
}

.hadith-card:hover {
    box-shadow: var(--hd-shadow-lg);
    transform: translateY(-6px);
    background: var(--hd-glass-strong);
    border-color: rgba(155, 89, 182, .3);
}

.hadith-card:hover::before { opacity: 1; }

/* رقم الحديث */
.hadith-number {
    min-width: 46px;
    height: 46px;
    padding: 0 10px;
    background: linear-gradient(135deg, rgba(155, 89, 182, .12), rgba(248, 180, 217, .25));
    color: var(--hd-purple-deep);
    border-radius: 14px 14px 14px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    border: 1px solid var(--hd-line);
    letter-spacing: .5px;
}

/* نص الحديث */
.hadith-text {
    font-family: var(--font-secondary);
    font-size: 1.3rem;
    line-height: 2.15;
    color: var(--text-dark);
    text-align: right;
    margin-bottom: 16px;
    position: relative;
    padding-right: 16px;
    border-right: 3px solid rgba(248, 180, 217, .55);
}

.hadith-card.collapsed .hadith-text {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* زر التوسيع */
.toggle-hadith-btn {
    background: rgba(155, 89, 182, .07);
    border: 1px solid var(--hd-line);
    color: var(--hd-purple-deep);
    font-weight: 700;
    padding: 7px 16px;
    border-radius: 30px;
    font-size: .88rem;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 14px;
    transition: all .25s ease;
}

.toggle-hadith-btn:hover {
    background: linear-gradient(135deg, var(--hd-purple), var(--hd-purple-deep));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 18px rgba(142, 68, 173, .25);
}

/* بيانات الحديث */
.hadith-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px dashed var(--hd-line) !important;
    padding-top: 15px;
}

.hadith-meta span {
    padding: 6px 15px;
    border-radius: 30px;
    font-size: .82rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.hadith-book {
    background: rgba(155, 89, 182, .10) !important;
    color: var(--hd-purple-deep) !important;
    border: 1px solid var(--hd-line);
}

.hadith-chapter {
    background: rgba(248, 180, 217, .18) !important;
    color: #c2185b !important;
    border: 1px solid rgba(248, 180, 217, .5);
    max-width: 100%;
}

/* درجة الحديث */
.hadith-status {
    padding: 5px 14px;
    border-radius: 30px;
    font-size: .8rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-sahih { background: #e8f8f0; color: #1e9e63; border: 1px solid rgba(46, 204, 113, .5); }
.status-hasan { background: #fef9e7; color: #b7930c; border: 1px solid rgba(241, 196, 15, .5); }
.status-daeef { background: #fdedec; color: #d0453a; border: 1px solid rgba(231, 76, 60, .45); }

/* ==================== الحالات (فارغ / تحميل / خطأ) ==================== */
.hadith-empty,
.hadith-loading,
.hadith-error {
    text-align: center;
    padding: 70px 24px;
    color: var(--text-light);
    background: var(--hd-glass);
    border: 1px dashed var(--hd-line);
    border-radius: var(--hd-radius);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.hadith-empty i,
.hadith-loading i,
.hadith-error i {
    font-size: 3.4rem;
    margin-bottom: 18px;
    opacity: .45;
    color: var(--hd-purple);
}

.hadith-empty h5,
.hadith-error h5 {
    font-weight: 800;
    color: var(--hd-purple-deep);
    margin-bottom: 6px;
}

.hadith-loading .spinner-border {
    color: var(--hd-purple) !important;
    width: 3rem;
    height: 3rem;
    margin-bottom: 14px;
}

.hadith-error .btn-primary {
    background: linear-gradient(135deg, var(--hd-purple), var(--hd-purple-deep));
    border: none;
    border-radius: 30px;
    padding: 10px 26px;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(142, 68, 173, .25);
}

/* ==================== حركة الظهور ==================== */
.fade-in { animation: hdFadeUp .6s ease both; }

.hadith-card {
    animation: hdFadeUp .5s ease both;
}

@keyframes hdFadeUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .fade-in, .hadith-card { animation: none; }
    .hadith-card:hover, .book-btn:hover { transform: none; }
}

/* ==================== التجاوب ==================== */
@media (max-width: 991.98px) {
    .hadith-hero-sub { max-width: 100%; }
    .hadith-quote-card { margin-top: 12px; }
    .hadith-divider { justify-content: center; }
}

@media (max-width: 768px) {
    .filter-card { padding: 20px 16px 16px; }
    .filter-card-head { margin-bottom: 16px; }
    .book-buttons { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 12px; }
    .book-btn { padding: 18px 12px; border-radius: 18px 18px 18px 32px; }
    .hadith-card { padding: 20px 18px; border-radius: 20px 20px 20px 44px; }
    .hadith-text { font-size: 1.18rem; line-height: 2.05; }
    .section-head { flex-direction: column; align-items: flex-start; }
    .section-hint { font-size: .78rem; }
}

@media (max-width: 480px) {
    .hadith-quote-card { padding: 32px 22px 26px; border-radius: 24px 24px 24px 60px; }
    .grade-legend { gap: 8px; }
}
