/* ── Impedance Variance Analysis — web GUI theme ──
   Port of the Qt QSS dark stylesheet (#0e1117 base, #4c9be8 accent). */

* { box-sizing: border-box; }

:root {
  --bg:            #0e1117;
  --panel:         #12151e;
  --panel-border:  #2a2d3a;
  --input-bg:      #1a1e2a;
  --input-border:  #2e3345;
  --text:          #e0e0e0;
  --text-muted:    #c0c0c8;
  --text-dim:      #7080a0;
  --accent:        #4c9be8;
  --green:         #5fcf80;
  --red:           #e84c6c;
  --yellow:        #e8c84c;
  --log-bg:        #090b10;
  --log-border:    #1e2230;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Inter", Arial, sans-serif;
  font-size: 13px;
}

body { display: flex; flex-direction: column; overflow: hidden; }

/* ── Header / status bar ── */
header.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--log-border);
  background: var(--log-bg);
  flex: 0 0 auto;
}
header.app-header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
}
header.app-header .subtitle { color: var(--text-dim); font-size: 11px; }

footer.statusbar {
  flex: 0 0 auto;
  padding: 5px 18px;
  background: var(--log-bg);
  color: #506080;
  border-top: 1px solid #1a1e2a;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 3-column main layout ── */
main.app {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.config-panel {
  flex: 0 0 320px;
  overflow-y: auto;
  padding: 14px;
  border-right: 1px solid #1a1e2a;
}

.center-panel {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0 10px;
}

.results-panel {
  flex: 0 0 300px;
  overflow-y: auto;
  padding: 14px;
  border-left: 1px solid #1a1e2a;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Panel headers ── */
.panel-title {
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--log-border);
  margin-bottom: 12px;
}

/* ── Group boxes ── */
.group {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  margin-bottom: 14px;
  position: relative;
}
.group > .group-title {
  color: var(--accent);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ── Form fields ── */
.field { margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }
.field label.section-label {
  display: block;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

input[type="text"], input[type="number"], select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  padding: 6px 9px;
  color: #e8e8f0;
  font-size: 13px;
  font-family: inherit;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: #1d2235;
}
input:disabled, select:disabled { color: #505060; background: #141720; }

.row2 { display: flex; gap: 8px; }
.row2 > .field { flex: 1; margin-bottom: 0; }

/* checkboxes */
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #c8ccd8;
  cursor: pointer;
  font-size: 12px;
}
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

/* slider */
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.slider-row .value-label {
  color: var(--accent);
  font-weight: 600;
  min-width: 28px;
  text-align: center;
}

/* ── Buttons ── */
button {
  background: #1e2335;
  border: 1px solid #334060;
  border-radius: 7px;
  padding: 7px 16px;
  color: #c8d8f0;
  font-weight: 500;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #263050; border-color: var(--accent); color: #e8f0ff; }
button:active:not(:disabled) { background: #1a2540; }
button:disabled { color: #404060; background: #141720; border-color: #252838; cursor: default; }

button.run-btn {
  width: 100%;
  background: linear-gradient(90deg, #1c6fc9, #1a5faf);
  border: 1px solid #2a80e0;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 11px 24px;
  letter-spacing: 0.5px;
}
button.run-btn:hover:not(:disabled) {
  background: linear-gradient(90deg, #2480e0, #1a70c8);
  border-color: #4ca0f8;
}
button.run-btn:disabled { background: #1a1e28; border-color: #252838; color: #404060; }

button.open-btn {
  background: linear-gradient(90deg, #1a5038, #164530);
  border: 1px solid #2a8060;
  color: #80f0a8;
  font-weight: 600;
}
button.open-btn:hover:not(:disabled) {
  background: linear-gradient(90deg, #206040, #1a5538);
  border-color: #50e090;
}
button.open-btn:disabled { color: #304040; background: #141720; border-color: #252838; }

button.ghost-btn {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: #8090b0;
  font-size: 12px;
}
button.ghost-btn:hover:not(:disabled) { background: #232840; border-color: var(--accent); color: #c0d0f0; }

.btn-row { display: flex; gap: 8px; }
.btn-row button { flex: 1; }

.file-summary { color: var(--green); font-size: 11px; margin-top: 6px; min-height: 14px; }

/* ── Sample data ── */
.group.demo-group {
  border-color: #3a4a34;
  background: linear-gradient(180deg, #141a16, var(--panel));
}
.group.demo-group > .group-title { color: var(--green); }

.demo-desc {
  color: #8fa898;
  font-size: 11px;
  line-height: 1.45;
  margin-top: 6px;
  min-height: 30px;
}

button.demo-btn {
  width: 100%;
  margin-top: 4px;
  background: linear-gradient(90deg, #1a5038, #164530);
  border: 1px solid #2a8060;
  color: #80f0a8;
  font-weight: 600;
  letter-spacing: 0.3px;
}
button.demo-btn:hover:not(:disabled) {
  background: linear-gradient(90deg, #206040, #1a5538);
  border-color: #50e090;
  color: #b0ffd0;
}
button.demo-btn:disabled { color: #304040; background: #141720; border-color: #252838; }

.demo-cta {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
button.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
button.link-btn:hover:not(:disabled) { background: none; color: #b0ffd0; }
button.link-btn:disabled { background: none; color: #405050; text-decoration: none; }

/* ── Tabs ── */
.tabbar {
  display: flex;
  gap: 2px;
  padding: 8px 0 0;
  flex: 0 0 auto;
}
.tabbar .tab {
  background: var(--input-bg);
  border: 1px solid var(--log-border);
  border-bottom: none;
  border-radius: 7px 7px 0 0;
  padding: 7px 18px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.tabbar .tab.active { background: var(--panel); color: var(--accent); border-color: var(--panel-border); }
.tabbar .tab:hover:not(.active) { color: var(--text-muted); }

.tabpages {
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--panel-border);
  border-radius: 0 8px 8px 8px;
  background: var(--panel);
  margin-bottom: 10px;
  position: relative;
}
.tabpage {
  position: absolute;
  inset: 0;
  padding: 12px;
  display: none;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.tabpage.active { display: flex; }

/* ── Log tab ── */
.progress-track {
  height: 12px;
  background: #0d1018;
  border: 1px solid var(--log-border);
  border-radius: 5px;
  overflow: hidden;
  margin: 10px 0 4px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2465b8, var(--accent));
  border-radius: 5px;
  transition: width 0.2s ease;
}
.status-line { color: #607090; font-size: 11px; padding: 0 2px 8px; }
.status-line.ok { color: var(--green); }
.status-line.err { color: var(--red); }
.status-line.busy { color: var(--accent); }

.log-header { display: flex; align-items: center; justify-content: space-between; }
.log-header .clear { width: auto; }

pre.log {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  overflow: auto;
  background: var(--log-bg);
  border: 1px solid var(--log-border);
  border-radius: 8px;
  color: #b0c8e0;
  font-family: "Cascadia Code", "Consolas", "Courier New", monospace;
  font-size: 12px;
  padding: 10px;
  white-space: pre;
}

/* ── Figure viewer / 3D tab ── */
.viewer-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  flex: 0 0 auto;
}
.viewer-controls label { color: var(--text-dim); font-size: 11px; font-weight: 600; }
.viewer-controls select { width: auto; min-width: 140px; }
.viewer-controls .spacer { flex: 1; }

.plot-host {
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--log-border);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}
.plot-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #506070;
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

/* ── Results panel ── */
.nf-line { color: #70a0c8; font-size: 11px; padding: 1px 0; font-family: "Consolas", monospace; }
.nf-line.ready { color: var(--green); }

ul.figure-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: #0d1018;
  border: 1px solid var(--log-border);
  border-radius: 8px;
  overflow: hidden;
}
ul.figure-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #181c28;
  color: #506070;
  font-size: 12px;
  cursor: default;
}
ul.figure-list li:last-child { border-bottom: none; }
ul.figure-list li .tag {
  font-family: "Consolas", monospace;
  font-size: 10px;
  font-weight: 700;
  min-width: 40px;
  text-align: center;
  border-radius: 3px;
  padding: 1px 4px;
  background: rgba(255,255,255,0.05);
  color: #405060;
}
ul.figure-list li .name { flex: 1; }
ul.figure-list li .dl {
  visibility: hidden;
  background: none;
  border: none;
  color: #8090b0;
  padding: 2px 6px;
  font-size: 13px;
}
ul.figure-list li.ready { color: #c0cce0; cursor: pointer; }
ul.figure-list li.ready:hover { background: #1a2035; color: #e0ecff; }
ul.figure-list li.ready .dl { visibility: visible; }
ul.figure-list li.ready .dl:hover { color: var(--accent); }
ul.figure-list li.selected { background: #1e3060; color: #fff; box-shadow: inset 3px 0 0 var(--accent); }

/* ── scrollbars ── */
::-webkit-scrollbar { width: 8px; height: 8px; background: #0d1018; }
::-webkit-scrollbar-thumb { background: #2a3050; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a4070; }

/* ── responsive ── */
@media (max-width: 1100px) {
  main.app { flex-direction: column; overflow-y: auto; }
  body { overflow: auto; }
  .config-panel, .results-panel {
    flex: 0 0 auto;
    border: none;
    border-bottom: 1px solid #1a1e2a;
  }
  .center-panel { min-height: 640px; }
  .tabpages { min-height: 520px; }
}
