/* ==========================================================================
   Bluecake Native Rich Content Editor (BluecakeRichEditor v1.0)
   Designed specifically for Bluecake OS Enterprise UI/UX
   ========================================================================== */

.bluecake-editor-container {
    display: flex;
    flex-direction: column;
    background-color: var(--bc-card-bg, #ffffff);
    border: 1px solid var(--bc-border-subtle, #cbd5e1);
    border-radius: 16px;
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: 'Tajawal', sans-serif !important;
}

.bluecake-editor-container:focus-within {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12), 0 4px 20px -2px rgba(15, 23, 42, 0.08) !important;
}

/* Header Menubar */
.bc-editor-menubar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    user-select: none;
}

[data-bs-theme="dark"] .bc-editor-menubar,
body.dark-mode .bc-editor-menubar {
    background-color: #0f172a;
    border-bottom-color: #1e293b;
}

.bc-editor-menu-item {
    position: relative;
}

.bc-editor-menu-btn {
    background: transparent;
    border: none;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.bc-editor-menu-btn:hover,
.bc-editor-menu-btn.active {
    background-color: #e2e8f0;
    color: #0f172a;
}

[data-bs-theme="dark"] .bc-editor-menu-btn,
body.dark-mode .bc-editor-menu-btn {
    color: #94a3b8;
}

[data-bs-theme="dark"] .bc-editor-menu-btn:hover,
body.dark-mode .bc-editor-menu-btn:hover {
    background-color: #1e293b;
    color: #f8fafc;
}

/* Dropdown Menu Overlay */
.bc-editor-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1060;
    min-width: 200px;
    padding: 6px;
    margin-top: 4px;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    display: none;
}

[dir="ltr"] .bc-editor-dropdown-menu {
    right: auto;
    left: 0;
}

.bc-editor-dropdown-menu.show {
    display: block;
    animation: bcEditorFadeIn 0.15s ease-out;
}

@keyframes bcEditorFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

[data-bs-theme="dark"] .bc-editor-dropdown-menu,
body.dark-mode .bc-editor-dropdown-menu {
    background-color: #1e293b;
    border-color: #334155;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.bc-editor-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: right;
    transition: background-color 0.12s ease, color 0.12s ease;
}

[dir="ltr"] .bc-editor-dropdown-item {
    text-align: left;
}

.bc-editor-dropdown-item:hover {
    background-color: #f1f5f9;
    color: #2563eb;
}

[data-bs-theme="dark"] .bc-editor-dropdown-item,
body.dark-mode .bc-editor-dropdown-item {
    color: #cbd5e1;
}

[data-bs-theme="dark"] .bc-editor-dropdown-item:hover,
body.dark-mode .bc-editor-dropdown-item:hover {
    background-color: #334155;
    color: #38bdf8;
}

.bc-editor-dropdown-divider {
    height: 1px;
    margin: 4px 0;
    background-color: #e2e8f0;
}

[data-bs-theme="dark"] .bc-editor-dropdown-divider,
body.dark-mode .bc-editor-dropdown-divider {
    background-color: #334155;
}

/* Secondary Command Toolbar */
.bc-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
}

[data-bs-theme="dark"] .bc-editor-toolbar,
body.dark-mode .bc-editor-toolbar {
    background-color: #0f172a;
    border-bottom-color: #1e293b;
}

.bc-editor-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.bc-editor-separator {
    width: 1px;
    height: 22px;
    margin: 0 4px;
    background-color: #cbd5e1;
}

[data-bs-theme="dark"] .bc-editor-separator,
body.dark-mode .bc-editor-separator {
    background-color: #334155;
}

.bc-editor-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #475569;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.bc-editor-btn:hover {
    background-color: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}

.bc-editor-btn.active {
    background-color: #e0f2fe !important;
    color: #0284c7 !important;
    border-color: #bae6fd !important;
    font-weight: 700;
}

