/* ============================================================================
   DGLink shared design system
   ----------------------------------------------------------------------------
   Single source of truth for the look of every DGLink tool (Chat Assistant,
   Sequence Search, Query Builder). This file is kept byte-identical in each
   frontend's static/ directory. Edit one copy, then copy it to the others:

     cp mcp/frontend/static/dglink.css \
        semantic_search/frontend/static/dglink.css
     cp mcp/frontend/static/dglink.css \
        genomic_index/genomic_index_query_frontend/static/dglink.css
   ========================================================================== */

:root {
  --navy:            #14212b;
  --navy-2:          #1d2d38;
  --teal:            #0f7d70;
  --teal-dark:       #0b6459;
  --teal-tint:       #e3f0ed;
  --teal-tint-line:  #b9dcd5;
  --gold:            #b8860b;
  --gold-text:       #97710a;
  --gold-tint:       #fbf1dd;
  --gold-line:       #e6cf91;
  --orange:          #d0492b;
  --stripe-gray:     #9aa5ad;
  --bg:              #f4f6f7;
  --card:            #ffffff;
  --border:          #e4e8eb;
  --ink:             #14212b;
  --body:            #33424c;
  --muted:           #64748b;
  --mono: "SF Mono", "Menlo", "Consolas", "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 1px 2px rgba(20, 33, 43, .04), 0 1px 3px rgba(20, 33, 43, .06);
  --shadow-lg: 0 6px 20px rgba(20, 33, 43, .10);
}

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

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---- Header + nav ------------------------------------------------------- */
.site-header {
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  text-decoration: none;
}
/* The mark lives in static/dglink-logo.svg, so it has no intrinsic size of its
   own — sizing it is this rule's job. */
.brand-logo { display: block; width: 34px; height: 34px; }
.brand-name {
  color: #fff;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.site-nav { display: flex; gap: 2rem; }
.site-nav a {
  color: #9fb0ba;
  text-decoration: none;
  font-size: 1.02rem;
  padding-bottom: 3px;
  border-bottom: 2px solid transparent;
  transition: color .15s;
}
.site-nav a:hover { color: #d7e0e5; }
.site-nav a.active {
  color: #fff;
  border-bottom-color: var(--teal);
}

/* repeating teal / gold / orange / gray accent ribbon under the header */
.accent-stripe {
  height: 7px;
  background: repeating-linear-gradient(
    90deg,
    var(--teal)        0,   var(--teal)        62px,
    var(--gold)        62px, var(--gold)       124px,
    var(--orange)      124px, var(--orange)    186px,
    var(--stripe-gray) 186px, var(--stripe-gray) 248px
  );
}

/* ---- Layout primitives -------------------------------------------------- */
.container {
  max-width: 820px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.6rem 1.9rem;
  box-shadow: var(--shadow);
}

.eyebrow {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .74rem;
  font-weight: 700;
  color: var(--teal);
}
.eyebrow.muted { color: var(--muted); }

.page-title {
  font-size: 1.95rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.02em;
  margin: .35rem 0 .25rem;
}
.subtitle { color: var(--muted); font-size: 1.02rem; }

/* ---- Forms -------------------------------------------------------------- */
.form-field { margin-bottom: 1.35rem; position: relative; }
.label {
  display: block;
  font-weight: 600;
  font-size: .92rem;
  color: var(--body);
  margin-bottom: .45rem;
}
.field {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem .9rem;
  font-size: .95rem;
  font-family: var(--sans);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field.mono { font-family: var(--mono); }
.field::placeholder { color: #9aa8b1; }
.field:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 125, 112, .13);
}
textarea.field { resize: vertical; line-height: 1.6; }
select.field { cursor: pointer; }

.field-row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.field-row .form-field { margin-bottom: 0; }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: .7rem 1.4rem;
  font-family: var(--sans);
  font-size: .96rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--teal-dark); }
.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: .8rem; align-items: center; margin-top: 1.6rem; }

a.link {
  color: var(--teal);
  font-weight: 600;
  text-decoration: none;
}
a.link:hover { text-decoration: underline; }

/* ---- Chips / badges ----------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-family: var(--mono);
  font-size: .8rem;
  white-space: nowrap;
}
.chip-id    { background: var(--teal-tint); color: var(--teal-dark); border-color: var(--teal-tint-line); }
.chip-obj   { background: var(--gold-tint); color: var(--gold-text); border-color: var(--gold-line); }
.chip-match { background: #fff; color: var(--gold-text); border-color: var(--gold-line); }
.chip-hit   { background: var(--teal-tint); color: var(--teal-dark); border-color: var(--teal-tint-line); }
.chip-valid   { background: #e7f3e0; color: #3b6d11; border-color: #c3e0a1; }
.chip-invalid { background: #fbe9e9; color: #a32d2d; border-color: #f0bcbc; }
.chip-muted   { opacity: .5; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }

.error-banner {
  background: #fbe9e9;
  border: 1px solid #f0bcbc;
  color: #a32d2d;
  border-radius: 10px;
  padding: .75rem 1rem;
  font-size: .92rem;
  margin-top: 1rem;
}

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255, 255, 255, .5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: dgl-spin .6s linear infinite;
}
@keyframes dgl-spin { to { transform: rotate(360deg); } }

/* ---- Autocomplete dropdown (Query Builder) ------------------------------ */
.autocomplete {
  position: absolute;
  z-index: 30;
  left: 0; right: 0;
  margin-top: 4px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  max-height: 220px;
  overflow-y: auto;
}
.autocomplete li {
  padding: .55rem .9rem;
  font-size: .92rem;
  color: var(--body);
  cursor: pointer;
}
.autocomplete li:hover { background: var(--teal-tint); color: var(--teal-dark); }

