/* ═══════════════════════════════════════════════════════════════
   PyPTO IDE Assistant — Reusable UI Components
   ═══════════════════════════════════════════════════════════════ */

/* ──────────── FORM ELEMENTS ──────────── */
.form-section { margin-bottom: 16px; }
.form-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.form-input {
  width: 100%;
  background: var(--bg-base);
  border: none;
  border-radius: 5px;
  padding: 6px 9px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
}
.form-input:focus { outline: none; }
.form-input::placeholder { color: var(--text-muted); }

/* ──────────── RADIO GROUP ──────────── */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.radio-opt {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 4px;
  border: none;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.radio-opt:hover { background: var(--bg-hover); color: var(--text-primary); }
.radio-opt.active { background: var(--bg-selected); color: var(--accent-blue); }
.radio-opt input[type="radio"] { accent-color: var(--accent-blue); }

/* ──────────── TENSOR ROW ──────────── */
.tensor-row {
  display: flex;
  gap: 5px;
  margin-bottom: 5px;
  align-items: center;
}
.ti-name {
  flex: 1 1 0;
  background: var(--bg-base);
  border: none;
  border-radius: 4px;
  padding: 4px 7px;
  color: var(--text-primary);
  font-size: 11px;
  font-family: inherit;
  min-width: 0;
}
.ti-name:focus { outline: none; }
.ti-dtype {
  flex: 0 0 58px;
  background: var(--bg-base);
  border: none;
  border-radius: 4px;
  padding: 4px 4px;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: inherit;
}
.ti-dtype:focus { outline: none; }
.ti-shape {
  flex: 0 0 78px;
  background: var(--bg-base);
  border: none;
  border-radius: 4px;
  padding: 4px 7px;
  color: var(--text-accent);
  font-size: 11px;
  font-family: inherit;
}
.ti-shape:focus { outline: none; }
.ti-del {
  flex-shrink: 0;
  width: 22px; height: 22px;
  background: none;
  border: none;
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  transition: background 0.12s, color 0.12s;
  display: flex; align-items: center; justify-content: center;
}
.ti-del:hover { background: rgba(255, 75, 123, 0.12); color: var(--accent-red); }

/* ──────────── KV GRID ──────────── */
.kv-grid { display: flex; flex-direction: column; gap: 5px; }
.kv-row { display: flex; align-items: center; gap: 8px; }
.kv-k {
  flex: 0 0 64px;
  font-size: 11px;
  color: var(--text-muted);
}
.kv-v {
  flex: 1;
  background: var(--bg-base);
  border: none;
  border-radius: 4px;
  padding: 4px 7px;
  color: var(--text-accent);
  font-size: 11px;
  font-family: inherit;
}
.kv-v:focus { outline: none; }

/* ──────────── CHECKBOXES ──────────── */
.check-list { display: flex; flex-direction: column; gap: 5px; }
.ck-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
}
.ck-item input[type="checkbox"] { accent-color: var(--accent-blue); }
.ck-item:hover { color: var(--text-primary); }

