/* Mixgo 仿真系统主界面样式：工具栏、布局、面板（原 mixgo_sowl_app.css，已统一到 common） */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --bg-panel: #1e2746;
    --text-primary: #eaeaea;
    --text-secondary: #a0a0a0;
    --accent-primary: #e94560;
    --accent-secondary: #0f4c75;
    --accent-success: #4caf50;
    --border-color: #2a3f5f;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100%;
    max-width: 100%;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

@supports (height: 1dvh) {
    body, .app-container {
        height: 100dvh;
    }
}

@supports not (height: 1dvh) {
    body, .app-container {
        height: 100vh;
    }
}

/* 工具栏：绝对定位，隐藏时不占流式布局空间，下面主区域可顶到顶端 */
.toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 20px;
    height: 36px;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 10px var(--shadow-color);
    z-index: 200;
    /* 默认隐藏在顶部之外；显示时滑入，主区域同步留出顶部间距 */
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.18s ease-out, opacity 0.18s ease-out;
}

.app-container.show-toolbar .toolbar {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* 主区域：横向铺满；工具栏显示时留出 36px 避免被遮挡 */
.main-content {
    padding-top: 0;
    transition: padding-top 0.18s ease-out;
    display: flex;
    flex: 1 1 0%;
    overflow: hidden;
    min-width: 0;
    width: 100%;
    max-width: 100%;
}
.app-container.show-toolbar .main-content {
    padding-top: 36px;
}

/* 左上角半透明圆角竖条：贴边，仅显示竖排「仿真」文字 */
.toolbar-trigger {
    position: absolute;
    top: 0;
    left: 0;
    width: 18px;
    height: 32px;
    border-radius: 8px;
    background: rgba(30, 39, 70, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
    z-index: 201;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    transition: background 0.2s ease, transform 0.2s ease, color 0.2s ease;
}
.toolbar-trigger:hover {
    background: rgba(30, 39, 70, 0.55);
    transform: scale(1.05);
    color: #fff;
}
.toolbar-trigger:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-primary);
}
.toolbar-trigger-label {
    font-size: 10px;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: 0.02em;
    writing-mode: vertical-rl;
    text-orientation: upright;
}
.app-container.show-toolbar .toolbar-trigger {
    background: rgba(233, 69, 96, 0.2);
    border-color: rgba(233, 69, 96, 0.35);
}

.toolbar-left, .toolbar-center, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo { display: flex; align-items: center; }
.logo-icon { height: 26px; width: auto; object-fit: contain; display: block; }

.btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px var(--shadow-color);
}
.btn-icon { font-size: 12px; }
.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover:not(:disabled) { background: var(--border-color); }
.btn-secondary:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.25);
    background: var(--bg-primary);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-run-stop-toolbar.running { background: #e74c3c; color: #fff; }
/* 仿真按钮：默认抬起（隐藏右侧），按下时显示右侧并保持按下样式 */
#btn-simulation-toggle.active {
    background: var(--accent-secondary);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.25);
    border-color: var(--accent-primary);
}
/* 上传状态仅输出到控制台，工具栏不显示，保证界面固定 */
.upload-status-wrap {
    display: none !important;
}
.upload-status {
    font-size: 12px;
    color: var(--text-secondary);
}
.upload-status.uploading { color: var(--accent-primary); }
.upload-status.success { color: var(--accent-success); }
.upload-status.error { color: #e74c3c; }
.upload-progress {
    width: 100px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    display: none;
}
.upload-progress.visible {
    display: block;
}
.upload-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-primary);
    border-radius: 3px;
    transition: width 0.12s ease-out;
}
/* 主界面「放大布局」：仿真 iframe 铺满视口，盖住左侧 Mixly（工具栏 z-index 更高仍可操作） */
#mixgo-frame.mixvm-layout-zoom-fullscreen {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    flex: none !important;
    z-index: 90 !important;
    border: none !important;
}
body.mixvm-layout-zoom-active #panel-mixly,
body.mixvm-layout-zoom-active #resizer-h {
    pointer-events: none;
    user-select: none;
}

.arduino-toolbar-group { display: inline-flex; align-items: center; gap: 6px; }

.toolbar-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}
.example-select {
    padding: 6px 12px;
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    width: 180px;
}
.example-select:focus { outline: none; border-color: var(--accent-primary); }

.panel { display: flex; flex-direction: column; background: var(--bg-panel); overflow: hidden; }

/* 与右侧 Mixgo SOWL 标题区齐平：固定高度 40px */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 40px;
    min-height: 40px;
    padding: 0 15px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    font-weight: 600;
    box-sizing: border-box;
    flex-shrink: 0;
}

.panel-title { display: flex; align-items: center; gap: 8px; }
.panel-info { color: var(--text-secondary); font-size: 12px; }
.panel-content { flex: 1; overflow: auto; }

.panel-left { width: 66%; min-width: 0px; min-height: 0px; display: flex; flex-direction: column; }
#panel-mixly { padding: 0; }
#panel-mixly .load-error { flex-shrink: 0; }
#mixly-frame { flex: 1; min-height: 0; }
.panel-left .panel-content { padding: 0; min-height: 260px; }

/* 移动端：允许左侧面板随分割条缩小，避免固定 min-width 把右侧仿真区域挤没 */
@media (max-width: 600px) {
    .panel-left {
        min-width: 0;
    }
    .panel-right {
        max-width: none;
    }
}
.load-error {
    padding: 12px 16px;
    margin: 8px 12px;
    background: rgba(233, 69, 96, 0.2);
    border: 1px solid var(--accent-primary);
    border-radius: 8px;
    color: #ff8a9e;
    font-size: 13px;
    line-height: 1.5;
}
.load-error a { color: #0f4c75; text-decoration: underline; }

/* 左侧为 Mixly iframe，不再使用 CodeMirror */

/* 右侧仿真区占满主区域剩余宽度，右缘与浏览器内容区对齐；勿设 max-width，否则左侧较窄时会出现右侧大块留白 */
.panel-right {
    flex: 1 1 0%;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.resizer-horizontal {
    width: 8px;
    min-width: 8px;
    background: var(--border-color);
    cursor: col-resize;
    transition: background 0.2s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 20;
    touch-action: none; /* 触摸设备：避免拖拽手势被浏览器滚动/缩放接管 */
}
.resizer-horizontal::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -4px;
    right: -4px;
    cursor: col-resize;
}
.resizer-horizontal:hover, .resizer-horizontal.active { background: var(--accent-primary); }

.editor-disabled { opacity: 0.6; pointer-events: none; }

/* 切板后暂隐右侧设计 iframe，子页首帧布局完成后再显示（见 js/main.js mixgoDesignInitialLayoutReady） */
iframe#mixgo-frame.mixgo-frame-layout-pending {
    visibility: hidden;
}
