/* TMC Assistant embeddable widget — scoped styles
   All rules are nested inside .tmc-assistant-root so they never leak into the host page. */
.tmc-assistant-root, .tmc-assistant-root * {
  box-sizing: border-box;
}
.tmc-assistant-root {
  --tmc-primary: #0F766E;
  --tmc-primary-fg: #ffffff;
  --tmc-bg: #ffffff;
  --tmc-fg: #0f172a;
  --tmc-muted: #f1f5f9;
  --tmc-muted-fg: #475569;
  --tmc-border: #e2e8f0;
  --tmc-success: #16a34a;
  --tmc-radius: 12px;
  --tmc-shadow: 0 6px 24px rgba(15, 118, 110, 0.08);

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--tmc-fg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.tmc-assistant-root.tmc-dark {
  --tmc-bg: #0b1220;
  --tmc-fg: #e2e8f0;
  --tmc-muted: #1e293b;
  --tmc-muted-fg: #94a3b8;
  --tmc-border: #1e293b;
  --tmc-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
.tmc-panel {
  background: var(--tmc-bg);
  border: 1px solid var(--tmc-border);
  border-radius: var(--tmc-radius);
  box-shadow: var(--tmc-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 480px;
  max-height: 720px;
}
.tmc-header {
  background: linear-gradient(180deg, var(--tmc-primary), color-mix(in srgb, var(--tmc-primary) 85%, black));
  color: var(--tmc-primary-fg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.tmc-header-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.tmc-header-title { font-weight: 600; font-size: 15px; }
.tmc-header-sub { font-size: 11px; opacity: 0.85; }
.tmc-header-user { margin-left: auto; font-size: 11px; opacity: 0.9; }

.tmc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--tmc-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tmc-msg { max-width: 88%; padding: 10px 12px; border-radius: 10px; word-wrap: break-word; }
.tmc-msg.user { align-self: flex-end; background: var(--tmc-primary); color: var(--tmc-primary-fg); border-bottom-right-radius: 2px; }
.tmc-msg.assistant { align-self: flex-start; background: var(--tmc-muted); color: var(--tmc-fg); border-bottom-left-radius: 2px; }
.tmc-msg.system { align-self: center; background: transparent; color: var(--tmc-muted-fg); font-size: 12px; padding: 4px 8px; }

.tmc-msg p { margin: 0 0 6px 0; }
.tmc-msg p:last-child { margin-bottom: 0; }
.tmc-msg ul, .tmc-msg ol { margin: 4px 0 6px 18px; }
.tmc-msg li { margin: 2px 0; }
.tmc-msg code { background: rgba(15,118,110,0.1); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.tmc-msg strong { font-weight: 600; }
.tmc-msg a { color: var(--tmc-primary); text-decoration: underline; }

.tmc-cite {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  background: rgba(15,118,110,0.15);
  color: var(--tmc-primary);
  border: 1px solid rgba(15,118,110,0.3);
  padding: 0 5px;
  border-radius: 4px;
  margin: 0 2px;
  cursor: pointer;
  vertical-align: baseline;
}
.tmc-cite:hover { background: rgba(15,118,110,0.25); }

.tmc-citations-tray {
  border-top: 1px solid var(--tmc-border);
  background: var(--tmc-muted);
  max-height: 160px;
  overflow-y: auto;
  padding: 8px 12px;
  font-size: 12px;
}
.tmc-citations-tray-title { font-weight: 600; color: var(--tmc-muted-fg); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.tmc-citation-row { padding: 6px 8px; border-radius: 6px; background: var(--tmc-bg); margin-bottom: 4px; border: 1px solid var(--tmc-border); }
.tmc-citation-row-title { font-weight: 500; }
.tmc-citation-row-meta { font-size: 11px; color: var(--tmc-muted-fg); margin-top: 2px; }

.tmc-input-row {
  border-top: 1px solid var(--tmc-border);
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--tmc-bg);
}
.tmc-input {
  flex: 1;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--tmc-fg);
  background: var(--tmc-bg);
  border: 1px solid var(--tmc-border);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  min-height: 42px;
  max-height: 120px;
}
.tmc-input:focus { border-color: var(--tmc-primary); box-shadow: 0 0 0 3px rgba(15,118,110,0.15); }
.tmc-send {
  background: var(--tmc-primary);
  color: var(--tmc-primary-fg);
  border: none;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.tmc-send:hover { filter: brightness(0.95); }
.tmc-send:disabled { opacity: 0.5; cursor: not-allowed; }

.tmc-suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.tmc-suggestion {
  text-align: left;
  background: var(--tmc-muted);
  border: 1px solid var(--tmc-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--tmc-fg);
}
.tmc-suggestion:hover { background: var(--tmc-bg); border-color: var(--tmc-primary); }

.tmc-empty {
  text-align: center;
  padding: 24px 16px;
  color: var(--tmc-muted-fg);
}
.tmc-empty-title { font-weight: 600; color: var(--tmc-fg); margin-bottom: 4px; }

.tmc-loading {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: tmc-spin 0.7s linear infinite;
}
@keyframes tmc-spin { to { transform: rotate(360deg); } }

.tmc-thinking-dots span {
  display: inline-block;
  width: 6px; height: 6px;
  margin: 0 2px;
  border-radius: 50%;
  background: var(--tmc-muted-fg);
  animation: tmc-bounce 1.2s infinite ease-in-out;
}
.tmc-thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.tmc-thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tmc-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.tmc-auth-state {
  padding: 30px 24px;
  text-align: center;
  color: var(--tmc-muted-fg);
}
.tmc-auth-state-title { color: var(--tmc-fg); font-weight: 600; margin-bottom: 6px; }
.tmc-auth-button {
  margin-top: 12px;
  background: var(--tmc-primary);
  color: white;
  border: none;
  padding: 9px 16px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
}
.tmc-error { color: #b91c1c; font-size: 12px; margin-top: 6px; }

/* Responsive: stack everything on narrow viewports */
@media (max-width: 480px) {
  .tmc-panel { min-height: 420px; max-height: 80vh; }
  .tmc-suggestions { grid-template-columns: 1fr; }
}
