/* static/app.css */

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

body {
  font-size: 14px;
  overflow: hidden;
  height: 100vh;
}

/* --- Three-column grid layout --- */
.app-layout {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  grid-template-rows: 100vh;
  height: 100vh;
  gap: 0;
}

/* --- Sidebar (left controls) --- */
.sidebar {
  background-color: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  justify-content: space-between;
}

.sidebar-header > div {
  flex: 1;
}

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.3px;
}

.sidebar-header .subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-header-buttons {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.theme-toggle {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.theme-toggle:hover {
  border-color: var(--primary);
}

.theme-icon {
  font-size: 16px;
  line-height: 1;
}

/* --- Section cards --- */
.section {
  background-color: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* --- Form controls --- */
.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.form-row label {
  font-size: 12px;
  color: var(--text);
  min-width: 55px;
  flex-shrink: 0;
}

.info-label {
  cursor: pointer;
  border-bottom: 1px dashed transparent;
  transition: color 0.15s, border-color 0.15s;
}

.info-label:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.form-row input[type="number"],
.form-row input[type="range"],
.form-row select {
  flex: 1;
  min-width: 0;
}

input[type="number"] {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}

input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
}

select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  cursor: pointer;
}

select:focus {
  outline: none;
  border-color: var(--primary);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  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(--primary);
  cursor: pointer;
}

.range-value {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 38px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.btn-small {
  background-color: var(--primary);
  color: var(--text-over-primary);
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-small:hover {
  background-color: var(--primary-hover);
}

.btn-toggle {
  background-color: var(--border);
  color: var(--text-muted);
  border: none;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-toggle.active {
  background-color: var(--primary);
  color: var(--text-over-primary);
}

.btn-toggle:hover {
  opacity: 0.85;
}

/* Dynamic taper params container */
.taper-params {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.taper-params:empty {
  display: none;
}

/* --- Main center area --- */
.main-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--background);
}

/* --- Metrics bar --- */
.metrics-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px 12px;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
}

.metric {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 4px;
  background-color: var(--surface-alt);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s;
}

.metric:hover {
  border-color: var(--primary);
}

.metric-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-muted);
}

.metric-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* --- Plot area --- */
.plot-area {
  flex: 1;
  position: relative;
  min-height: 0;
}

.plot-area > div {
  position: absolute;
  inset: 0;
}

/* --- Right panel --- */
.right-panel {
  background-color: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.right-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-bottom: 1px solid var(--border);
}

.right-section:last-child {
  border-bottom: none;
}

.right-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 4px;
}

.right-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.right-plot {
  flex: 1;
  min-height: 0;
}

/* --- Info modal --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px 28px;
  max-width: 560px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  padding-right: 30px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.modal-close:hover {
  color: var(--primary);
}

.modal-body {
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

.modal-body .katex-display {
  margin: 16px 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.modal-body p {
  margin-bottom: 10px;
}

.modal.modal-wide {
  max-width: 640px;
}

.video-embed {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  margin: 12px 0;
  border-radius: 6px;
  overflow: hidden;
}

.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.video-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 14px;
  margin-bottom: 2px;
}

.resource-list {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.resource-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.resource-list a {
  color: var(--accent-cyan);
  text-decoration: none;
}

.resource-list a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.resource-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* --- Scrollbar styling --- */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* --- Pair inputs (side by side) --- */
.form-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.form-pair .form-row {
  margin-bottom: 0;
}

.form-pair .form-row label {
  min-width: 28px;
}
