/**
 * Commentary Styles
 * 
 * أنماط تفسير الكتاب المقدس
 * 
 * @package My_Bible_Plugin
 * @since 2.0.0
 */

/* ============================================
   Container & Layout
   ============================================ */

.bible-commentary-wrapper {
    direction: rtl;
    font-family: 'Noto Naskh Arabic', 'Traditional Arabic', 'Arial', sans-serif;
    line-height: 2;
    color: var(--commentary-text, #333);
    background: var(--commentary-bg, #fff);
}

.commentary-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    flex-wrap: wrap;
    gap: 10px;
}

.commentary-selectors {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
}

.commentary-select {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    cursor: pointer;
    min-width: 120px;
    max-width: 200px;
    transition: all 0.3s ease;
}

.commentary-select:hover {
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.commentary-nav-buttons {
    display: flex;
    gap: 8px;
}

.commentary-nav-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.commentary-nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Read Chapter Button */
.read-chapter-link {
    width: auto !important;
    border-radius: 25px !important;
    padding: 8px 20px !important;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.9) !important;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
}

.read-chapter-link:hover {
    background: rgba(16, 185, 129, 1) !important;
    text-decoration: none;
    color: #fff;
}

.read-chapter-link i {
    font-size: 14px;
}

/* ============================================
   Main Content Area
   ============================================ */

.commentary-main {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 25px;
    align-items: start;
}

/* ============================================
   Table of Contents (TOC) - Sticky
   ============================================ */

.commentary-toc {
    position: sticky;
    top: 80px;
    height: fit-content;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    border-right: 4px solid #667eea;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
    z-index: 100;
}

.commentary-toc h3 {
    margin: 0 0 15px;
    font-size: 16px;
    color: #667eea;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.commentary-toc h3 i {
    font-size: 14px;
}

#commentary-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#commentary-toc-list li {
    margin: 5px 0;
}

#commentary-toc-list a {
    display: block;
    padding: 10px 14px;
    color: #555;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    border-right: 3px solid transparent;
}

#commentary-toc-list a:hover {
    background: #667eea;
    color: #fff;
    border-right-color: #764ba2;
}

#commentary-toc-list a.active {
    background: #667eea;
    color: #fff;
    font-weight: bold;
    border-right-color: #764ba2;
}

#commentary-toc-list .toc-level-2 {
    padding-right: 25px;
    font-size: 13px;
}

.toc-empty {
    color: #999;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

/* ============================================
   Commentary Content - Responsive Text
   ============================================ */

.commentary-content {
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.05);
    min-width: 0; /* مهم للتجاوب */
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

#commentary-text {
    font-size: 18px;
    line-height: 2.2;
}

#commentary-text p {
    margin-bottom: 15px;
    text-align: justify;
    word-break: break-word;
}

/* Headings */
.commentary-heading-1 {
    font-size: 22px;
    color: #667eea;
    margin: 30px 0 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid #667eea;
    word-break: break-word;
}

.commentary-heading-2 {
    font-size: 18px;
    color: #764ba2;
    margin: 25px 0 15px;
    padding-right: 15px;
    border-right: 4px solid #764ba2;
}

/* Verse Text */
.commentary-verse-text {
    background: linear-gradient(135deg, #f5f7fa 0%, #f0f4f8 100%);
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 10px;
    border-right: 5px solid #28a745;
    font-style: italic;
    word-break: break-word;
}

.commentary-verse-text .verse-number {
    display: inline-block;
    background: #28a745;
    color: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 14px;
    font-style: normal;
    margin-left: 8px;
}

/* Dividers */
.commentary-divider {
    border: none;
    height: 2px;
    background: linear-gradient(to right, transparent, #ddd, transparent);
    margin: 30px 0;
}

.commentary-line {
    display: block;
    height: 10px;
}

/* List Numbers */
.list-number {
    display: inline-block;
    background: #667eea;
    color: #fff;
    padding: 2px 10px;
    border-radius: 15px;
    font-size: 14px;
    margin-left: 5px;
}

/* ============================================
   Smart Verse Links
   ============================================ */

.smart-verse-link {
    color: #1a73e8;
    text-decoration: none;
    background: rgba(26, 115, 232, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
}

.smart-verse-link:hover {
    background: #1a73e8;
    color: #fff;
}

/* ============================================
   Verse Modal
   ============================================ */

.verse-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.verse-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
}

.verse-modal-dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    background: #fff;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.verse-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.verse-modal-header h4 {
    margin: 0;
    font-size: 18px;
}

.verse-modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.verse-modal-close:hover {
    opacity: 1;
}

.verse-modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
    font-size: 18px;
    line-height: 2;
    direction: rtl;
}

.verse-modal-body .verse-num {
    display: inline-block;
    background: #667eea;
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 14px;
    margin-left: 8px;
}

/* ============================================
   Loading State
   ============================================ */

.commentary-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #667eea;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   Mobile Floating TOC Button
   ============================================ */

.toc-float-btn {
    display: none;
    position: fixed;
    bottom: 25px;
    left: 25px;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    z-index: 1000;
    transition: all 0.3s ease;
}