/* ──────────── BUTTONS ──────────── */
.btn-primary {
  padding: 8px 16px;
  background: var(--accent-blue);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-primary:hover { background: #2563eb; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary.full-width { width: 100%; }

.btn-secondary {
  padding: 6px 12px;
  background: var(--bg-hover);
  border: none;
  border-radius: 5px;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.btn-secondary:hover { background: var(--bg-active); color: var(--text-primary); }
.btn-secondary.full-width { width: 100%; }

.btn-add {
  padding: 4px 10px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: all 0.15s;
  margin-top: 4px;
}
.btn-add:hover { background: var(--bg-hover); color: var(--accent-blue); }

.btn-mini {
  padding: 2px 8px;
  background: var(--bg-hover);
  border: none;
  border-radius: 3px;
  color: var(--text-muted);
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s;
}
.btn-mini:hover { background: var(--bg-active); color: var(--accent-blue); }
.btn-mini.apply-btn:hover { color: var(--accent-green); }

/* ──────────── STAT CARDS ──────────── */
.stat-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sc-card {
  background: var(--bg-base);
  border: none;
  border-radius: 5px;
  padding: 8px 10px;
  position: relative;
  overflow: hidden;
}
.sc-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 2px; height: 100%;
  background: var(--accent-blue);
  opacity: 0.5;
}
.sc-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.sc-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.sc-val.warning { color: var(--accent-yellow); }

/* ──────────── FILE DROP AREA ──────────── */
.file-drop-area {
  border: none;
  border-radius: 6px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-base);
}
.file-drop-area:hover { background: var(--bg-hover); }
.file-drop-area.drag-over { background: var(--bg-selected); }
.fda-icon { font-size: 20px; color: var(--text-muted); margin-bottom: 6px; }
.fda-text { font-size: 11px; color: var(--text-muted); line-height: 1.6; }

/* ──────────── RANGE ROW ──────────── */
.range-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.rr-label { font-size: 11px; color: var(--text-muted); flex: 0 0 32px; }

/* ──────────── DEBUG SECTIONS ──────────── */
.debug-section {
  background: var(--bg-base);
  border: none;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}
.ds-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 10px;
}
.ds-placeholder {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ──────────── RISK MATRIX ──────────── */
.risk-matrix {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rm-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rm-name {
  flex: 0 0 120px;
  font-size: 11px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rm-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--bg-panel);
  border-radius: 4px;
  overflow: hidden;
}
.rm-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.rm-label {
  flex: 0 0 36px;
  text-align: right;
  font-size: 10px;
  font-weight: 600;
}
.risk-high   .rm-bar-fill { background: var(--accent-red); }
.risk-medium .rm-bar-fill { background: var(--accent-orange); }
.risk-low    .rm-bar-fill { background: var(--accent-green); }
.risk-high   .rm-label { color: var(--accent-red); }
.risk-medium .rm-label { color: var(--accent-orange); }
.risk-low    .rm-label { color: var(--accent-green); }

/* ──────────── WORKAROUND LIST ──────────── */
.wa-list { display: flex; flex-direction: column; gap: 8px; }
.wa-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border-radius: 6px;
  border: none;
  background: var(--bg-panel);
  transition: background 0.15s;
}
.wa-item:hover { background: var(--bg-hover); }

