/* packages/web/public/assets/tokens.css */

/* === Design tokens · Linear Dark · Dermalliance === */
:root {
  /* Backgrounds */
  --bg: #1A1A17;
  --bg-elev: #23231F;
  --bg-elev-2: #2C2B25;

  /* Borders */
  --border: #37362E;
  --border-soft: #2B2A24;

  /* Text */
  --text: #ECE7D7;
  --text-dim: #A19B89;
  --text-muted: #72695B;

  /* Accents */
  --yellow: #FFD836;
  --yellow-dim: #B8952A;
  --yellow-soft: rgba(255, 216, 54, 0.12);

  /* States */
  --green: #7DBD88;      /* answered */
  --orange: #E89B88;     /* unanswered */
  --orange-dim: #B4796A;
  --red: #E57471;
  --sage: #93A99F;
  --sage-dim: #5F7770;   /* clinical redirect */
  --doc-blue: #7EA7D9;   /* source type pill */

  /* Font families */
  --font-sans: 'Satoshi', -apple-system, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-serif: 'Instrument Serif', Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* noise grain overlay — reusable utility, apply to app root if desired */
.noise::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.05 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: screen; opacity: 0.35; z-index: 0;
}
.yellow-glow::after {
  content: ""; position: absolute; top: -120px; right: -80px;
  width: 340px; height: 340px; pointer-events: none; z-index: 0;
  background: radial-gradient(circle at center, rgba(255, 216, 54, 0.06) 0%, transparent 65%);
}

/* === Buttons === */
.btn {
  font-family: var(--font-sans);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.14s;
  letter-spacing: -0.005em;
}
.btn:hover { background: var(--bg-elev-2); border-color: var(--text-muted); }
.btn-primary {
  background: var(--yellow);
  color: #1A1A17;
  border-color: var(--yellow);
  font-weight: 600;
}
.btn-primary:hover { background: #FFE25E; border-color: #FFE25E; }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover { color: var(--text); background: var(--bg-elev); }

/* === Inputs === */
.input-wrap {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px 4px 4px 14px;
  display: flex; align-items: center; gap: 10px;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.input-wrap:focus-within {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255, 216, 54, 0.14);
}
.input-wrap input, .input-wrap textarea {
  flex: 1; border: 0; background: transparent; outline: none;
  font-family: var(--font-sans); font-size: 14px;
  padding: 11px 0; color: var(--text); letter-spacing: -0.005em;
  resize: none;
}
.input-wrap input::placeholder, .input-wrap textarea::placeholder { color: var(--text-muted); }

/* === Kbd keycap === */
.kbd {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 3px; color: var(--text-dim);
  font-family: var(--font-mono); font-size: inherit;
}

/* === Badges (status) === */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600;
  line-height: 1.4;
}
.badge .bullet {
  width: 5px; height: 5px; border-radius: 50%; background: currentColor;
  box-shadow: 0 0 6px currentColor;
}
.badge-answered { background: rgba(125, 189, 136, 0.1); color: var(--green); border: 1px solid rgba(125, 189, 136, 0.22); }
.badge-high { background: rgba(255, 216, 54, 0.08); color: var(--yellow); border: 1px solid rgba(255, 216, 54, 0.22); }
.badge-unanswered { background: rgba(232, 155, 136, 0.1); color: var(--orange); border: 1px solid rgba(232, 155, 136, 0.22); }
.badge-clinical { background: rgba(147, 169, 159, 0.1); color: var(--sage); border: 1px solid rgba(147, 169, 159, 0.22); }

/* === Label tags (monospace small) === */
.label-tag {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-muted); background: var(--bg-elev);
  border: 1px solid var(--border); padding: 1px 5px; border-radius: 3px;
  letter-spacing: 0.06em; text-transform: uppercase; font-weight: 500;
}

/* === Section label (monospace caps with line) === */
.section-label {
  font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted); margin: 0 0 10px;
  display: flex; align-items: center; gap: 10px;
}
.section-label::after {
  content: ""; flex: 1; height: 1px; background: var(--border-soft);
}

/* === D+ mini logo — inline SVG styling === */
.logo-mark { display: inline-flex; align-items: center; }

