/* Split Mode Grid Container (3:7 Ratio) */
.app-container.split-mode-active .chat-main {
    flex: 3 1 0% !important;
    min-width: 0 !important;
    max-width: none !important;
    border-right: 1px solid var(--border-color);
    transition: flex 0.2s ease;
}

.app-container.split-mode-active .codex-panel {
    flex: 7 1 0% !important;
    min-width: 0 !important;
    max-width: none !important;
    display: flex !important;
    flex-direction: column;
}

.app-container.split-mode-active .chat-scroll-inner {
    padding-left: 14px;
    padding-right: 14px;
    max-width: 100%;
}

.app-container.split-mode-active .input-dock {
    max-width: 100%;
    padding: 0 8px;
}

.app-container.split-mode-active .welcome-screen {
    padding: 20px 10px;
}

.app-container.split-mode-active .quick-prompts-grid {
    grid-template-columns: 1fr;
}

/* Header Toggle Button */
.codex-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 13px;
    border-radius: 20px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.codex-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.codex-toggle-btn.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 14px var(--primary-glow);
}

.codex-toggle-btn .codex-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
}

.codex-toggle-btn.active .codex-live-dot {
    background: #ffffff;
}

/* Code Block Live Preview Button */
.live-preview-btn {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-right: 6px;
    transition: all 0.15s ease;
}

.live-preview-btn:hover {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

/* Codex Main Panel (Right 68-70%) */
.codex-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-sidebar);
    height: 100vh;
    position: relative;
    overflow: hidden;
    z-index: 20;
    animation: fadeIn 0.2s ease;
}

.codex-panel.hidden {
    display: none !important;
}

/* Fullscreen Mode */
.codex-panel.fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    height: 100vh;
    width: 100vw;
}

/* Codex Header Toolbar */
.codex-header {
    height: 56px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-header);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    gap: 12px;
    flex-shrink: 0;
}

.codex-header-left,
.codex-header-center,
.codex-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* View Mode Tabs (Preview / Code / Console) */
.codex-tabs {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}

.codex-tab-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.codex-tab-btn:hover {
    color: var(--text-main);
}

.codex-tab-btn.active {
    background: var(--bg-sidebar);
    color: var(--primary);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.codex-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    font-weight: 700;
}

.codex-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Device View Switcher */
.device-switcher {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}

.device-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    padding: 5px 9px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.device-btn:hover {
    color: var(--text-main);
}

.device-btn.active {
    background: var(--bg-sidebar);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Status Indicator Pill */
.codex-status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.codex-status-pill .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
}

.codex-status-pill.loading .status-dot {
    background: #f59e0b;
}

.codex-status-pill.streaming {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
}

.codex-status-pill.streaming .status-dot {
    background: #6366f1;
    animation: codexPulse 1s infinite alternate;
}

@keyframes codexPulse {
    0% { opacity: 0.4; transform: scale(0.85); }
    100% { opacity: 1; transform: scale(1.2); }
}

.codex-status-pill.error .status-dot {
    background: #ef4444;
}

/* File Tabs Bar */
.codex-file-bar {
    height: 38px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-main);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
    flex-shrink: 0;
}

.codex-file-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.codex-file-tab:hover {
    background: var(--bg-card);
    color: var(--text-main);
}

.codex-file-tab.active {
    background: var(--bg-sidebar);
    color: var(--primary);
    font-weight: 600;
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
}

/* Codex Body Container */
.codex-body {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* View 1: Sandbox Preview */
.codex-view {
    flex: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: absolute;
    inset: 0;
}

.codex-view.hidden {
    display: none !important;
}

.sandbox-frame-wrap {
    flex: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #090d16;
    overflow: hidden;
    padding: 0;
    transition: padding 0.2s ease;
}

.sandbox-frame-wrap.tablet-view {
    padding: 20px 0;
}

.sandbox-frame-wrap.mobile-view {
    padding: 20px 0;
}

.sandbox-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
    transition: width 0.2s ease, height 0.2s ease, border-radius 0.2s ease;
}

.sandbox-frame-wrap.tablet-view .sandbox-iframe {
    width: 768px;
    height: 100%;
    max-height: 96%;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.sandbox-frame-wrap.mobile-view .sandbox-iframe {
    width: 375px;
    height: 100%;
    max-height: 94%;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

/* View 2: Code Editor */
.codex-code-view {
    background: var(--code-bg);
    overflow: auto;
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
}

.codex-code-content {
    color: var(--code-text);
    white-space: pre;
    tab-size: 4;
}

/* View 3: Console Logs & Error Inspector */
.codex-console-view {
    background: #090d16;
    display: flex;
    flex-direction: column;
}

.console-toolbar {
    height: 38px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    font-size: 11.5px;
    color: #94a3b8;
}

.console-clear-btn {
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 11.5px;
    padding: 4px 8px;
    border-radius: 4px;
}

.console-clear-btn:hover {
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.06);
}

.console-logs-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.console-log-item {
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid #3b82f6;
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #e2e8f0;
}

.console-log-item.warn {
    border-left-color: #f59e0b;
    background: rgba(245, 158, 11, 0.06);
    color: #fde68a;
}

.console-log-item.error {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
    color: #fca5a5;
}

.console-log-item.event {
    border-left-color: #10b981;
    background: rgba(16, 185, 129, 0.06);
    color: #a7f3d0;
}

.console-log-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10.5px;
    opacity: 0.75;
}

.console-log-msg {
    word-break: break-all;
    white-space: pre-wrap;
}

.fix-ai-btn {
    align-self: flex-start;
    margin-top: 4px;
    background: #ef4444;
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: opacity 0.15s ease;
}

.fix-ai-btn:hover {
    opacity: 0.9;
}

.console-empty {
    text-align: center;
    color: #475569;
    padding: 40px 0;
    font-size: 13px;
}

/* Share Preview Button Highlight */
.codex-share-btn {
    background: rgba(99, 102, 241, 0.14) !important;
    color: var(--primary) !important;
    border: 1px solid rgba(99, 102, 241, 0.3) !important;
    transition: all 0.2s ease !important;
}

.codex-share-btn:hover {
    background: var(--primary) !important;
    color: #ffffff !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 12px var(--primary-glow) !important;
}

/* Codex Toast Notification */
.codex-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid #334155;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 100000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
}

.codex-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .app-container.split-mode-active {
        flex-direction: column;
    }
    .app-container.split-mode-active .chat-main {
        flex: 1 1 45%;
        max-width: 100%;
        height: 45vh;
    }
    .codex-panel {
        height: 55vh;
    }
}
