/* TAFSIR MAWDOU'I STYLES */
/* Intégration du tafsir thématique dans les pages Coran */

.tafsir-section {
    margin: 0.75rem 0;
    border-right: 4px solid var(--gold, #d4af37);
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

/* Première section : marge supérieure normale */
.tafsir-section:first-of-type {
    margin-top: 1.5rem;
}

/* Dernière section : marge inférieure plus grande pour séparer du contenu suivant */
.tafsir-section:last-of-type {
    margin-bottom: 2.5rem;
}

/* Mode: Hidden - Les sections de tafsir sont complètement cachées */
body[data-tafsir-mode="hidden"] .tafsir-section {
    display: none;
}

/* Mode: Collapsed - Les sections sont visibles mais fermées */
body[data-tafsir-mode="collapsed"] .tafsir-section {
    display: block;
}

/* Mode: Expanded - Toutes les sections ouvertes */
body[data-tafsir-mode="expanded"] .tafsir-section {
    display: block;
}

body[data-tafsir-mode="expanded"] .tafsir-section .tafsir-content {
    max-height: 50000px !important;
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

body[data-tafsir-mode="expanded"] .tafsir-section .chevron {
    transform: rotate(180deg);
}

.tafsir-toggle {
    width: 100%;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.05rem;
    color: #2c3e50;
    transition: background 0.2s;
}

.tafsir-toggle:hover {
    background: #f5f1e8;
}

.tafsir-icon {
    font-size: 1.5rem;
}

.tafsir-label {
    font-weight: 600;
    color: #1a1a1a;
}

.tafsir-verses {
    margin-right: auto;
    color: #d4af37;
    font-weight: 700;
    font-size: 1rem;
    background: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
}

.chevron {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
    fill: #4a5568;
}

.tafsir-section.expanded .chevron {
    transform: rotate(180deg);
}

.tafsir-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease, padding 0.3s ease;
}

.tafsir-section.expanded .tafsir-content {
    max-height: 50000px;
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.tafsir-content p {
    font-size: 1rem;
    line-height: 1.8;
    color: #374151;
    margin-bottom: 1rem;
}

/* Texte arabe dans le tafsir */
[lang="ar"] .tafsir-content p,
.tafsir-content p[lang="ar"],
.tafsir-content p.ar {
    font-family: 'Amiri', serif;
    font-size: 1.25rem;
    line-height: 2.2;
    text-align: right;
    direction: rtl;
}

.tafsir-content p:last-child {
    margin-bottom: 0;
}

/* Settings panel pour les 3 modes */
.tafsir-settings-panel {
    background: white;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.tafsir-settings-panel h4 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
}

.radio-setting {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
    margin-bottom: 0.25rem;
}

.radio-setting:hover {
    background: #f9fafb;
}

.radio-setting input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #d4af37;
}

.radio-setting span {
    flex: 1;
}

/* Dark mode support */
body.dark .tafsir-section {
    background: #0f172a;
    border-right-color: #d4af37;
}

body.dark .tafsir-toggle {
    color: #e2e8f0;
}

body.dark .tafsir-toggle:hover {
    background: #374151;
}

body.dark .tafsir-verses {
    background: #1a202c;
    color: #fbbf24;
}

body.dark .tafsir-content p {
    color: #cbd5e0;
}

body.dark .tafsir-settings-panel {
    background: #2d3748;
}

body.dark .tafsir-settings-panel h4 {
    color: #e2e8f0;
}

body.dark .radio-setting:hover {
    background: #374151;
}

/* Bouton "Lire les versets" */
.tafsir-read-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #d4af37 0%, #8B6508 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.tafsir-read-btn:hover {
    background: linear-gradient(135deg, #8B6508 0%, #9a7a1a 100%);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.5);
    transform: translateY(-2px);
}

.tafsir-read-btn:active {
    transform: translateY(0);
}

.tafsir-read-btn svg {
    flex-shrink: 0;
}

/* Versets bornés (section tafsir active) */
.aya.tafsir-bounded {
    background: linear-gradient(to right, rgba(212, 175, 55, 0.12), rgba(212, 175, 55, 0.03));
    border-right: 5px solid #d4af37;
    padding: 1.5rem;
    margin: 0.5rem 0;
    border-radius: 4px;
    transition: all 0.3s ease;
    position: relative;
}

/* Badge indicateur sur le premier verset de la plage */
.aya.tafsir-bounded.tafsir-first::before {
    content: attr(data-verse-range);
    position: absolute;
    top: -12px;
    right: 16px;
    background: linear-gradient(135deg, #d4af37 0%, #8B6508 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: 'Amiri', serif;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.4);
    z-index: 10;
}

/* Premier et dernier verset marqués différemment */
.aya.tafsir-bounded.tafsir-first {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    margin-top: 1.5rem;
    border-right-width: 6px;
}

.aya.tafsir-bounded.tafsir-last {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    margin-bottom: 2rem;
    border-right-width: 6px;
}

/* Flash effect sur le premier verset */
.aya.tafsir-flash {
    animation: tafsirFlash 2s ease-out;
}

@keyframes tafsirFlash {
    0% {
        background: rgba(212, 175, 55, 0.4);
        border-right-color: #d4af37;
        border-right-width: 6px;
    }
    50% {
        background: rgba(212, 175, 55, 0.2);
    }
    100% {
        background: rgba(212, 175, 55, 0.08);
        border-right-width: 4px;
    }
}

/* Dark mode support pour les versets bornés */
body.dark .aya.tafsir-bounded {
    background: linear-gradient(to right, rgba(212, 175, 55, 0.2), rgba(212, 175, 55, 0.08));
    border-right-color: #fbbf24;
}

body.dark .aya.tafsir-bounded.tafsir-first::before,
body.dark .aya.tafsir-bounded.tafsir-last::after {
    background: linear-gradient(135deg, #fbbf24 0%, #d4af37 100%);
    color: #1a202c;
}

body.dark .tafsir-read-btn {
    background: linear-gradient(135deg, #fbbf24 0%, #d4af37 100%);
    color: #1a202c;
}

body.dark .tafsir-read-btn:hover {
    background: linear-gradient(135deg, #f59e0b 0%, #8B6508 100%);
}

/* Responsive */
@media (max-width: 768px) {
    .tafsir-toggle {
        font-size: 0.95rem;
        padding: 1rem 1.25rem;
    }

    .tafsir-verses {
        font-size: 1rem;
    }

    .tafsir-content p {
        font-size: 1rem;
        line-height: 2;
    }

    .tafsir-read-btn {
        font-size: 0.9rem;
        padding: 0.65rem 1.25rem;
    }

    .aya.tafsir-bounded {
        padding: 1rem;
        border-right-width: 3px;
    }

    .aya.tafsir-bounded.tafsir-first {
        border-right-width: 5px;
        margin-top: 1rem;
    }

    .aya.tafsir-bounded.tafsir-last {
        border-right-width: 5px;
    }

    .aya.tafsir-bounded.tafsir-first::before {
        font-size: 0.8rem;
        padding: 3px 10px;
        top: -10px;
        right: 12px;
    }
}