/* === User chip === */
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border); border-radius: 100px;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-dim); letter-spacing: -0.005em;
}
.user-chip .avatar {
  width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(135deg, var(--yellow) 0%, #D9A829 100%);
  color: #1A1A17; font-size: 9px; font-weight: 700; font-family: var(--font-sans);
  display: flex; align-items: center; justify-content: center;
}
.user-chip .role-badge {
  background: var(--yellow-soft); color: var(--yellow);
  padding: 1px 6px; border-radius: 3px;
  font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase;
  font-weight: 600;
}

/* === Bubble · user (right-aligned) === */
.msg-user { display: flex; flex-direction: column; align-items: flex-end; margin: 20px 0 12px; }
.msg-user .bubble {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 14px 14px 4px 14px;
  padding: 11px 14px;
  max-width: 78%;
  font-size: 14px;
  color: var(--text); line-height: 1.45;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
  letter-spacing: -0.005em;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg-user .msg-time {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-muted); margin-top: 6px; letter-spacing: 0.03em;
  padding-right: 4px;
}

/* === Bubble · bot (full width with yellow/orange/sage left rail) === */
.msg-bot { margin: 16px 0 24px; padding: 2px 0 2px 16px; border-left: 2px solid var(--yellow-dim); }
.msg-bot.is-unanswered { border-left-color: var(--orange-dim); }
.msg-bot.is-clinical { border-left-color: var(--sage-dim); }
.msg-bot.is-error { border-left-color: var(--red); }

.msg-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.avatar-mini {
  width: 20px; height: 20px; border-radius: 5px; background: var(--yellow);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  box-shadow: 0 0 0 2px var(--bg);
}
.avatar-mini svg { width: 13px; height: 10px; }
.meta-name {
  font-family: var(--font-sans); font-size: 12px;
  font-weight: 600; color: var(--text); letter-spacing: -0.01em;
}
.meta-time {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-muted); margin-left: auto; letter-spacing: 0.03em;
}

.msg-body { font-family: var(--font-sans); font-size: 14.5px; color: var(--text); line-height: 1.58; letter-spacing: -0.005em; }
.msg-body p { margin-bottom: 10px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body ul { list-style: none; padding-left: 0; margin: 4px 0 10px; }
.msg-body ul li { padding-left: 18px; position: relative; margin-bottom: 5px; font-size: 14px; }
.msg-body ul li::before { content: "—"; position: absolute; left: 0; color: var(--yellow-dim); font-weight: 500; }
.msg-body .highlight { background: rgba(255, 216, 54, 0.1); padding: 1px 4px; border-radius: 3px; }

.msg-footer { display: flex; align-items: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.sources-btn {
  background: var(--bg-elev); border: 1px solid var(--border);
  padding: 5px 10px 5px 9px; border-radius: 6px;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-dim); font-family: var(--font-sans);
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all 0.14s; letter-spacing: -0.005em;
}
.sources-btn:hover { border-color: var(--yellow-dim); color: var(--text); background: var(--bg-elev-2); }
.sources-btn svg { color: var(--text-muted); flex: none; }
.sources-btn:hover svg { color: var(--yellow); }
.sources-btn .count { font-family: var(--font-mono); font-size: 10.5px; color: var(--yellow); font-weight: 600; }

.fb-group { display: inline-flex; gap: 3px; }
.fb-btn {
  width: 28px; height: 28px; border-radius: 6px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: all 0.14s;
}
.fb-btn:hover { background: var(--bg-elev); }
.fb-btn.up:hover { color: var(--green); border-color: rgba(125, 189, 136, 0.35); }
.fb-btn.down:hover { color: var(--red); border-color: rgba(229, 116, 113, 0.35); }
.fb-btn.active-up { color: var(--green); border-color: rgba(125, 189, 136, 0.45); background: rgba(125, 189, 136, 0.06); }
.fb-btn.active-down { color: var(--red); border-color: rgba(229, 116, 113, 0.45); background: rgba(229, 116, 113, 0.06); }

.meta-right { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); }

.ticket-bar {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-dim);
  margin-top: 14px; padding: 7px 11px 7px 9px; background: var(--bg-elev);
  border: 1px dashed var(--border); border-radius: 7px;
}
.ticket-bar svg { color: var(--orange); flex: none; }
.ticket-bar .ticket-id { color: var(--orange); font-weight: 500; }

