/* ====================================
   SVG TEST — Dark Theme Stylesheet
   ==================================== */

/* --- Reset & Custom Properties --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg:          #0d1117;
  --card:        #161b22;
  --border:      #30363d;
  --accent:      #3fb950;
  --accent-dim:  #238636;
  --blue:        #58a6ff;
  --amber:       #d29922;
  --red:         #f85149;
  --text:        #c9d1d9;
  --muted:       #8b949e;
  --bright:      #f0f6fc;
  --radius:      12px;
  --radius-sm:   8px;
  --mono:        'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Consolas', monospace;
  --sans:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* --- Layout (2 Bảng Song Song) --- */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 60px;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 28px;
  align-items: start;
}

.col-left {
  position: sticky;
  top: 24px;
}

.col-right {
  min-width: 0;
}

/* --- Config Panel --- */
.config {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.config-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.config-title::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.field {
  margin-bottom: 14px;
}

.security-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.4;
  opacity: 0.85;
}

.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 5px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: var(--mono);
  outline: none;
  transition: border-color 0.2s;
}

.field textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}

.field input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.field input:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input { flex: 1; }

/* --- Buttons --- */
.btn {
  display: block;
  width: 100%;
  padding: 11px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--sans);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-icon {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1;
  transition: border-color 0.2s;
  flex-shrink: 0;
}

.btn-icon:hover { border-color: var(--blue); }

.btn-connect {
  background: var(--blue);
  color: #fff;
  margin-bottom: 12px;
}

.btn-connect:hover:not(:disabled) { background: #79c0ff; }

.btn-run {
  background: linear-gradient(135deg, var(--accent-dim), #2ea043);
  color: #fff;
  margin-top: 6px;
  font-size: 15px;
  padding: 13px 16px;
}

.btn-run:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(63, 185, 80, 0.3); }

.btn-compare {
  background: linear-gradient(135deg, #1a6e30 0%, var(--accent-dim) 40%, var(--accent) 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 20px;
  border-radius: 10px;
  margin: 16px 0 12px;
  letter-spacing: 0.3px;
}

.btn-compare:hover:not(:disabled) {
  box-shadow: 0 6px 24px rgba(63, 185, 80, 0.35);
  transform: translateY(-1px);
}

/* --- Status Message --- */
.status-msg {
  font-size: 12px;
  font-family: var(--mono);
  margin-top: 8px;
  min-height: 18px;
  transition: color 0.2s;
}

.status-msg.ok      { color: var(--accent); }
.status-msg.warn    { color: var(--amber); }
.status-msg.err     { color: var(--red); }
.status-msg.loading { color: var(--amber); }

.protocol-badge {
  display: inline-block;
  font-size: 11px;
  font-family: var(--mono);
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(88, 166, 255, 0.12);
  color: var(--blue);
  border: 1px solid rgba(88, 166, 255, 0.3);
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 500;
  text-transform: none;
}

/* --- Result Card --- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  animation: cardIn 0.35s ease-out;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card > header {
  border-top: 3px solid var(--accent);
  padding: 12px 20px;
  background: rgba(63, 185, 80, 0.04);
}

.card > header p {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--bright);
  letter-spacing: 3px;
  text-transform: uppercase;
}

.icon-warn {
  color: var(--amber);
  margin-right: 8px;
}

.card-body {
  padding: 16px 20px 20px;
}

/* --- Placeholder Card --- */
.placeholder-body {
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
}

.placeholder-icon {
  font-size: 48px;
  margin-bottom: 16px;
  line-height: 1;
}

.placeholder-body h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--bright);
  margin-bottom: 8px;
}

.placeholder-body p {
  font-size: 13px;
  max-width: 420px;
  margin: 0 auto;
  line-height: 1.6;
}

.model-label {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 2px;
  word-break: break-all;
  line-height: 1.4;
}

.card-subtitle {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 14px;
}

/* --- SVG Render Frame --- */
.svg-frame {
  background: #0a0e14;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  min-height: 440px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.svg-render {
  width: 100%;
  padding: 6px;
}

.svg-render svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
}

.svg-error {
  color: var(--red);
  text-align: center;
  padding: 32px 16px;
  font-size: 13px;
  line-height: 1.6;
}

.svg-error details {
  margin-top: 12px;
  text-align: left;
}

.svg-error summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}

.svg-error pre {
  font-family: var(--mono);
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 180px;
  overflow: auto;
  margin-top: 8px;
  color: var(--muted);
  padding: 8px;
  background: var(--bg);
  border-radius: 4px;
}

