/* ============================================================================
   Hadith Section Styles
   Version: 1.12 - ADDED: Bookmark buttons and badges for collections/books
   Part of Islamic Daily Companion
   ============================================================================ */

/* CSS Variables for Hadith Section */
:root {
    --hadith-card-bg: rgba(255, 255, 255, 0.9);
    --hadith-border: rgba(0, 0, 0, 0.1);
    --hadith-arabic-bg: rgba(76, 175, 80, 0.05);
    --hadith-green: #4CAF50;
    --hadith-green-dark: #45a049;
    --bookmark-active: #FFD700;
    --bookmark-inactive: #999;
    --hadith-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.dark-mode {
    --hadith-card-bg: rgba(45, 55, 72, 0.9);
    --hadith-border: rgba(255, 255, 255, 0.1);
    --hadith-arabic-bg: rgba(76, 175, 80, 0.1);
}

/* ============================================================================
   Main Hadith Section Container
   ============================================================================ */

#hadithSection {
    display: none;
    width: 100%;
    min-height: 100vh;
    padding: 165px 20px 110px;
    box-sizing: border-box;
}

/* Hadith Section Header (standardized) */
.hadith-section-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 0;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    position: fixed;
    top: 85px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 428px;
    z-index: 90;
}

.dark-mode .hadith-section-header {
    background: rgba(45, 55, 72, 0.95);
}

.hadith-section-header .back-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #4CAF50;
    font-size: 18px;
    position: relative;
    z-index: 1;
}

.hadith-section-header .back-btn:hover {
    background: rgba(76, 175, 80, 0.2);
    transform: scale(1.05);
}

.hadith-section-title-wrapper {
    position: absolute;
    left: 0;
    right: 0;
    text-align: center;
    pointer-events: none;
}

.hadith-section-header h2 {
    font-size: 24px;
    font-weight: bold;
    color: #2d5016;
    margin: 0;
    pointer-events: auto;
}

.dark-mode .hadith-section-header h2 {
    color: #4CAF50;
}

/* FIXED v1.10: Mobile-specific padding to prevent back button hiding behind top bar */
@media (max-width: 768px) {
    #hadithSection {
        padding-top: 165px; /* Standardized for fixed header */
    }
}

#hadithContent {
    max-width: 1200px;
    margin: 0 auto;
}

/* ============================================================================
   Section Header (with back button)
   ============================================================================ */

.section-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 8px;
    padding: 15px 20px;
    background: var(--hadith-card-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: var(--hadith-shadow);
}

.section-header .back-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(76, 175, 80, 0.1);
    color: #4CAF50;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
}

.section-header .back-btn:hover {
    background: rgba(76, 175, 80, 0.2);
    transform: scale(1.05);
}

.section-header h2 {
    margin: 0;
    flex: 1;
    text-align: center;
    font-size: 24px;
    color: #2d5016;
}

.dark-mode .section-header h2 {
    color: #4CAF50;
}

/* ============================================================================
   Daily Hadith Card
   ============================================================================ */

#dailyHadithCard {
    background: var(--hadith-card-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 30px;
    margin: 8px auto 8px auto;
    max-width: 428px;
    box-shadow: var(--hadith-shadow);
}

.daily-hadith-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--hadith-green);
}

.daily-hadith-header span {
    font-size: 18px;
    font-weight: bold;
    color: var(--hadith-green);
}

.language-toggle {
    padding: 8px 16px;
    background: var(--hadith-green);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.language-toggle:hover {
    background: var(--hadith-green-dark);
    transform: translateY(-2px);
}

.daily-hadith-content {
    line-height: 1.8;
}

.daily-hadith-content .hadith-narrator {
    font-style: italic;
    color: #666;
    margin-bottom: 15px;
}

.daily-hadith-content .hadith-text {
    font-size: 18px;
    margin-bottom: 20px;
    color: #333;
    white-space: pre-line;
}

.daily-hadith-content .hadith-reference {
    font-size: 14px;
    color: #666;
    font-style: italic;
    text-align: right;
}

.daily-hadith-content.arabic-content {
    direction: rtl;
    text-align: right;
}

.daily-hadith-content.arabic-content .hadith-text-arabic {
    font-family: 'Amiri', 'Scheherazade New', serif;
    font-size: 22px;
    line-height: 2;
    margin-bottom: 20px;
}

/* ============================================================================
   Search Panel
   ============================================================================ */

.search-panel {
    display: flex;
    gap: 10px;
    margin: 0 auto 4px auto;
    max-width: 428px;
    padding: 20px;
    background: var(--hadith-card-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: var(--hadith-shadow);
}

.search-panel input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid var(--hadith-border);
    border-radius: 8px;
    font-size: 16px;
    background: white;
    transition: all 0.3s ease;
}

.search-panel input:focus {
    outline: none;
    border-color: var(--hadith-green);
}

.search-panel button {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--hadith-green), var(--hadith-green-dark));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-panel button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

