/* ==========================================
   1. 基础盒模型修复 (防止内边距撑开容器)
   ========================================== */
.tm-workspace, .tm-workspace * {
    box-sizing: border-box;
}

/* ==========================================
   2. 宏观布局 (响应式弹性容器)
   ========================================== */
.tm-workspace {
    display: flex;
    flex-wrap: wrap; /* 核心：空间不足时自动换行 */
    gap: 24px;
    align-items: stretch;
    width: 100%;
}

.tm-control-panel {
    flex: 1 1 350px; /* 占据剩余空间，最小基准350px */
    min-width: 0;    /* 极度关键：防止内部长字符串/输入框撑破容器 */
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tm-dashboard-panel {
    flex: 1 1 320px; /* 移动端自动铺满，PC端占据320px */
    max-width: 380px; /* 防止在宽屏上仪表盘变得过宽 */
    min-width: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);
}

/* ==========================================
   3. 输入与选择区域
   ========================================== */
.tm-input-group label,
.tm-select-wrap label,
.tm-result-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tm-input-group input[type="number"],
.tm-select-wrap select {
    width: 100%;
    padding: 14px 16px;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-main);
    font-size: 1.2rem;
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    outline: none;
    transition: 0.2s;
}

.tm-input-group input[type="number"]:focus,
.tm-select-wrap select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}

/* 单位选择器组 */
.tm-unit-selector {
    display: flex;
    align-items: flex-end; /* 修正：使底部对齐 */
    gap: 16px;
}

.tm-select-wrap {
    flex: 1;
    min-width: 0;
}

.tm-swap-btn {
    flex: 0 0 48px; /* 固定大小，不伸缩 */
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--primary-color);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.tm-swap-btn:hover {
    background: #e2e8f0;
    transform: rotate(180deg);
}

/* ==========================================
   4. 结果展示与复制
   ========================================== */
.tm-result-box {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.tm-result-box input {
    flex: 1;
    min-width: 0; /* 极度关键：防止极长数字撑爆结果框 */
    padding: 14px 16px;
    border-radius: 10px;
    border: 2px solid rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.05);
    color: #10b981;
    font-size: 1.4rem;
    font-weight: 800;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    outline: none;
}

.tm-copy-btn {
    flex: 0 0 auto;
    padding: 0 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-main);
    border-radius: 10px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.tm-copy-btn:hover {
    background: #e2e8f0;
    color: var(--primary-color);
}

/* ==========================================
   5. 仪表盘细节
   ========================================== */
.tm-dashboard-title {
    font-size: 1.1rem;
    color: var(--text-main);
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--border-color);
}

.tm-metrics-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tm-metric-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tm-metric-card.highlight {
    border-left: 3px solid var(--primary-color);
    background: rgba(0, 102, 204, 0.03);
}

.tm-m-val {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
    flex: 1; /* 让数值占据剩余空间 */
}

.tm-m-lbl {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ==========================================
   6. 深色模式适配
   ========================================== */
[data-theme="dark"] .tm-input-group input,
[data-theme="dark"] .tm-select-wrap select { background: #0f172a; border-color: #334155; }
[data-theme="dark"] .tm-swap-btn { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .tm-swap-btn:hover { background: #334155; }
[data-theme="dark"] .tm-result-box input { background: rgba(16, 185, 129, 0.1); }
[data-theme="dark"] .tm-copy-btn { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .tm-copy-btn:hover { background: #334155; }
[data-theme="dark"] .tm-metric-card { background: #0f172a; border-color: #334155; }
[data-theme="dark"] .tm-metric-card.highlight { background: rgba(99, 102, 241, 0.1); border-color: var(--primary-color); }

/* ==========================================
   7. 移动端专项优化
   ========================================== */
@media (max-width: 768px) {
    .tm-workspace {
        gap: 16px;
    }

    .tm-dashboard-panel {
        max-width: 100%; /* 手机端解除宽度限制 */
    }

    .tm-unit-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .tm-swap-btn {
        align-self: center;
        margin: 4px 0;
        transform: rotate(90deg); /* 手机端变为上下旋转 */
    }

    .tm-swap-btn:hover {
        transform: rotate(270deg);
    }

    .tm-result-box {
        flex-direction: column; /* 结果框和按钮在手机端竖排 */
    }

    .tm-copy-btn {
        padding: 14px;
        width: 100%;
        justify-content: center;
    }
}