/* --- Route Text & Metrics --- */
.route-text {
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  margin-top: 14px;
}

.metrics {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  padding-top: 4px;
}

.card-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 14px;
  line-height: 1.6;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

/* --- Loading Overlay --- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay p {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.loading-overlay .elapsed {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
}

/* --- Compare Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.92);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 960px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--bright);
}

.modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: var(--red);
  color: #fff;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

/* --- Compare Card (Mini) --- */
.cmp-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s;
}

.cmp-card:hover { border-color: var(--blue); }

.cmp-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cmp-head span {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--blue);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmp-del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.cmp-del:hover {
  color: var(--red);
  background: rgba(248, 81, 73, 0.1);
}

.cmp-preview {
  min-height: 200px;
  overflow: hidden;
}

.cmp-svg {
  height: 200px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.cmp-svg svg {
  width: 100%;
  height: 100%;
}

.cmp-svg .no-svg {
  color: var(--muted);
  font-size: 12px;
}

.cmp-foot {
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* --- Prompt Header & Lang Switch --- */
.prompt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.prompt-lang-switch {
  display: flex;
  gap: 4px;
}

.lang-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.lang-btn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

/* --- Result Top Row & Benchmark Tag --- */
.result-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.benchmark-tag {
  background: rgba(88, 166, 255, 0.12);
  color: var(--blue);
  border: 1px solid rgba(88, 166, 255, 0.3);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Assessment Box (Manxue AI Classifier) --- */
.assessment-box {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 12px 0 16px;
}

.assessment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.assessment-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.assessment-badge.normal {
  background: rgba(63, 185, 80, 0.18);
  color: #3fb950;
  border: 1px solid rgba(63, 185, 80, 0.4);
}

.assessment-badge.degraded {
  background: rgba(248, 81, 73, 0.18);
  color: #f85149;
  border: 1px solid rgba(248, 81, 73, 0.4);
}

.assessment-badge.unknown {
  background: rgba(210, 153, 34, 0.18);
  color: #d29922;
  border: 1px solid rgba(210, 153, 34, 0.4);
}

.assessment-reason {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 6px;
}

.assessment-source {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.8;
}

.btn-mini {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-mini:hover {
  border-color: var(--blue);
  color: var(--blue);
}

/* --- Candy Reasoning Card --- */
.candy-result-card {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 12px 0 16px;
}

.candy-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.candy-verdict-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 6px;
}

.candy-verdict-badge.passed {
  background: rgba(63, 185, 80, 0.18);
  color: #3fb950;
  border: 1px solid rgba(63, 185, 80, 0.4);
}

.candy-verdict-badge.degraded {
  background: rgba(248, 81, 73, 0.18);
  color: #f85149;
  border: 1px solid rgba(248, 81, 73, 0.4);
}

.candy-verdict-badge.unknown {
  background: rgba(210, 153, 34, 0.18);
  color: #d29922;
  border: 1px solid rgba(210, 153, 34, 0.4);
}

.candy-reasoning-info {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.candy-detail {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.5;
}

.candy-answer-box h4 {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.candy-answer-text {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--bright);
  background: #161b22;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  max-height: 380px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* --- Modal Tabs & Manxue Grid --- */
.modal-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.modal-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}

.modal-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.modal-tab.active {
  background: var(--card);
  color: var(--bright);
}

.manxue-monitor-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.manxue-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--bright);
}

.manxue-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
}

.manxue-badge.normal, .manxue-badge.passed {
  background: rgba(63, 185, 80, 0.18);
  color: #3fb950;
}

.manxue-badge.degraded, .manxue-badge.incorrect {
  background: rgba(248, 81, 73, 0.18);
  color: #f85149;
}

.manxue-card-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
  font-size: 14px;
}

/* --- Hidden utility --- */
[hidden] { display: none !important; }

/* --- Responsive --- */
@media (max-width: 860px) {
  main {
    grid-template-columns: 1fr;
    max-width: 520px;
    padding: 20px 14px 48px;
    gap: 20px;
  }
  .col-left {
    position: static;
  }
  .svg-frame {
    min-height: 320px;
  }
}

@media (max-width: 520px) {
  main { padding: 12px 10px 40px; }
  .modal-body { grid-template-columns: 1fr; }
  .card > header p { font-size: 12px; letter-spacing: 2px; }
}