/* ============================================================================
   Chat Assistant
   ========================================================================== */
.chat {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px - 7px);
}
.chat-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
}
.chat-toolbar label { font-size: .85rem; color: var(--muted); }
.provider-select {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .4rem .7rem;
  font-size: .86rem;
  color: var(--ink);
  cursor: pointer;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: .25rem 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.message { display: flex; gap: .85rem; animation: dgl-fade .3s ease; }
.message.user { justify-content: flex-end; }
@keyframes dgl-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.avatar {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--navy);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar img { width: 28px; height: 28px; display: block; }
.msg-body {
  border-radius: 14px;
  padding: 1.1rem 1.4rem;
  font-size: var(--chat-font, 1rem);
  line-height: 1.6;
}
.message.assistant .msg-body {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--body);
  box-shadow: var(--shadow);
}
.message.user .msg-body {
  background: var(--teal);
  color: #fff;
  max-width: 70%;
}
.msg-body.error { background: #fbe9e9; border-color: #f0bcbc; color: #a32d2d; }

/* markdown inside assistant messages */
.msg-body h1, .msg-body h2, .msg-body h3 { color: var(--ink); margin: 1rem 0 .5rem; line-height: 1.3; }
.msg-body h1 { font-size: 1.4rem; }
.msg-body h2 { font-size: 1.2rem; }
.msg-body h3 { font-size: 1.05rem; }
.msg-body p { margin: .5rem 0; }
.msg-body ul, .msg-body ol { margin: .5rem 0 .5rem 1.4rem; }
.msg-body li { margin-bottom: .3rem; }
.msg-body strong { color: var(--ink); font-weight: 700; }
.msg-body a { color: var(--teal); }
.msg-body code {
  font-family: var(--mono);
  font-size: .85em;
  background: var(--teal-tint);
  color: var(--teal-dark);
  padding: .12rem .42rem;
  border-radius: 5px;
}
.msg-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  overflow-x: auto;
  margin: .6rem 0;
}
.msg-body pre code { background: none; color: inherit; padding: 0; }
.msg-body table { border-collapse: collapse; width: 100%; margin: .85rem 0; }
.msg-body th {
  text-align: left;
  text-transform: uppercase;
  font-size: .72rem;
  letter-spacing: .06em;
  color: var(--muted);
  padding: .55rem .6rem;
  border-bottom: 2px solid var(--border);
}
.msg-body td { padding: .6rem; border-bottom: 1px solid #eef1f3; font-size: .95rem; }
.msg-body td:first-child { color: var(--teal-dark); font-weight: 600; }
.msg-body blockquote {
  border-left: 3px solid var(--teal-tint-line);
  padding-left: 1rem;
  color: var(--muted);
  margin: .5rem 0;
}
.loading-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--teal);
  animation: dgl-pulse 1.4s ease-in-out infinite;
}
@keyframes dgl-pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

.composer {
  display: flex;
  gap: .75rem;
  align-items: flex-end;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: .75rem;
  box-shadow: var(--shadow);
}
#messageInput {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink);
  padding: .55rem .6rem;
  min-height: 46px;
  max-height: 200px;
  line-height: 1.5;
}

/* ============================================================================
   Sequence Search (Genomic index query)
   ========================================================================== */
.results-meta {
  font-family: var(--mono);
  font-size: .9rem;
  color: var(--muted);
  margin: 1.25rem 0 .8rem;
}
.results-meta strong { color: var(--ink); font-weight: 700; }
.results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .8rem;
}
.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.35rem 1.5rem;
}
.result-eyebrow {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .7rem;
  font-weight: 700;
  color: var(--muted);
}
.result-gene {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  margin: .15rem 0 .55rem;
}
.result-links { display: flex; gap: 1.1rem; margin-bottom: .35rem; }

/* ============================================================================
   Query Builder (Knowledge graph semantic search)
   ========================================================================== */
.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: .5rem;
}
.role-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.35rem 1rem 1.1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.role-card:hover { border-color: var(--teal-tint-line); }
.role-card:has(input:checked) { border-color: var(--teal); background: var(--teal-tint); }
.role-card img { max-width: 100%; height: auto; margin-bottom: .9rem; }
.role-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font-weight: 600;
  color: var(--ink);
  font-size: .98rem;
}
input[type="radio"] { accent-color: var(--teal); width: 16px; height: 16px; }

.results-panel { margin-top: 1.5rem; }
.def-row {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 1rem;
  align-items: baseline;
  padding: .4rem 0;
}
.def-label {
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
}
.def-value { color: var(--ink); font-size: .96rem; word-break: break-word; }
.def-value.mono { font-family: var(--mono); }
.def-divider { border: none; border-top: 1px solid var(--border); margin: .9rem 0; }
.match-count { margin-bottom: .25rem; }

@media (max-width: 720px) {
  .site-header { padding: 0 1rem; }
  .site-nav { gap: 1rem; }
  .results-grid, .role-grid { grid-template-columns: 1fr; }
  .def-row { grid-template-columns: 1fr; gap: .2rem; }
  .card { padding: 1.5rem 1.25rem; }
}
