/* section_properties/static/section_properties/css/style.css */

:root {
    --primary: #0f172a;      /* 深邃藍黑 */
    --primary-light: #334155;
    --accent: #2563eb;       /* 工程藍 */
    --accent-hover: #1d4ed8;
    --bg-app: #f1f5f9;       /* 應用程式背景 */
    --bg-panel: #ffffff;
    --border: #e2e8f0;
    --text-main: #1e293b;
    --text-sub: #64748b;
    --font-ui: 'Noto Sans TC', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background-color: var(--bg-app);
    font-family: var(--font-ui);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.app-header {
    height: 48px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    flex-shrink: 0;
    z-index: 10;
}

.header-left { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.back-link { text-decoration: none; color: var(--text-sub); display: flex; align-items: center; gap: 4px; transition: 0.2s; }
.back-link:hover { color: var(--accent); }
.divider { color: #cbd5e1; }
.current-page { font-weight: 500; color: var(--primary); }
.app-title { font-size: 1rem; font-weight: 700; color: var(--primary-light); margin: 0; }

/* --- Main Workspace --- */
.main-workspace {
    flex: 1;
    padding: 12px;
    min-height: 0;
    display: flex;
}

.workspace-grid {
    width: 100%;
    height: 100%;
    display: grid;
    /* [修正] 左側 360px，右側加大至 400px，中間自適應 */
    grid-template-columns: 360px 1fr 400px;
    gap: 12px;
}

/* --- Panel Styles --- */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.panel-header {
    padding: 10px 15px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.panel-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-light);
    display: flex;
    align-items: center;
    gap: 6px;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* Scrollbar */
.custom-scrollbar::-webkit-scrollbar { width: 6px; height: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 3px; }

/* --- Inputs --- */
.control-group { margin-bottom: 15px; }
.control-label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.85rem; }
.form-select { width: 100%; padding: 8px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 0.9rem; background-color: #fff; }
.divider-line { height: 1px; background: var(--border); margin: 15px 0; }

.row-2-col { display: flex; gap: 12px; margin-bottom: 10px; }
.input-group { flex: 1; min-width: 0; }
.input-group label {
    display: block; font-size: 0.8rem; color: var(--text-sub); margin-bottom: 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.section-input {
    width: 100%; padding: 6px 8px;
    border: 1px solid #cbd5e1; border-radius: 4px;
    font-family: var(--font-mono); font-size: 0.9rem; text-align: right;
}
.section-input:focus { outline: none; border-color: var(--accent); }
.input-group-header {
    font-size: 0.8rem; font-weight: 700; color: var(--primary-light);
    margin: 12px 0 6px 0; border-left: 3px solid var(--accent); padding-left: 6px;
}

.panel-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
    background: #f8fafc;
    flex-shrink: 0;
}
.btn-calculate {
    width: 100%; padding: 10px; background: var(--primary); color: #fff;
    border: none; border-radius: 6px; font-weight: 600; cursor: pointer;
    display: flex; justify-content: center; align-items: center; gap: 8px; transition: 0.2s;
}
.btn-calculate:hover { background: #0f172a; transform: translateY(-1px); }

/* --- Canvas --- */
.canvas-panel {
    background-color: #e5e7eb;
    position: relative;
    display: flex;
}
.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}
canvas {
    background: #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.canvas-legend {
    position: absolute; bottom: 10px; left: 10px;
    background: rgba(255,255,255,0.9); padding: 4px 8px; border-radius: 4px;
    font-size: 0.75rem; color: var(--text-sub); border: 1px solid #e2e8f0;
}

/* --- Results --- */
.unit-toggle { display: flex; gap: 8px; font-size: 0.8rem; background: #e2e8f0; padding: 2px; border-radius: 4px; }
.unit-toggle label { padding: 2px 8px; cursor: pointer; border-radius: 3px; display: flex; align-items: center; }
.unit-toggle input { display: none; }
.unit-toggle label:has(input:checked) { background: #fff; color: var(--accent); font-weight: bold; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }

/* [修正] 使用 table-layout: fixed 和寬度調整來避免橫向捲軸 */
.result-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.result-table th, .result-table td { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; }
.result-table th {
    text-align: left; font-weight: 500; font-size: 0.85rem; color: var(--text-sub);
    width: 40%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result-table td {
    text-align: right; font-family: var(--font-mono); font-weight: 600; color: var(--primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.table-group-header td { background: #f8fafc; color: var(--primary-light); font-size: 0.8rem; font-weight: 700; padding: 6px 10px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.unit-text { font-size: 0.75rem; color: #94a3b8; margin-left: 4px; display: inline-block; width: 30px; text-align: left;}

/* RWD */
@media (max-width: 1024px) {
    body { height: auto; overflow: auto; }
    .main-workspace { padding: 0; display: block; }
    .workspace-grid { display: flex; flex-direction: column; gap: 0; }
    .panel { border-radius: 0; border: none; border-bottom: 1px solid var(--border); box-shadow: none; }
    .canvas-panel { height: 400px; }
}