.wa-prio {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800;
}
.prio-1 .wa-prio { background: #1e0a0a; color: var(--accent-red); }
.prio-2 .wa-prio { background: #1e110a; color: var(--accent-orange); }
.prio-3 .wa-prio { background: #1a1a0a; color: var(--accent-yellow); }
.prio-4 .wa-prio { background: #0a1a10; color: var(--accent-green); }
.prio-5 .wa-prio { background: #0a1020; color: var(--accent-blue); }
.prio-6 .wa-prio { background: #170a20; color: var(--accent-purple); }

.wa-content { flex: 1; min-width: 0; }
.wa-name { font-size: 12px; font-weight: 600; color: var(--text-primary); margin-bottom: 3px; }
.wa-desc { font-size: 11px; color: var(--text-muted); line-height: 1.5; margin-bottom: 6px; }
.wa-desc code {
  background: var(--bg-base);
  padding: 1px 4px;
  border-radius: 3px;
  color: #93c5fd;
  font-size: 10px;
}
.wa-actions { display: flex; gap: 5px; }

/* ──────────── OPTIMIZATION CARDS ──────────── */
.opt-card {
  border: none;
  border-radius: 6px;
  margin-bottom: 8px;
  overflow: hidden;
  background: var(--bg-panel);
}

.opt-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-panel);
  cursor: pointer;
}
.opt-impact {
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.impact-high   { background: #1e0a0a; color: var(--accent-red); }
.impact-medium { background: #1e110a; color: var(--accent-orange); }
.impact-low    { background: #0a1a10; color: var(--accent-green); }

.opt-title { font-size: 12px; font-weight: 600; color: var(--text-primary); flex: 1; }
.opt-gain  { font-size: 11px; font-weight: 700; color: var(--accent-green); }

.opt-card-body {
  padding: 10px;
  display: none;
  background: var(--bg-base);
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.opt-card.expanded .opt-card-body { display: block; }

.opt-code-block {
  background: var(--bg-panel);
  border: none;
  border-radius: 5px;
  padding: 10px;
  margin: 8px 0;
  font-family: inherit;
  font-size: 11px;
  white-space: pre;
  overflow-x: auto;
  color: #c9d1d9;
}
.opt-apply-btn {
  margin-top: 8px;
  padding: 4px 12px;
  background: var(--accent-green);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.opt-apply-btn:hover { background: #059669; }

/* ──────────── CHECKPOINT RESULTS ──────────── */
.ckpt-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: none;
  border-radius: 5px;
  margin-bottom: 6px;
  font-size: 11px;
  background: var(--bg-base);
}
.ckpt-name { flex: 0 0 120px; font-weight: 600; color: var(--text-primary); }
.ckpt-diff-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--bg-panel); overflow: hidden; }
.ckpt-diff-fill { height: 100%; border-radius: 3px; }
.ckpt-val { flex: 0 0 64px; text-align: right; font-weight: 700; }
.ckpt-pass { color: var(--accent-green); }
.ckpt-fail { color: var(--accent-red); }
.ckpt-diff-fill.pass { background: var(--accent-green); }
.ckpt-diff-fill.fail { background: var(--accent-red); }

/* ──────────── CONSTRAINT ITEMS ──────────── */
.ct-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 0;
  font-size: 11px;
}
.ct-icon { flex-shrink: 0; font-size: 13px; }
.ct-msg { flex: 1; color: var(--text-secondary); line-height: 1.5; }
.ct-ok   .ct-icon { color: var(--accent-green); }
.ct-warn .ct-icon { color: var(--accent-yellow); }
.ct-err  .ct-icon { color: var(--accent-red); }

/* ──────────── API DOCS LIST ──────────── */
.docs-search { padding: 8px; flex-shrink: 0; }
.docs-list { flex: 1; overflow-y: auto; padding: 6px; }
.doc-item {
  padding: 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s;
  border: none;
  margin-bottom: 4px;
}
.doc-item:hover { background: var(--bg-hover); }
.doc-item-name { font-size: 12px; font-weight: 600; color: var(--accent-blue); margin-bottom: 2px; }
.doc-item-desc { font-size: 11px; color: var(--text-muted); line-height: 1.5; }
.doc-item-tag {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 9px;
  background: var(--bg-base);
  border: none;
  color: var(--text-muted);
  margin-top: 4px;
  margin-right: 3px;
}

/* ──────────── SNIPPET LIST ──────────── */
.snippet-list { padding: 6px; overflow-y: auto; flex: 1; }
.snippet-item {
  padding: 10px;
  border: none;
  border-radius: 5px;
  margin-bottom: 6px;
  cursor: pointer;
  background: var(--bg-base);
  transition: background 0.12s;
}
.snippet-item:hover { background: var(--bg-hover); }
.snippet-name { font-size: 12px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.snippet-preview {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-base);
  border-radius: 3px;
  padding: 4px 6px;
  white-space: pre;
  overflow: hidden;
  max-height: 48px;
}

/* ──────────── SELECTED OP PANEL (in precision) ──────────── */
.op-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.od-color-bar { width: 4px; height: 36px; border-radius: 2px; flex-shrink: 0; }
.od-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.od-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.op-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.od-kv { display: flex; flex-direction: column; }
.od-k { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.od-v { font-size: 12px; color: var(--text-primary); font-weight: 500; }

.io-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 11px; }
.io-table th {
  text-align: left;
  padding: 4px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.io-table td {
  padding: 5px 6px;
  color: var(--text-secondary);
  vertical-align: middle;
}
.io-dir-in  { color: var(--accent-blue);  font-weight: 700; }
.io-dir-out { color: var(--accent-green); font-weight: 700; }
.tier-badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
}

/* ──────────── TYPING ANIMATION ──────────── */
.typing-dots {
  display: flex; align-items: center; gap: 4px; padding: 4px 0;
}
.typing-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ──────────── NOTIFICATION TOAST ──────────── */
#toast-container {
  position: fixed;
  bottom: 36px; right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: toast-in 0.2s ease, toast-out 0.2s ease 2.8s forwards;
  pointer-events: auto;
}
.toast.success { background: #052e16; border: none; color: var(--accent-green); }
.toast.error   { background: #1e0a0a; border: none; color: var(--accent-red); }
.toast.info    { background: #0c1a2e; border: none; color: var(--accent-blue); }
@keyframes toast-in  { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: none; } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; } }

/* ──────────── THINKING INDICATOR ──────────── */
.ai-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 10px;
}
.ai-thinking::before {
  content: '';
  display: inline-block;
  width: 10px; height: 10px;
  border: 2px solid var(--accent-purple);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ──────────── SVG GRAPH NODE STYLES ──────────── */
.pg-node { cursor: pointer; }
.pg-node rect {
  transition: stroke 0.2s, filter 0.2s;
  stroke-width: 1.5;
}
.pg-node:hover rect { stroke-width: 2.5; }
.pg-node.selected rect { stroke-width: 3; }
.pg-node.risk-high   rect { stroke: #ef4444; filter: url(#glow-red); }
.pg-node.risk-medium rect { stroke: #f97316; filter: url(#glow-orange); }
.pg-node.checkpoint rect { stroke-dasharray: 5 3; stroke: #3b82f6; }

.pg-edge { stroke: #243447; stroke-width: 1.5; fill: none; }
.pg-edge-active { stroke: #3b82f6; stroke-width: 2; }

/* ──────────── MISC ──────────── */
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23475569'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 22px !important;
  cursor: pointer;
}