/* === Modal === */
.backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 10, 9, 0.66);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  cursor: pointer;
}
.modal {
  position: fixed; z-index: 50;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 216, 54, 0.08);
}
.modal-desktop {
  top: 50%; left: 50%;
  width: min(560px, 92vw); max-height: 80vh;
  transform: translate(-50%, -50%);
}
@media (max-width: 600px) {
  .modal-desktop { display: none; }
}
.modal-mobile {
  left: 0; right: 0; bottom: 0;
  width: 100%; max-height: 82vh;
  border-radius: 18px 18px 0 0;
}
@media (min-width: 601px) {
  .modal-mobile { display: none; }
}
.modal-mobile::before {
  content: ""; position: absolute; top: 7px; left: 50%;
  transform: translateX(-50%);
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border); opacity: 0.6;
}
.modal-header {
  padding: 18px 18px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border-soft); flex: none;
}
.modal-mobile .modal-header { padding-top: 22px; }
.modal-header h2 { font-family: var(--font-sans); font-size: 15.5px; font-weight: 700; color: var(--text); letter-spacing: -0.015em; }
.modal-close {
  width: 30px; height: 30px; border-radius: 7px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.14s;
}
.modal-close:hover { background: var(--bg-elev-2); color: var(--text); border-color: var(--text-muted); }
.modal-body { flex: 1; overflow-y: auto; padding: 6px 18px; }
.modal-footer {
  padding: 12px 18px; border-top: 1px solid var(--border-soft); background: var(--bg);
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted);
  flex: none; flex-wrap: wrap; gap: 8px;
}

/* Source cards inside modal */
.source { padding: 18px 0; border-bottom: 1px solid var(--border-soft); }
.source:last-child { border-bottom: 0; }
.source-type {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600;
  color: var(--doc-blue); background: rgba(126, 167, 217, 0.08);
  border: 1px solid rgba(126, 167, 217, 0.2);
  padding: 3px 8px 3px 6px; border-radius: 4px; margin-bottom: 10px;
}
.source-title { font-family: var(--font-sans); font-size: 14.5px; font-weight: 600; color: var(--text); margin-bottom: 12px; letter-spacing: -0.015em; }
.source-quote { border-left: 2px solid var(--yellow-dim); padding: 4px 0 4px 14px; font-family: var(--font-sans); font-size: 13.5px; color: var(--text-dim); line-height: 1.58; margin-bottom: 12px; position: relative; }
.source-quote::before { content: "“"; position: absolute; left: 10px; top: -8px; color: var(--yellow-dim); font-family: var(--font-serif); font-size: 22px; font-style: italic; opacity: 0.6; }
.source-link { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--yellow-dim); font-weight: 600; text-decoration: none; padding: 4px 0; transition: color 0.14s; }
.source-link:hover { color: var(--yellow); }

/* === App shell (chat) === */
.app { height: 100vh; display: flex; flex-direction: column; position: relative; }
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border-soft);
  flex: none;
}
.app-header .logo { display: flex; align-items: center; gap: 9px; }
.app-header .logo-word { font-family: var(--font-sans); font-weight: 700; letter-spacing: -0.025em; font-size: 14.5px; color: var(--text); }

/* Conversation scroll area */
.messages { flex: 1; overflow-y: auto; padding: 0 20px; scroll-behavior: smooth; }
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
@media (min-width: 900px) {
  .messages { max-width: 820px; margin: 0 auto; width: 100%; padding: 0 40px; }
}

/* Composer */
.composer { padding: 14px 16px 16px; border-top: 1px solid var(--border-soft); background: var(--bg); flex: none; }
@media (min-width: 900px) {
  .composer { padding: 16px 60px 24px; }
  .composer > .input-wrap, .composer .composer-hints { max-width: 700px; margin-left: auto; margin-right: auto; }
}
.composer-hints {
  margin-top: 10px; display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted);
  flex-wrap: wrap; gap: 8px;
}
.composer-hints .warn { color: var(--yellow-dim); display: flex; align-items: center; gap: 6px; }
.composer-hints .blocked-pii { color: var(--orange); }

/* Today divider */
.today-divider {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 0 6px;
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-muted);
}
.today-divider::before, .today-divider::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }
.today-divider .date { padding: 0 8px; }

/* Login specific */
.login-shell {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; overflow: hidden;
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 28px 24px;
  position: relative; z-index: 1;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.login-card h1 { font-family: var(--font-sans); font-size: 26px; font-weight: 700; letter-spacing: -0.025em; color: var(--text); margin-bottom: 8px; }
.login-card .sub { font-family: var(--font-sans); font-size: 14px; color: var(--text-dim); line-height: 1.5; margin-bottom: 22px; }
.login-card .error { color: var(--red); font-size: 12.5px; font-family: var(--font-mono); margin-top: 8px; letter-spacing: -0.005em; }
.login-card .help { font-size: 12px; color: var(--text-muted); margin-top: 16px; text-align: center; }
.login-card .help a { color: var(--yellow-dim); text-decoration: none; }
.login-card .help a:hover { color: var(--yellow); }
