/* The SMB Fix — Premium Chat UI v3 */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #0a0a0a;
  --bg2: #141414;
  --bg3: #1c1c1c;
  --border: #222;
  --border-hover: #333;
  --text: #f0f0f0;
  --text2: #aaa;
  --text3: #777;
  --muted: #555;
  --accent: #e8ff47;
  --accent-dim: #e8ff4712;
  --accent-border: #e8ff4730;
  --green: #4ade80;
  --green-dim: #4ade8018;
  --yellow: #fbbf24;
  --yellow-dim: #fbbf2418;
  --red: #f87171;
  --red-dim: #f8717118;
  --blue: #60a5fa;
  --blue-dim: #60a5fa18;
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Space Grotesk', -apple-system, sans-serif;
}

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Noise overlay */
body::before {
  content: '';
  position: fixed; inset: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 9999;
}

/* ── Header ── */
.chat-header {
  padding: 14px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.chat-header .back { color: var(--text3); text-decoration: none; font-size: 13px; font-weight: 500; font-family: var(--mono); transition: color .2s; }
.chat-header .back:hover { color: var(--accent); }
.chat-header .icon { font-size: 18px; }
.chat-header .title { font-size: 15px; font-weight: 600; flex: 1; letter-spacing: -.3px; }
.chat-header .badge {
  font-size: 10px; padding: 3px 10px; border-radius: 2px;
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid var(--accent-border);
  font-weight: 600; font-family: var(--mono);
  text-transform: uppercase; letter-spacing: 1px;
}

/* ── Stats Bar ── */
.stats-bar {
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.stat-item {
  flex: 1;
  padding: 14px 18px;
  border-right: 1px solid var(--border);
  text-align: center;
}
.stat-item:last-child { border-right: none; }
.stat-value {
  font-size: 18px; font-weight: 700; color: var(--accent);
  line-height: 1.2; font-family: var(--mono);
}
.stat-value.green { color: var(--green); }
.stat-value.yellow { color: var(--yellow); }
.stat-value.blue { color: var(--blue); }
.stat-label {
  font-size: 11px; color: var(--text2); /* BRIGHTER */
  margin-top: 4px;
}

/* ── Use Cases — full width, spread evenly ── */
.use-cases {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  padding: 14px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.use-case-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border-radius: 3px;
  background: var(--bg2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all .2s;
  text-align: center;
}
.use-case-chip:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.use-case-chip .chip-icon { font-size: 18px; }
.use-case-chip .chip-label {
  font-size: 11px; color: var(--text2); font-weight: 500;
  white-space: nowrap;
}
.use-case-chip .chip-desc {
  font-size: 9px; color: var(--text3);
  font-family: var(--mono);
  white-space: nowrap;
}
.use-case-chip:hover .chip-label { color: var(--accent); }
.use-case-chip:hover .chip-desc { color: var(--text3); }

/* ── Chat Area ── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}
.chat-area::-webkit-scrollbar { width: 4px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); }

/* ── Messages ── */
.message {
  max-width: 90%;
  animation: msgIn .4s cubic-bezier(.16,1,.3,1);
}
.message.bot { align-self: flex-start; }
.message.user { align-self: flex-end; }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.message-bubble {
  padding: 16px 20px;
  border-radius: 3px;
  line-height: 1.7;
  font-size: 14px;
  position: relative;
}
.message.bot .message-bubble {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
}
.message.user .message-bubble {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
}

/* ── Result Bubble — separate, copyable ── */
.result-bubble {
  background: var(--bg2);
  border: 1px solid var(--accent-border);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  margin-top: 12px;
  max-width: 90%;
  align-self: flex-start;
  animation: resultIn .5s cubic-bezier(.16,1,.3,1);
}
@keyframes resultIn {
  from { opacity: 0; transform: translateY(16px) scale(.96); border-left-color: transparent; }
  to { opacity: 1; transform: translateY(0) scale(1); border-left-color: var(--accent); }
}
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--accent-border);
  background: var(--accent-dim);
}
.result-header .result-title {
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  font-family: var(--mono);
}
.result-content {
  padding: 18px 20px;
  line-height: 1.7;
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
}
.result-actions {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--border);
  background: var(--bg3);
}
.result-action {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 8px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text2);
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  position: relative;
}
.result-action:last-child { border-right: none; }
.result-action:hover {
  color: var(--accent);
  background: var(--accent-dim);
  transform: translateY(-1px);
}
.result-action:active {
  transform: translateY(1px);
  background: var(--accent-border);
}
.result-action .action-icon { font-size: 18px; }
.result-action .action-label { font-size: 9px; text-transform: uppercase; letter-spacing: .5px; }
.result-action.copied {
  color: var(--green) !important;
  background: var(--green-dim) !important;
}
.result-action.copied .action-label { font-weight: 700; }

/* ── Copy button on regular messages ── */
.msg-actions {
  display: flex; gap: 6px;
  margin-top: 8px; opacity: 0;
  transition: opacity .2s;
}
.message:hover .msg-actions { opacity: 1; }