.toc-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.5);
}

.toc-float-btn.active {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: rotate(90deg);
}

.toc-mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toc-mobile-overlay.open {
    opacity: 1;
}

/* ============================================
   Navigator (Book Index)
   ============================================ */

.commentary-navigator {
    direction: rtl;
}

.commentary-navigator h2 {
    text-align: center;
    color: #667eea;
    margin-bottom: 30px;
}

.testament-section {
    margin-bottom: 40px;
}

.testament-section h3 {
    color: #764ba2;
    font-size: 20px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.book-card {
    display: block;
    padding: 15px;
    text-align: center;
    background: linear-gradient(135deg, #f5f7fa 0%, #fff 100%);
    border-radius: 10px;
    text-decoration: none;
    color: #333;
    border: 1px solid #eee;
    transition: all 0.3s ease;
}

.book-card:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.3);
}

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

@media (max-width: 992px) {
    .commentary-main {
        grid-template-columns: 220px 1fr;
        gap: 15px;
    }
    
    .commentary-content {
        padding: 20px;
    }
    
    #commentary-text {
        font-size: 17px;
    }
}

@media (max-width: 768px) {
    .commentary-main {
        grid-template-columns: 1fr;
    }
    
    /* Hide TOC by default on mobile */
    .commentary-toc {
        display: block;
        position: fixed;
        top: 0;
        right: -300px;
        width: 280px;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        z-index: 1001;
        transition: right 0.3s ease;
        padding-top: 60px;
    }
    
    .commentary-toc.open {
        right: 0;
    }
    
    /* Show floating button */
    .toc-float-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .toc-mobile-overlay {
        display: block;
        pointer-events: none;
    }
    
    .toc-mobile-overlay.open {
        pointer-events: auto;
    }
    
    /* Close button for mobile TOC */
    .commentary-toc::before {
        content: '✕';
        position: absolute;
        top: 15px;
        left: 15px;
        width: 35px;
        height: 35px;
        background: #667eea;
        color: #fff;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        cursor: pointer;
    }
    
    .commentary-nav {
        padding: 10px;
    }
    
    .commentary-selectors {
        width: 100%;
    }
    
    .commentary-select {
        flex: 1;
        min-width: 0;
        font-size: 14px;
        padding: 8px 10px;
    }
    
    .commentary-content {
        padding: 15px;
        border-radius: 8px;
    }
    
    #commentary-text {
        font-size: 16px;
        line-height: 2;
    }
    
    .commentary-heading-1 {
        font-size: 18px;
    }
    
    .commentary-heading-2 {
        font-size: 16px;
    }
    
    .verse-modal-dialog {
        width: 95%;
        max-height: 85vh;
    }
    
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .commentary-nav-buttons {
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }
    
    .commentary-nav-btn {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    #commentary-text {
        font-size: 15px;
    }
    
    .commentary-verse-text {
        padding: 12px 15px;
        font-size: 14px;
    }
}

/* ============================================
   Dark Mode Support
   ============================================ */

.dark-mode .bible-commentary-wrapper {
    --commentary-text: #e0e0e0;
    --commentary-bg: #1a1a2e;
}

.dark-mode .commentary-toc {
    background: #16213e;
    border-right-color: #667eea;
}

.dark-mode .commentary-toc h3 {
    border-bottom-color: #333;
}

.dark-mode #commentary-toc-list a {
    color: #bbb;
}

.dark-mode #commentary-toc-list a:hover,
.dark-mode #commentary-toc-list a.active {
    background: #667eea;
    color: #fff;
}

.dark-mode .commentary-content {
    background: #0f0f23;
}

.dark-mode .commentary-select {
    background: #16213e;
    color: #e0e0e0;
}

.dark-mode .smart-verse-link {
    background: rgba(102, 126, 234, 0.2);
}

.dark-mode .verse-modal-dialog {
    background: #1a1a2e;
}

.dark-mode .verse-modal-body {
    color: #e0e0e0;
}

.dark-mode .book-card {
    background: #16213e;
    color: #e0e0e0;
    border-color: #333;
}

.dark-mode .commentary-verse-text {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* ============================================
   Scrollbar Styling
   ============================================ */

.commentary-toc::-webkit-scrollbar,
.verse-modal-body::-webkit-scrollbar {
    width: 6px;
}

.commentary-toc::-webkit-scrollbar-track,
.verse-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.commentary-toc::-webkit-scrollbar-thumb,
.verse-modal-body::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

.dark-mode .commentary-toc::-webkit-scrollbar-track,
.dark-mode .verse-modal-body::-webkit-scrollbar-track {
    background: #333;
}

/* ============================================
   Commentary Images (Base64)
   ============================================ */

.commentary-image {
    display: block;
    text-align: center;
    margin: 20px auto;
    max-width: 100%;
}

.commentary-inline-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

.dark-mode .commentary-inline-image {
    border-color: #444;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* للصور الكبيرة */
@media (min-width: 768px) {
    .commentary-image {
        max-width: 80%;
        margin: 25px auto;
    }
}

