/**
 * Online Code Editor Styles
 * Mobile-responsive with preview below editor
 */

/* === Root Variables === */
:root {
    --oce-bg-primary: #1e1e1e;
    --oce-bg-secondary: #252526;
    --oce-bg-tertiary: #2d2d30;
    --oce-bg-hover: #37373d;
    --oce-text-primary: #cccccc;
    --oce-text-secondary: #858585;
    --oce-border-color: #3e3e42;
    --oce-accent-color: #0e639c;
    --oce-accent-hover: #1177bb;
    --oce-success-color: #4ec9b0;
    --oce-danger-color: #f48771;
    --oce-warning-color: #dcdcaa;
    --oce-tab-active: #007acc;
    --oce-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --oce-radius: 6px;
    --oce-transition: all 0.3s ease;
}

/* Light theme variables */
.oce-editor-wrapper[data-theme="light"] {
    --oce-bg-primary: #ffffff;
    --oce-bg-secondary: #f3f3f3;
    --oce-bg-tertiary: #e8e8e8;
    --oce-bg-hover: #d4d4d4;
    --oce-text-primary: #333333;
    --oce-text-secondary: #666666;
    --oce-border-color: #d4d4d4;
    --oce-accent-color: #0078d4;
    --oce-accent-hover: #106ebe;
    --oce-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* === Main Wrapper === */
.oce-editor-wrapper {
    background-color: var(--oce-bg-primary);
    border: 1px solid var(--oce-border-color);
    border-radius: var(--oce-radius);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    box-shadow: var(--oce-shadow);
    margin: 20px 0;
}

/* === Control Bar === */
.oce-control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: var(--oce-bg-secondary);
    border-bottom: 1px solid var(--oce-border-color);
    flex-wrap: wrap;
    gap: 12px;
}

.oce-editor-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--oce-text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.oce-editor-title svg {
    color: var(--oce-accent-color);
}

.oce-control-right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* === Buttons === */
.oce-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background-color: var(--oce-bg-tertiary);
    color: var(--oce-text-primary);
    border: 1px solid var(--oce-border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--oce-transition);
    white-space: nowrap;
}

.oce-btn:hover {
    background-color: var(--oce-bg-hover);
    border-color: var(--oce-accent-color);
}

.oce-btn:active {
    transform: translateY(1px);
}

.oce-btn-run {
    background-color: var(--oce-accent-color);
    color: #ffffff;
    border-color: var(--oce-accent-color);
}

.oce-btn-run:hover {
    background-color: var(--oce-accent-hover);
}

.oce-btn svg {
    width: 16px;
    height: 16px;
}

/* === Main Container === */
.oce-main-container {
    display: flex;
    flex-direction: column;
    min-height: 600px;
}

/* === Editors Section === */
.oce-editors-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--oce-bg-secondary);
}

/* === Tabs === */
.oce-tabs {
    display: flex;
    background-color: var(--oce-bg-tertiary);
    border-bottom: 1px solid var(--oce-border-color);
    overflow-x: auto;
}

.oce-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    background: transparent;
    color: var(--oce-text-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--oce-transition);
    white-space: nowrap;
}

.oce-tab:hover {
    color: var(--oce-text-primary);
    background-color: var(--oce-bg-hover);
}

.oce-tab-active {
    color: var(--oce-text-primary);
    border-bottom-color: var(--oce-tab-active);
}

.oce-tab svg {
    width: 16px;
    height: 16px;
}

/* === Editor Panels === */
.oce-editor-panels {
    flex: 1;
    position: relative;
    min-height: 300px;
}

.oce-editor-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
}

.oce-panel-active {
    display: block;
}

.oce-code-textarea {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    resize: none;
}

/* CodeMirror customization */
.CodeMirror {
    height: 100% !important;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.CodeMirror-gutters {
    background-color: var(--oce-bg-tertiary) !important;
    border-right: 1px solid var(--oce-border-color) !important;
}

.CodeMirror-linenumber {
    color: var(--oce-text-secondary) !important;
}

/* === Preview Section === */
.oce-preview-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--oce-border-color);
    background-color: var(--oce-bg-secondary);
}

.oce-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background-color: var(--oce-bg-tertiary);
    border-bottom: 1px solid var(--oce-border-color);
}

.oce-preview-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--oce-text-primary);
}

