/**
 * BaseEditor - Lightweight Rich Text Editor Styles
 * Scoped under .base-editor to prevent global pollution
 */

.base-editor-container {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    /* overflow: hidden; */
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    text-align: right;
    direction: rtl;
}

.base-editor-container:focus-within {
    border-color: #249E94;
    box-shadow: 0 0 0 3px rgba(36, 158, 148, 0.1);
}

.base-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 6px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    gap: 2px;
    border-top-left-radius: 7px;
    border-top-right-radius: 7px;
}

.base-editor-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.base-editor-btn:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.base-editor-btn.active {
    background: #e2e8f0;
    color: #249E94;
    border-color: rgba(36, 158, 148, 0.2);
}

.base-editor-btn i {
    width: 18px;
    height: 18px;
}

.base-editor-divider {
    width: 1px;
    height: 20px;
    background: #e2e8f0;
    margin: 0 6px;
}

.base-editor-content {
    padding: 16px;
    min-height: 120px;
    outline: none;
    line-height: 1.8;
    color: #334155;
    overflow-y: auto;
    font-size: 0.95rem;
    position: relative;
}

.base-editor-content:empty::before {
    content: attr(placeholder);
    position: absolute;
    color: #94a3b8;
    pointer-events: none;
    display: block; /* For empty state */
}

/* Base styles for contenteditable area */
.base-editor-content p {
    margin-bottom: 12px;
    min-height: 1.2em; /* Ensure empty paragraphs are clickable */
}

.base-editor-content blockquote {
    border-right: 4px solid #249E94;
    padding: 8px 16px;
    margin: 16px 0;
    background: #f0fdfa;
    color: #475569;
    border-radius: 4px 0 0 4px;
}

.base-editor-content ul,
.base-editor-content ol {
    padding-right: 28px;
    margin-bottom: 16px;
}

.base-editor-content li {
    margin-bottom: 4px;
}

.base-editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 0.75rem;
    color: #94a3b8;
    border-bottom-left-radius: 7px;
    border-bottom-right-radius: 7px;
}

.base-editor-char-counter.limit-near {
    color: #f59e0b;
}

.base-editor-char-counter.limit-exceeded {
    color: #ef4444;
    font-weight: bold;
}

.base-editor-preview {
    display: none;
    padding: 16px;
    min-height: 120px;
    background: #fff;
    line-height: 1.8;
    color: #334155;
    overflow-y: auto;
}

.base-editor-container.preview-mode .base-editor-content {
    display: none;
}

.base-editor-container.preview-mode .base-editor-preview {
    display: block;
}

.base-editor-container.preview-mode .base-editor-toolbar .base-editor-btn:not(.preview-toggle) {
    opacity: 0.5;
    pointer-events: none;
}

.base-editor-container.disabled {
    background: #f1f5f9;
}

.base-editor-container.disabled .base-editor-content {
    cursor: not-allowed;
    color: #94a3b8;
}

/* Tooltip (optional, simple CSS implementation) */
.base-editor-btn[data-title]:hover::after {
    content: attr(data-title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    margin-bottom: 5px;
    z-index: 10;
}
