/* ----------------------------------------------------
   1. 全局样式及暗黑变量定义
   ---------------------------------------------------- */
:root {
    --bg-main: #161617;
    --bg-panel: rgba(28, 28, 30, 0.85);
    --bg-card: #2c2c2e;
    --bg-card-active: #3a3a3c;
    --text-primary: #f5f5f7;
    --text-secondary: #aeaeb2;
    --text-muted: #8e8e93;
    --color-primary: #0A84FF;
    --color-success: #30D158;
    --color-danger: #FF453A;
    --color-warn: #FF9F0A;
    --border-color: rgba(255, 255, 255, 0.08);
    --font-sans: 'Inter', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Outfit', var(--font-sans);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
    user-select: none;
}

/* ----------------------------------------------------
   2. 头部标题栏 (毛玻璃特效)
   ---------------------------------------------------- */
.app-header {
    height: 52px;
    background-color: rgba(28, 28, 30, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 100;
    flex-shrink: 0;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 20px;
    background: linear-gradient(135deg, #0A84FF, #30D158);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-area h1 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge {
    font-size: 10px;
    background: rgba(10, 132, 255, 0.15);
    color: var(--color-primary);
    border: 1px solid rgba(10, 132, 255, 0.3);
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: 600;
}

.engine-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    transition: all 0.4s ease;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--color-warn);
    transition: all 0.4s ease;
}

.status-dot.ready {
    background-color: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
    animation: none;
}

.status-dot.failed {
    background-color: var(--color-danger);
    animation: none;
}

.pulsing {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* ----------------------------------------------------
   3. 主工作容器
   ---------------------------------------------------- */
.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* 左侧控制栏 */
.control-panel {
    width: 300px;
    min-width: 300px;
    background-color: var(--bg-panel);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    overflow-y: auto;
}

/* 自定义滚动条 */
.control-panel::-webkit-scrollbar {
    width: 4px;
}
.control-panel::-webkit-scrollbar-track {
    background: transparent;
}
.control-panel::-webkit-scrollbar-thumb {
    background: #48484a;
    border-radius: 2px;
}

.panel-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-primary);
    font-weight: 700;
}

/* 按钮及输入 */
.file-inputs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-btn {
    position: relative;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.file-btn input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
}

.file-btn:hover {
    background-color: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
}

.file-btn.loaded {
    border-style: solid;
    border-color: var(--color-success);
    background-color: rgba(48, 209, 88, 0.06);
}

.file-status {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    min-height: 16px;
}

/* 滑动胶囊按钮 */
.capsule-container {
    position: relative;
    background-color: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    height: 36px;
    display: flex;
    padding: 3px;
    border: 1px solid var(--border-color);
}

.capsule-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    height: 30px;
    width: calc(33.33% - 2px);
    background-color: var(--color-primary);
    border-radius: 6px;
    transition: left 0.25s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: 0 2px 8px rgba(10, 132, 255, 0.4);
}

.capsule-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease;
    outline: none;
    position: relative;
    z-index: 1;
}

.capsule-btn.active {
    color: #ffffff;
    font-weight: 600;
}

/* 滑块组 */
.slider-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: #48484a;
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: 2.5px solid #ffffff;
    box-shadow: 0 0 4px rgba(0,0,0,0.5);
    transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

/* 历史撤销行 */
.action-row {
    display: flex;
    gap: 8px;
}

.action-btn {
    flex: 1;
    height: 34px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.action-btn:hover:not([disabled]) {
    background-color: var(--bg-card-active);
}

.action-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* 板块管理器 */
.block-section {
    flex: 1;
    min-height: 100px;
    display: flex;
    flex-direction: column;
}

.block-list-container {
    flex: 1;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.placeholder-text {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    padding: 16px 10px;
    line-height: 1.6;
}

/* 板块卡片样式 */
.block-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.block-card:hover {
    background-color: var(--bg-card-active);
}

.block-card.active {
    border-color: var(--color-primary);
    background-color: rgba(10, 132, 255, 0.08);
}

.block-card.success {
    border-left: 3px solid var(--color-success);
}

.block-card.failed {
    border-left: 3px solid var(--color-danger);
}

.block-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.block-card-title {
    font-size: 12px;
    font-weight: 600;
}

.block-card-size {
    font-size: 10px;
    color: var(--text-muted);
}

.block-card-del {
    background: none;
    border: none;
    color: var(--color-danger);
    font-weight: 700;
    cursor: pointer;
    font-size: 13px;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.block-card-del:hover {
    background-color: rgba(255, 69, 58, 0.15);
}

/* 导出按钮 */
.export-btn {
    width: 100%;
    height: 42px;
    border-radius: 8px;
    background: linear-gradient(135deg, #0A84FF, #0070e3);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(10, 132, 255, 0.3);
    transition: all 0.2s ease;
}

.export-btn:hover:not([disabled]) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(10, 132, 255, 0.45);
}

.export-btn:active:not([disabled]) {
    transform: translateY(0);
}

.export-btn:disabled {
    background: #2c2c2e;
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* ----------------------------------------------------
   4. 右侧画布工作空间
   ---------------------------------------------------- */
.canvas-workspace {
    flex: 1;
    background-color: #0d0d0d;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* 欢迎占位面板 */
.welcome-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    pointer-events: none;
}

.welcome-overlay.hidden {
    display: none;
}

.welcome-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    opacity: 0.4;
}

.welcome-icon {
    font-size: 48px;
    background: linear-gradient(135deg, #0A84FF, #30D158);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-content h2 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
}

.welcome-content p {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 300px;
    line-height: 1.6;
}

.canvas-holder {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#editor-canvas {
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    background-image:
        linear-gradient(45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(-45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1a1a1a 75%),
        linear-gradient(-45deg, transparent 75%, #1a1a1a 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    background-color: #222;
    cursor: default;
    display: none;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

#editor-canvas.visible {
    display: block;
}

/* 画布辅助控件 */
.canvas-controls {
    height: 44px;
    border-top: 1px solid var(--border-color);
    background-color: rgba(28, 28, 30, 0.8);
    backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
}

.compare-btn {
    height: 28px;
    padding: 0 12px;
    border-radius: 6px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: all 0.15s ease;
}

.compare-btn:hover:not([disabled]) {
    background-color: var(--bg-card-active);
}

.compare-btn:active:not([disabled]),
.compare-btn.active:not([disabled]) {
    background-color: var(--color-primary);
    color: #ffffff;
    transform: scale(0.95);
}

.compare-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.zoom-step-btn {
    width: 26px;
    height: 26px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.zoom-step-btn:hover {
    border-color: rgba(255,255,255,0.2);
    color: #ffffff;
}

#zoom-lbl {
    min-width: 42px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------
   5. 底部状态栏
   ---------------------------------------------------- */
.app-footer {
    height: 24px;
    background-color: #1c1c1e;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.credit {
    font-family: var(--font-display);
}

/* ----------------------------------------------------
   6. 模态弹框
   ---------------------------------------------------- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: rgba(44, 44, 46, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 24px;
    width: 340px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: translateY(0);
}

.modal-content h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-content p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-btn {
    height: 36px;
    border-radius: 8px;
    background-color: var(--color-primary);
    color: #ffffff;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.modal-btn:hover {
    background-color: #0070e3;
}
