/* ==================== Classic Editor ==================== */
.ce-wrapper {
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    margin-bottom: 12px;
    font-family: Tahoma, Vazir, sans-serif;
    transition: border-color 0.2s;
}
.ce-wrapper:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.ce-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    padding: 8px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    align-items: center;
}

.ce-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    color: #374151;
    transition: all 0.15s;
    user-select: none;
    line-height: 1;
}
.ce-btn:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}
.ce-btn.active {
    background: #6366f1;
    color: #fff;
    border-color: #4f46e5;
}
.ce-btn b, .ce-btn i, .ce-btn u, .ce-btn s { font-size: 15px; }
.ce-sep {
    width: 1px;
    height: 22px;
    background: #d1d5db;
    margin: 0 4px;
}

.ce-editable {
    min-height: 200px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 16px;
    line-height: 2;
    outline: none;
    color: #1f2937;
    font-size: 15px;
    word-wrap: break-word;
}
.ce-editable:empty::before {
    content: attr(data-placeholder);
    color: #9ca3af;
    pointer-events: none;
}
.ce-editable h1, .ce-editable h2, .ce-editable h3, .ce-editable h4 {
    margin: 16px 0 8px;
    font-weight: 700;
    color: #1f2937;
}
.ce-editable h1 { font-size: 1.8rem; }
.ce-editable h2 { font-size: 1.5rem; }
.ce-editable h3 { font-size: 1.25rem; }
.ce-editable h4 { font-size: 1.1rem; }
.ce-editable p { margin: 8px 0; }
.ce-editable ul, .ce-editable ol { margin: 8px 0; padding-right: 24px; }
.ce-editable li { margin: 4px 0; }
.ce-editable blockquote {
    border-right: 4px solid #6366f1;
    padding: 8px 16px;
    margin: 12px 0;
    background: #f9fafb;
    color: #4b5563;
    font-style: italic;
    border-radius: 4px;
}
.ce-editable pre, .ce-editable code {
    background: #1f2937;
    color: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    direction: ltr;
    text-align: left;
    display: inline-block;
    font-size: 0.9em;
}
.ce-editable pre {
    display: block;
    padding: 12px;
    overflow-x: auto;
    margin: 12px 0;
}
.ce-editable img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
    cursor: pointer;
}
.ce-editable a { color: #0d6efd; text-decoration: underline; }

.ce-source {
    width: 100%;
    min-height: 300px;
    padding: 16px;
    border: none;
    outline: none;
    font-family: monospace;
    direction: ltr;
    text-align: left;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    background: #f9fafb;
    color: #1f2937;
}

/* Fullscreen */
.ce-wrapper.ce-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    border-radius: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}
.ce-wrapper.ce-fullscreen .ce-editable {
    max-height: none;
    flex: 1;
    font-size: 17px;
}

/* Dark mode */
.ce-wrapper.ce-dark {
    background: #1f2937;
    border-color: #374151;
}
.ce-wrapper.ce-dark .ce-toolbar {
    background: #111827;
    border-bottom-color: #374151;
}
.ce-wrapper.ce-dark .ce-btn {
    color: #d1d5db;
}
.ce-wrapper.ce-dark .ce-btn:hover {
    background: #374151;
}
.ce-wrapper.ce-dark .ce-editable {
    color: #e5e7eb;
    background: #1f2937;
}
.ce-wrapper.ce-dark .ce-editable h1,
.ce-wrapper.ce-dark .ce-editable h2,
.ce-wrapper.ce-dark .ce-editable h3,
.ce-wrapper.ce-dark .ce-editable h4 {
    color: #f9fafb;
}

/* Mobile */
@media (max-width: 768px) {
    .ce-toolbar { padding: 6px; gap: 2px; }
    .ce-btn { min-width: 30px; height: 30px; font-size: 13px; padding: 0 6px; }
    .ce-editable { padding: 12px; font-size: 14px; min-height: 180px; }
    .ce-sep { margin: 0 2px; }
}