/* ============================================================================
   Collections List (changed from grid)
   ============================================================================ */

#collectionsGrid {
    background: var(--hadith-card-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--hadith-shadow);
    margin-bottom: 30px;
}

.collection-list-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    border-bottom: 1px solid var(--hadith-border);
    cursor: pointer;
    transition: all 0.3s ease;
}

.collection-list-item:last-child {
    border-bottom: none;
}

.collection-list-item:hover {
    background: rgba(76, 175, 80, 0.05);
    transform: translateX(5px);
}

/* Collection Icon Wrapper - Becomes button if has bookmarks */
.collection-icon-wrapper {
    position: relative;
    min-width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.collection-icon-wrapper.has-bookmarks {
    background: var(--bookmark-active);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.collection-icon-wrapper.has-bookmarks:hover {
    background: #FFC700;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.5);
}

.collection-icon-wrapper .collection-icon {
    font-size: 48px;
    text-align: center;
}

.collection-icon-wrapper .bookmark-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #d32f2f;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 3px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.collection-content {
    flex: 1;
    text-align: right;
    padding-right: 15px;
}

.collection-name-en {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 5px;
    color: #333;
}

.collection-name-ar {
    font-family: 'Amiri', 'Scheherazade New', serif;
    font-size: 18px;
    direction: rtl;
    margin-bottom: 5px;
    color: var(--hadith-green);
}

.collection-list-item .collection-count {
    font-size: 13px;
    color: #999;
}

.collection-list-item .fa-chevron-right {
    color: var(--hadith-green);
    font-size: 20px;
    margin-left: auto;
}

/* ============================================================================
   Collection/Book Info Panels
   ============================================================================ */

.collection-info-panel,
.book-info-panel {
    background: var(--hadith-card-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 30px;
    margin: 0 auto 4px auto;
    max-width: 428px;
    box-shadow: var(--hadith-shadow);
}

.collection-info-panel h3,
.book-info-panel h3 {
    color: var(--hadith-green);
    margin-bottom: 20px;
    font-size: 18px;
}

.collection-details,
.book-details {
    line-height: 1.8;
}

.collection-title-en,
.book-title-en {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

.collection-title-ar,
.book-title-ar {
    font-family: 'Amiri', 'Scheherazade New', serif;
    font-size: 22px;
    direction: rtl;
    text-align: right;
    margin-bottom: 20px;
    color: var(--hadith-green);
}

.collection-details hr,
.book-details hr {
    border: none;
    border-top: 1px solid var(--hadith-border);
    margin: 20px 0;
}

.collection-details p,
.book-details p {
    margin: 10px 0;
    color: #666;
}

/* ============================================================================
   Books List
   ============================================================================ */

.books-list {
    background: var(--hadith-card-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 30px;
    margin: 0 auto 4px auto;
    max-width: 428px;
    box-shadow: var(--hadith-shadow);
}

.books-list h3 {
    color: var(--hadith-green);
    margin-bottom: 20px;
    font-size: 18px;
}

.book-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    border-bottom: 1px solid var(--hadith-border);
    cursor: pointer;
    transition: all 0.3s ease;
}

.book-item:last-child {
    border-bottom: none;
}

.book-item:hover {
    background: rgba(76, 175, 80, 0.05);
    transform: translateX(5px);
}

/* Book Number Label - Top Left Corner */
.book-number-label {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 12px;
    font-weight: bold;
    color: var(--hadith-green);
    background: rgba(76, 175, 80, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Book Icon Wrapper - Becomes button if has bookmarks */
.book-icon-wrapper {
    position: relative;
    min-width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.book-icon-wrapper.has-bookmarks {
    background: var(--bookmark-active);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.book-icon-wrapper.has-bookmarks:hover {
    background: #FFC700;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.5);
}

.book-icon-wrapper .book-icon {
    font-size: 40px;
    text-align: center;
}

.book-icon-wrapper .bookmark-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #d32f2f;
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 8px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.book-content {
    flex: 1;
    text-align: right;
    padding-right: 15px;
}

.book-item .book-title-en {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 5px;
}

.book-item .book-title-ar {
    font-family: 'Amiri', 'Scheherazade New', serif;
    font-size: 16px;
    direction: rtl;
    margin-bottom: 5px;
    color: var(--hadith-green);
}

.book-count {
    font-size: 12px;
    color: #999;
}

.book-item .fa-chevron-right {
    color: var(--hadith-green);
    font-size: 18px;
    margin-left: auto;
}

/* ============================================================================
   Hadiths List
   ============================================================================ */

.hadiths-list {
    background: var(--hadith-card-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 30px;
    margin: 0 auto 4px auto;
    max-width: 428px;
    box-shadow: var(--hadith-shadow);
}

.hadiths-list h3 {
    color: var(--hadith-green);
    margin-bottom: 20px;
    font-size: 18px;
}

/* ============================================================================
   Individual Hadith Item (Expandable)
   ============================================================================ */

.hadith-item {
    padding: 20px;
    border-bottom: 1px solid var(--hadith-border);
    transition: all 0.3s ease;
}

.hadith-item:last-child {
    border-bottom: none;
}

.hadith-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    user-select: none;
}

.hadith-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    background: var(--hadith-green);
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
}

.hadith-toggle:hover {
    background: var(--hadith-green-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.hadith-arrow {
    font-size: 16px;
    color: white;
    transition: all 0.3s ease;
}

.hadith-arrow.expanded {
    /* No rotation needed - icon changes from chevron-down to chevron-up */
}

.hadith-icon {
    font-size: 20px;
}

.hadith-number {
    font-weight: bold;
    color: var(--hadith-green);
}

.hadith-english {
    /* Padding removed - chevron now in hadith-actions */
}

.hadith-narrator {
    font-style: italic;
    color: #666;
    margin-bottom: 10px;
}

.hadith-text {
    line-height: 1.8;
    color: #333;
    margin-bottom: 15px;
}

/* ============================================================================
   Hadith Actions (Bookmark & Copy)
   ============================================================================ */

.hadith-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.bookmark-btn,
.copy-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bookmark-btn {
    background: var(--bookmark-inactive);
    color: white;
}

.bookmark-btn.active {
    background: var(--bookmark-active);
    color: #333;
}

.bookmark-btn:hover {
    transform: translateY(-2px);
}

.copy-btn {
    background: linear-gradient(135deg, var(--hadith-green), var(--hadith-green-dark));
    color: white;
}

.copy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

/* ============================================================================
   Arabic Section (Expandable)
   ============================================================================ */

.hadith-arabic-section {
    margin-top: 20px;
    padding: 20px;
    background: var(--hadith-arabic-bg);
    border-radius: 12px;
    margin-left: 0;
}

.arabic-header {
    font-weight: bold;
    color: var(--hadith-green);
    margin-bottom: 15px;
    font-size: 16px;
}

.hadith-text-arabic {
    font-family: 'Amiri', 'Scheherazade New', serif;
    font-size: 22px;
    line-height: 1.8;
    direction: rtl;
    text-align: right;
    color: #333;
    margin-bottom: 15px;
}

.hadith-arabic-section .copy-btn {
    float: left;
}

/* ============================================================================
   Loading & Error States
   ============================================================================ */

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 16px;
}

.loading::before {
    content: '⏳ ';
    font-size: 24px;
    margin-right: 10px;
}

.error {
    text-align: center;
    padding: 40px;
    color: #d32f2f;
    font-size: 16px;
}

.error::before {
    content: '⚠️ ';
    font-size: 24px;
    margin-right: 10px;
}

.error-message {
    background: rgba(211, 47, 47, 0.1);
    color: #d32f2f;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    margin: 20px 0;
}

/* ============================================================================
   Toast Notifications
   ============================================================================ */

.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 15px 30px;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10000;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-success {
    background: var(--hadith-green);
}

.toast-error {
    background: #d32f2f;
}

.toast-info {
    background: #1976d2;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

/* Tablets */
@media (max-width: 768px) {
    .collection-list-item {
        padding: 15px;
    }
    
    .collection-list-item .collection-icon {
        font-size: 32px;
        min-width: 50px;
    }
    
    .collection-name-en {
        font-size: 16px;
    }
    
    .collection-name-ar {
        font-size: 18px;
    }
    
    .section-header h2 {
        font-size: 20px;
    }
    
    .daily-hadith-content .hadith-text {
        font-size: 16px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    #hadithSection {
        padding: 165px 16px 110px; /* FIXED: Standardized padding for header clearance */
    }
    
    .collection-list-item {
        padding: 12px;
        gap: 10px;
    }
    
    .collection-list-item .collection-icon {
        font-size: 28px;
        min-width: 40px;
    }
    
    .collection-name-en {
        font-size: 14px;
    }
    
    .collection-name-ar {
        font-size: 16px;
    }
    
    .section-header {
        padding: 10px 15px;
    }
    
    .section-header h2 {
        font-size: 18px;
    }
    
    #dailyHadithCard,
    .collection-info-panel,
    .book-info-panel,
    .books-list,
    .hadiths-list {
        padding: 20px;
    }
    
    .daily-hadith-header span {
        font-size: 14px;
    }
    
    .daily-hadith-content .hadith-text {
        font-size: 14px;
    }
    
    .hadith-header {
        /* Chevron no longer uses absolute positioning */
    }
    
    .hadith-english {
        /* Padding removed */
    }
    
    .hadith-arabic-section {
        margin-left: 0;
        padding: 15px;
    }
    
    .hadith-text-arabic {
        font-size: 18px;
    }
    
    .search-panel {
        flex-direction: column;
    }
    
    .search-panel button {
        width: 100%;
        justify-content: center;
    }
    
    .hadith-actions {
        flex-direction: column;
    }
    
    .bookmark-btn,
    .copy-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================================================
   Dark Mode Adjustments
   ============================================================================ */

.dark-mode #hadithSection {
    color: #e0e0e0;
}

.dark-mode .hadith-text,
.dark-mode .collection-title-en,
.dark-mode .book-title-en {
    color: #e0e0e0;
}

.dark-mode .hadith-narrator,
.dark-mode .book-count,
.dark-mode .collection-details p,
.dark-mode .book-details p {
    color: #b0b0b0;
}

.dark-mode .search-panel input {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border-color: rgba(255, 255, 255, 0.2);
}

.dark-mode .hadith-text-arabic {
    color: #e0e0e0;
}

/* ============================================================================
   Load More Button (v1.11 - Pagination)
   ============================================================================ */

.load-more-container {
    padding: 30px 20px;
    text-align: center;
}

.load-more-btn {
    padding: 15px 30px;
    background: linear-gradient(135deg, var(--hadith-green), var(--hadith-green-dark));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.load-more-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.load-more-btn i {
    font-size: 18px;
}

.all-loaded-message {
    padding: 20px;
    text-align: center;
    color: var(--hadith-green);
    font-weight: bold;
    font-size: 16px;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 12px;
    margin: 20px 0;
}

/* ============================================================================
   Data Source Attribution Footer
   ============================================================================ */

.hadith-footer {
    margin-top: 40px;
    padding: 20px;
    text-align: center;
    background: var(--hadith-card-bg);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: var(--hadith-shadow);
}

.data-source {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
}

.data-source a {
    color: var(--hadith-green);
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s ease;
}

.data-source a:hover {
    color: var(--hadith-green-dark);
    text-decoration: underline;
}

.dark-mode .data-source {
    color: #b0b0b0;
}

/* ============================================================================
   Print Styles (Future Enhancement)
   ============================================================================ */

@media print {
    .section-header .back-btn,
    .language-toggle,
    .search-panel,
    .hadith-actions,
    .copy-btn {
        display: none !important;
    }

    .hadith-arabic-section {
        display: block !important;
    }

    .hadith-footer {
        display: block !important;
        page-break-after: avoid;
    }
}