.copy-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text3); font-size: 10px;
  padding: 3px 8px; border-radius: 2px;
  cursor: pointer; font-family: var(--mono);
  transition: all .2s;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn.copied { color: var(--green); border-color: var(--green); }

/* ── Thinking Indicator ── */
.thinking {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: 3px;
  max-width: 90%; align-self: flex-start;
  animation: msgIn .4s cubic-bezier(.16,1,.3,1);
}
.thinking-dots { display: flex; gap: 3px; }
.thinking-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite both;
}
.thinking-dots span:nth-child(2) { animation-delay: .15s; }
.thinking-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes pulse {
  0%, 80%, 100% { opacity: .3; transform: scale(.8); }
  40% { opacity: 1; transform: scale(1.2); }
}
.thinking-text {
  font-size: 12px; color: var(--text2); /* BRIGHTER */
  font-family: var(--mono);
}
.thinking-text .step { animation: fadeIn .3s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Validation Steps ── */
.validation-steps { margin: 10px 0; display: flex; flex-direction: column; gap: 5px; }
.val-step { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); font-family: var(--mono); }
.val-step .icon { font-size: 12px; }
.val-step.pass .icon { color: var(--green); }
.val-step.warn .icon { color: var(--yellow); }
.val-step.fail .icon { color: var(--red); }
.val-step.pass { color: var(--green); }
.val-step.warn { color: var(--yellow); }
.val-step.fail { color: var(--red); }

/* ── Knowledge Section ── */
.knowledge-section {
  margin: 10px 0; padding: 10px 14px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-left: 2px solid var(--accent);
  border-radius: 2px;
}
.knowledge-section .k-title {
  font-size: 10px; color: var(--accent);
  text-transform: uppercase; letter-spacing: .8px;
  font-weight: 600; margin-bottom: 6px;
  font-family: var(--mono);
}
.knowledge-section .k-item { font-size: 13px; color: var(--text2); line-height: 1.6; }

/* ── Structured Output ── */
.field-grid { display: grid; grid-template-columns: 130px 1fr; gap: 4px 16px; margin: 12px 0; }
.field-label { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; padding-top: 3px; font-family: var(--mono); }
.field-value { font-size: 14px; color: var(--text); font-weight: 500; }
.field-value.flag { color: var(--yellow); }
.field-value.error { color: var(--red); }
.divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* Classification badges */
.classification {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 2px;
  font-size: 11px; font-weight: 600;
  font-family: var(--mono); text-transform: uppercase; letter-spacing: .5px;
}
.classification.hot { background: var(--red-dim); color: var(--red); border: 1px solid #f8717130; }
.classification.warm { background: var(--yellow-dim); color: var(--yellow); border: 1px solid #fbbf2430; }
.classification.cold { background: var(--blue-dim); color: var(--blue); border: 1px solid #60a5fa30; }
.classification.order { background: var(--blue-dim); color: var(--blue); }
.classification.product { background: var(--green-dim); color: var(--green); }
.classification.billing { background: var(--yellow-dim); color: var(--yellow); }
.classification.complaint { background: var(--red-dim); color: var(--red); }
.classification.return { background: var(--green-dim); color: var(--green); }

.score-badge { font-size: 20px; margin-right: 4px; }

/* ── Input Area ── */
.input-area {
  padding: 14px 24px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; flex-shrink: 0;
}
.input-area textarea {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px; font-family: var(--sans);
  resize: none; height: 52px;
  transition: border-color .2s;
  line-height: 1.5;
}
.input-area textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-border);
}
.input-area textarea::placeholder { color: var(--text3); } /* BRIGHTER */

.send-btn {
  background: var(--accent); color: #000;
  border: none; padding: 12px 22px; border-radius: 2px;
  cursor: pointer; font-size: 13px; font-weight: 700;
  white-space: nowrap; font-family: var(--mono);
  transition: all .2s;
  display: flex; align-items: center; gap: 6px;
  text-transform: uppercase; letter-spacing: .5px;
}
.send-btn:hover { opacity: .85; transform: translateY(-1px); }
.send-btn:active { transform: translateY(0); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.send-btn .spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(0,0,0,.2);
  border-top-color: #000; border-radius: 50%;
  animation: spin .5s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── CTA Bar ── */
.cta-bar {
  padding: 10px 24px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  text-align: center; flex-shrink: 0;
}
.cta-bar a { color: var(--accent); text-decoration: none; font-size: 11px; font-weight: 600; font-family: var(--mono); letter-spacing: .3px; transition: opacity .2s; }
.cta-bar a:hover { opacity: .7; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .use-cases { grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 10px 16px; }
  .use-case-chip .chip-desc { display: none; }
  .stats-bar { flex-wrap: wrap; }
  .stat-item { min-width: 70px; padding: 10px; }
  .stat-value { font-size: 15px; }
  .message, .result-bubble { max-width: 96%; }
  .field-grid { grid-template-columns: 100px 1fr; }
  .input-area { padding: 10px 16px; }
  .chat-area { padding: 16px; }
}
