/* =========================================================================
   ISLAM ATLAS — Evrensel Zengin Metin Editörü (Rich Text Editor) CSS
   %100 Ücretsiz, Sıfır Harici API Gereksinimi, Tamamen Yerel ve Güçlü
   ========================================================================= */

.rich-editor-wrapper {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color, #dcdcdc);
    border-radius: var(--radius-md, 8px);
    background: var(--bg-card, #ffffff);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 0.5rem;
    font-family: inherit;
}

.rich-editor-wrapper:focus-within {
    border-color: var(--color-primary-600, #10b981);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* Tam Ekran Modu */
.rich-editor-wrapper.rich-editor-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
}

.rich-editor-wrapper.rich-editor-fullscreen .rich-editor-content {
    flex: 1;
    max-height: none !important;
    height: calc(100vh - 120px) !important;
}

/* =========================================================================
   Araç Çubuğu (Toolbar)
   ========================================================================= */
.rich-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.65rem;
    background: var(--bg-secondary, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    user-select: none;
}

.rich-editor-group {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    background: var(--bg-card, #ffffff);
    padding: 0.15rem 0.25rem;
    border-radius: 6px;
    border: 1px solid var(--border-color, #e2e8f0);
}

.rich-editor-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 0.4rem;
    border: none;
    background: transparent;
    color: var(--text-primary, #1e293b);
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.rich-editor-btn:hover {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-primary-800, #047857);
}

.rich-editor-btn.active {
    background: var(--color-primary-700, #047857);
    color: #ffffff;
}

.rich-editor-btn svg {
    width: 15px;
    height: 15px;
    stroke-width: 2.2;
}

/* Özel İslami ve Akademik Butonlar */
.rich-editor-btn-special {
    background: rgba(201, 156, 45, 0.12);
    color: #92690d;
    border: 1px solid rgba(201, 156, 45, 0.3);
    font-size: 0.78rem;
    padding: 0 0.5rem;
    gap: 0.25rem;
}

.rich-editor-btn-special:hover {
    background: #c99c2d;
    color: #ffffff;
}

/* Seçim Menüsü (Format / Başlık) */
.rich-editor-select {
    height: 28px;
    padding: 0 0.5rem;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 4px;
    background: var(--bg-card, #ffffff);
    color: var(--text-primary, #1e293b);
    font-size: 0.82rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
}

.rich-editor-select:focus {
    border-color: var(--color-primary-600, #10b981);
}

/* =========================================================================
   İçerik Yazım Alanı (Content Editable & HTML Code Area)
   ========================================================================= */
.rich-editor-content {
    min-height: 280px;
    max-height: 550px;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    background: var(--bg-card, #ffffff);
    color: var(--text-primary, #1e293b);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.75;
    outline: none;
}

.rich-editor-content[placeholder]:empty:before {
    content: attr(placeholder);
    color: var(--text-muted, #94a3b8);
    cursor: text;
}

/* HTML Kaynak Kodu Görünümü */
.rich-editor-source {
    display: none;
    width: 100%;
    min-height: 280px;
    max-height: 550px;
    padding: 1rem;
    border: none;
    outline: none;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.88rem;
    line-height: 1.6;
    background: #1e293b;
    color: #f1f5f9;
    resize: vertical;
}

.rich-editor-wrapper.show-source .rich-editor-content {
    display: none;
}
.rich-editor-wrapper.show-source .rich-editor-source {
    display: block;
}

/* =========================================================================
   Editör İçi Tipografi ve Özel Akademik Şablonlar
   ========================================================================= */
.rich-editor-content h1,
.rich-editor-content h2,
.rich-editor-content h3,
.rich-editor-content h4 {
    color: var(--color-primary-800, #065f46);
    margin-top: 1.25rem;
    margin-bottom: 0.65rem;
    font-weight: 800;
    line-height: 1.35;
}

.rich-editor-content h2 {
    font-size: 1.35rem;
    border-bottom: 2px solid rgba(16, 185, 129, 0.2);
    padding-bottom: 0.35rem;
}

.rich-editor-content h3 {
    font-size: 1.15rem;
}

.rich-editor-content p {
    margin-bottom: 1rem;
}

.rich-editor-content blockquote.academic-quote {
    margin: 1.25rem 0;
    padding: 1rem 1.35rem;
    border-left: 4px solid var(--color-gold-500, #c99c2d);
    background: rgba(201, 156, 45, 0.07);
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: var(--text-primary);
}

.rich-editor-content blockquote.academic-quote .quote-author {
    display: block;
    font-style: normal;
    font-weight: 700;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    color: var(--color-gold-700, #8a6818);
}

/* Ayet Kutusu */
.rich-editor-content .quran-academic-box {
    margin: 1.5rem 0;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, rgba(20, 89, 68, 0.08) 0%, rgba(201, 156, 45, 0.05) 100%);
    border: 1px solid rgba(20, 89, 68, 0.2);
    border-radius: 12px;
    text-align: center;
}

.rich-editor-content .quran-academic-box .arabic-text {
    font-family: 'Amiri', 'Traditional Arabic', serif;
    font-size: 1.45rem;
    line-height: 2.2;
    direction: rtl;
    color: var(--color-primary-900, #064e3b);
    margin-bottom: 0.65rem;
}

.rich-editor-content .quran-academic-box .turkish-translation {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-style: italic;
    line-height: 1.6;
    margin-bottom: 0.4rem;
}

.rich-editor-content .quran-academic-box .source-ref {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-gold-700, #b45309);
}

/* Bilgi Kutusu */
.rich-editor-content .academic-info-box {
    margin: 1.25rem 0;
    padding: 1rem 1.25rem;
    background: rgba(59, 130, 246, 0.08);
    border-left: 4px solid #3b82f6;
    border-radius: 0 8px 8px 0;
}

/* Tablolar */
.rich-editor-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0;
    font-size: 0.92rem;
}

.rich-editor-content table th,
.rich-editor-content table td {
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border-color, #e2e8f0);
}

.rich-editor-content table th {
    background: var(--bg-secondary, #f8fafc);
    font-weight: 700;
    color: var(--color-primary-800, #065f46);
}

.rich-editor-content ul,
.rich-editor-content ol {
    padding-left: 1.75rem;
    margin-bottom: 1rem;
}

.rich-editor-content a {
    color: var(--color-primary-600, #059669);
    text-decoration: underline;
    font-weight: 600;
}

/* =========================================================================
   Alt Durum Çubuğu (Footer & 1500+ Kelime Sayacı)
   ========================================================================= */
.rich-editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.45rem 0.85rem;
    background: var(--bg-secondary, #f8fafc);
    border-top: 1px solid var(--border-color, #e2e8f0);
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
    user-select: none;
}

.rich-editor-word-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.76rem;
    transition: all 0.2s ease;
}

.rich-editor-word-badge.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.rich-editor-word-badge.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* =========================================================================
   Modal Dialogları (Link, Ayet, Hadis Ekleme Penceresi)
   ========================================================================= */
.rich-editor-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    backdrop-filter: blur(2px);
}

.rich-editor-dialog {
    background: var(--bg-card, #ffffff);
    border-radius: var(--radius-lg, 12px);
    width: 90%;
    max-width: 520px;
    padding: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color, #e2e8f0);
    animation: fadeInModal 0.2s ease-out;
}

.rich-editor-dialog h4 {
    margin: 0 0 1rem 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--color-primary-800, #065f46);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rich-editor-dialog label {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    color: var(--text-primary);
}

.rich-editor-dialog input,
.rich-editor-dialog textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.85rem;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
    background: var(--bg-body, #ffffff);
    color: var(--text-primary);
    font-size: 0.9rem;
    box-sizing: border-box;
}

.rich-editor-dialog input:focus,
.rich-editor-dialog textarea:focus {
    outline: none;
    border-color: var(--color-primary-600, #10b981);
}

.rich-editor-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}