[data-bs-theme="dark"] .bc-editor-btn,
body.dark-mode .bc-editor-btn {
    color: #94a3b8;
}

[data-bs-theme="dark"] .bc-editor-btn:hover,
body.dark-mode .bc-editor-btn:hover {
    background-color: #1e293b;
    color: #f8fafc;
    border-color: #334155;
}

[data-bs-theme="dark"] .bc-editor-btn.active,
body.dark-mode .bc-editor-btn.active {
    background-color: rgba(56, 189, 248, 0.15) !important;
    color: #38bdf8 !important;
    border-color: rgba(56, 189, 248, 0.3) !important;
}

.bc-editor-select {
    height: 34px;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s ease;
}

[data-bs-theme="dark"] .bc-editor-select,
body.dark-mode .bc-editor-select {
    background-color: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

/* Color Picker Popover */
.bc-color-palette {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    padding: 8px;
}

.bc-color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.12s ease;
}

.bc-color-swatch:hover {
    transform: scale(1.15);
}

/* Editor Main Content Area */
.bc-editor-body {
    position: relative;
    min-height: 420px;
    max-height: 700px;
    overflow-y: auto;
    padding: 24px;
    background-color: #ffffff;
    color: #0f172a;
    font-size: 15px;
    line-height: 1.7;
    outline: none !important;
    direction: rtl;
    text-align: right;
}

[data-bs-theme="dark"] .bc-editor-body,
body.dark-mode .bc-editor-body {
    background-color: #090d16;
    color: #f8fafc;
}

/* Placeholder support */
.bc-editor-body[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
    display: block;
}

/* WYSIWYG Content Elements Inside Editor */
.bc-editor-body h1, .bc-editor-body h2, .bc-editor-body h3, 
.bc-editor-body h4, .bc-editor-body h5, .bc-editor-body h6 {
    font-weight: 800;
    color: #0f172a;
    margin-top: 1.2em;
    margin-bottom: 0.6em;
}

[data-bs-theme="dark"] .bc-editor-body h1, 
[data-bs-theme="dark"] .bc-editor-body h2, 
[data-bs-theme="dark"] .bc-editor-body h3 {
    color: #f8fafc;
}

.bc-editor-body blockquote {
    margin: 16px 0;
    padding: 12px 20px;
    border-right: 4px solid #2563eb;
    background-color: #f8fafc;
    border-radius: 0 12px 12px 0;
    color: #334155;
    font-style: italic;
}

[dir="ltr"] .bc-editor-body blockquote {
    border-right: none;
    border-left: 4px solid #2563eb;
    border-radius: 12px 0 0 12px;
}

.bc-editor-body pre {
    background-color: #0f172a;
    color: #38bdf8;
    padding: 16px;
    border-radius: 12px;
    font-family: monospace;
    font-size: 14px;
    overflow-x: auto;
    direction: ltr;
    text-align: left;
}

.bc-editor-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.bc-editor-body table th,
.bc-editor-body table td {
    border: 1px solid #cbd5e1;
    padding: 10px 14px;
    text-align: right;
}

[dir="ltr"] .bc-editor-body table th,
[dir="ltr"] .bc-editor-body table td {
    text-align: left;
}

.bc-editor-body table th {
    background-color: #f1f5f9;
    font-weight: 700;
}

.bc-editor-body img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 12px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Status Bar */
.bc-editor-statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px 16px;
    background-color: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    user-select: none;
}

[data-bs-theme="dark"] .bc-editor-statusbar,
body.dark-mode .bc-editor-statusbar {
    background-color: #0f172a;
    border-top-color: #1e293b;
    color: #94a3b8;
}

.bc-editor-path {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: monospace;
    font-size: 11px;
}

.bc-editor-stats {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Custom Table Controls Floating Context Toolbar */
.bc-table-context-bar {
    position: absolute;
    z-index: 1050;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background-color: #0f172a;
    color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.bc-table-context-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.bc-table-context-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}
