/* ==========================================================
   Custom Editor Module - Layout & Styling
   ========================================================== */

/* ---- Split Pane Layout ---- */
.ce-split-pane {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.ce-editor-panel {
    flex: 0 0 60%;
    min-width: 320px;
    max-width: 100%;
}

.ce-preview-panel {
    flex: 1;
    min-width: 280px;
}

/* ---- Tab Buttons ---- */
.ce-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
}

.ce-tab-btn {
    flex: 1;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-bottom-color 0.2s;
    background: #f9fafb;
    color: #6b7280;
    border-bottom: 2px solid transparent;
}

.ce-tab-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.ce-tab-btn.active {
    background: #fff;
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* ---- Toolbar ---- */
.ce-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.ce-toolbar .btn {
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.ce-toolbar .btn-save {
    background: #2563eb;
    color: #fff;
    border: 1px solid #2563eb;
}

.ce-toolbar .btn-save:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.ce-toolbar .btn-reset {
    background: #fff;
    color: #dc2626;
    border: 1px solid #fca5a5;
}

.ce-toolbar .btn-reset:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

.ce-toolbar .btn-preview {
    background: #fff;
    color: #0891b2;
    border: 1px solid #a5f3fc;
}

.ce-toolbar .btn-preview:hover {
    background: #ecfeff;
    border-color: #0891b2;
}

/* ---- Code Textarea ---- */
.ce-code-textarea {
    width: 100%;
    min-height: 340px;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.6;
    padding: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #1e1e2e;
    color: #cdd6f4;
    resize: vertical;
    tab-size: 2;
    white-space: pre;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ce-code-textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.ce-code-textarea::placeholder {
    color: #585b70;
}

.ce-code-textarea::-webkit-scrollbar {
    width: 8px;
}

.ce-code-textarea::-webkit-scrollbar-track {
    background: #1e1e2e;
    border-radius: 0 8px 8px 0;
}

.ce-code-textarea::-webkit-scrollbar-thumb {
    background: #45475a;
    border-radius: 4px;
}

.ce-code-textarea::-webkit-scrollbar-thumb:hover {
    background: #585b70;
}

/* ---- Preview Iframe ---- */
.ce-preview-wrapper {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
}

.ce-preview-header {
    padding: 10px 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
}

.ce-preview-header span {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.ce-preview-iframe {
    width: 100%;
    min-height: 440px;
    border: none;
    background: #fff;
    display: block;
}

.ce-preview-body {
    padding: 8px;
}

/* ---- History Panel ---- */
.ce-history-panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
}

.ce-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.ce-history-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: #111827;
}

.ce-history-header .badge {
    font-size: 12px;
    color: #9ca3af;
}

.ce-history-list {
    max-height: 260px;
    overflow-y: auto;
}

.ce-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}

.ce-history-item:hover {
    background: #f9fafb;
}

.ce-history-item.current {
    background: #f0fdf4;
}

.ce-history-item-info {
    flex: 1;
    min-width: 0;
}

.ce-history-item-title {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
}

.ce-history-item-date {
    font-size: 12px;
    color: #9ca3af;
}

.ce-history-item-note {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

.ce-history-actions {
    display: flex;
    gap: 6px;
    margin-left: 12px;
}

.ce-history-actions .btn {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
}

.ce-history-btn-preview {
    background: #fff;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s;
}

.ce-history-btn-preview:hover {
    background: #f3f4f6;
    color: #374151;
}

.ce-history-btn-restore {
    background: #fff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    cursor: pointer;
    transition: all 0.2s;
}

.ce-history-btn-restore:hover {
    background: #eff6ff;
    border-color: #2563eb;
}

.ce-history-empty {
    text-align: center;
    padding: 20px 0;
    color: #9ca3af;
    font-size: 13px;
}

/* ---- Enable/Disable Toggle ---- */
.ce-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ce-toggle-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- Section Labels ---- */
.ce-section-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Panel Container ---- */
.ce-panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
}

.ce-panel-body {
    padding: 16px;
}

/* ---- Responsive: collapse on mobile ---- */
@media (max-width: 768px) {
    .ce-split-pane {
        flex-direction: column;
    }

    .ce-editor-panel {
        flex: 1 1 100%;
        min-width: unset;
        max-width: 100%;
    }

    .ce-preview-panel {
        flex: 1 1 100%;
        min-width: unset;
    }

    .ce-code-textarea {
        min-height: 220px;
        font-size: 12px;
    }

    .ce-preview-iframe {
        min-height: 280px;
    }

    .ce-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .ce-toolbar .btn {
        justify-content: center;
    }

    .ce-tabs {
        flex-direction: row;
    }

    .ce-tab-btn {
        font-size: 12px;
        padding: 8px 12px;
    }

    .ce-history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .ce-history-actions {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    .ce-code-textarea {
        min-height: 180px;
        font-size: 11px;
        padding: 10px;
    }

    .ce-preview-iframe {
        min-height: 200px;
    }

    .ce-history-panel {
        padding: 14px;
    }
}