.oce-preview-title svg {
    color: var(--oce-success-color);
}

.oce-auto-run-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--oce-text-primary);
    cursor: pointer;
    user-select: none;
}

.oce-auto-run-label input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.oce-preview-container {
    flex: 1;
    position: relative;
    min-height: 300px;
    background-color: #ffffff;
}

#oce-preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    background-color: #ffffff;
}

/* === Fullscreen Modal === */
.oce-fullscreen-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--oce-bg-primary);
    z-index: 999999;
    flex-direction: column;
}

.oce-fullscreen-modal.active {
    display: flex;
}

.oce-fullscreen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background-color: var(--oce-bg-secondary);
    border-bottom: 1px solid var(--oce-border-color);
    color: var(--oce-text-primary);
    font-weight: 600;
}

.oce-btn-close-fullscreen {
    background: transparent;
    border: none;
    color: var(--oce-text-primary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--oce-transition);
}

.oce-btn-close-fullscreen:hover {
    background-color: var(--oce-bg-hover);
}

#oce-fullscreen-frame {
    flex: 1;
    width: 100%;
    border: none;
    background-color: #ffffff;
}

/* === Toast Notification === */
.oce-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 14px 20px;
    background-color: var(--oce-bg-tertiary);
    color: var(--oce-text-primary);
    border: 1px solid var(--oce-border-color);
    border-radius: 6px;
    box-shadow: var(--oce-shadow);
    z-index: 1000000;
    opacity: 0;
    transform: translateY(20px);
    transition: var(--oce-transition);
    pointer-events: none;
    font-size: 14px;
    max-width: 300px;
}

.oce-toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.oce-toast.success {
    border-left: 4px solid var(--oce-success-color);
}

.oce-toast.error {
    border-left: 4px solid var(--oce-danger-color);
}

.oce-toast.info {
    border-left: 4px solid var(--oce-accent-color);
}

/* === Responsive Design === */

/* Tablet and below - Stack editors and preview vertically */
@media screen and (max-width: 1024px) {
    .oce-main-container {
        flex-direction: column;
    }
    
    .oce-editors-section {
        min-height: 350px;
    }
    
    .oce-preview-section {
        min-height: 350px;
        border-top: 1px solid var(--oce-border-color);
        border-left: none;
    }
}

/* Mobile - Smaller controls and fonts */
@media screen and (max-width: 768px) {
    .oce-control-bar {
        padding: 10px 12px;
    }
    
    .oce-editor-title {
        font-size: 14px;
    }
    
    .oce-btn {
        padding: 7px 12px;
        font-size: 12px;
    }
    
    .oce-btn svg {
        width: 14px;
        height: 14px;
    }
    
    .oce-tab {
        padding: 10px 14px;
        font-size: 12px;
    }
    
    .CodeMirror {
        font-size: 13px;
    }
    
    .oce-editors-section {
        min-height: 300px;
    }
    
    .oce-preview-container {
        min-height: 250px;
    }
    
    .oce-toast {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        font-size: 13px;
    }
}

/* Extra small mobile */
@media screen and (max-width: 480px) {
    .oce-control-right {
        width: 100%;
    }
    
    .oce-btn {
        flex: 1;
        justify-content: center;
    }
    
    .oce-editor-title {
        font-size: 13px;
    }
    
    .CodeMirror {
        font-size: 12px;
    }
}

/* === Scrollbar Styling === */
.oce-editor-wrapper ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.oce-editor-wrapper ::-webkit-scrollbar-track {
    background: var(--oce-bg-secondary);
}

.oce-editor-wrapper ::-webkit-scrollbar-thumb {
    background: var(--oce-bg-hover);
    border-radius: 5px;
}

.oce-editor-wrapper ::-webkit-scrollbar-thumb:hover {
    background: var(--oce-border-color);
}

/* === Loading State === */
.oce-editor-panel.loading::before {
    content: 'Loading editor...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--oce-text-secondary);
    font-size: 14px;
}

/* === Animations === */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.oce-editor-wrapper {
    animation: slideUp 0.4s ease;
}

/* === Print Styles === */
@media print {
    .oce-control-bar,
    .oce-tabs,
    .oce-preview-header {
        display: none;
    }
    
    .oce-main-container {
        flex-direction: column;
    }
    
    .oce-preview-section {
        page-break-before: always;
    }
}
