/* SciCoproof app shell — sidebar layout, design tokens, base styles.
   Closely mirrors scico-search-web/css/shell.css so the two products share
   the same visual language; accent colour is shifted from red (#BA5757) to
   the SciCoproof blue (#5576A6). */
:root {
  --blue: #5576A6;
  --blue-strong: #3f5a8a;
  --blue-soft: #edf1f7;
  --btn: #5576A6;
  --btn-strong: #3f5a8a;
  --ins: #d7f0d8;  --ins-text: #154b18;   /* tracked-change insertion */
  --del: #f8d7d7;  --del-text: #7d1f1f;   /* tracked-change deletion  */
  --ink: #262730;
  --muted: #6B7280;
  --line: #E6E6E6;
  --slate: #8497B0;
  --bg-soft: #F8F9FA;
}

*, *::before, *::after { box-sizing: border-box }
html, body { margin: 0 }
body {
  font-family: "Source Sans 3", "Source Sans Pro", -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: #fff;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none }

/* Material Symbols */
.mi {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-size: 1.1em;
  line-height: 1;
  white-space: nowrap;
  -webkit-font-feature-settings: 'liga';
  font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  vertical-align: -.16em;
  display: inline-block;
}
.mi.fill { font-variation-settings: 'FILL' 1 }

/* ── App layout ───────────────────────────────────────────────────────────── */
.app { display: flex; align-items: stretch; min-height: 100vh }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 264px;
  flex: 0 0 264px;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 14px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
body.sb-collapsed .sidebar { display: none }

.sb-expand {
  display: none;
  position: fixed;
  left: 10px;
  top: 12px;
  z-index: 50;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  color: var(--muted);
  align-items: center;
  justify-content: center;
}
body.sb-collapsed .sb-expand { display: inline-flex }
.sb-expand:hover { border-color: var(--btn); color: var(--btn) }

.sb-top { display: flex; align-items: center; justify-content: space-between }

.sb-toggle {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sb-toggle:hover { border-color: var(--btn); color: var(--btn) }

/* Sidebar logo */
.sb-logo {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -.01em;
  color: var(--ink);
}
.sb-logo .proof { color: var(--blue) }

/* User profile block */
.sb-profile { display: flex; align-items: center; gap: 10px }
.sb-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 40px;
  background: var(--slate);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}
.sb-id { min-width: 0 }
.sb-name { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.sb-email { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }

/* Logout button */
.sb-logout {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .86rem;
  cursor: pointer;
  color: var(--ink);
  width: 100%;
}
.sb-logout:hover { border-color: #BA5757; color: #BA5757 }
.sb-logout .mi { font-size: 1.05rem }

/* Section headers */
.side-h {
  font-size: .76rem;
  font-weight: 700;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
}
.side-h .mi { font-size: 1rem }

/* Rating stars */
.sb-rate .stars { display: flex; gap: 2px; cursor: pointer }
.sb-rate .stars .mi { color: #ccc; font-size: 1.3rem; transition: color .12s }
.sb-rate .stars .mi.lit { color: #E3A52E }
.sb-rate .stars .mi.fill { font-variation-settings: 'FILL' 1 }

/* Star-rating text area + submit */
.sb-feedback { display: flex; flex-direction: column; gap: 8px; margin-top: 8px }
.sb-feedback textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: .86rem;
  font-family: inherit;
  resize: vertical;
  min-height: 68px;
  color: var(--ink);
  background: #fff;
}
.sb-feedback textarea:focus { outline: none; border-color: var(--btn) }
.sb-feedback button {
  border: 0;
  background: var(--btn);
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .86rem;
  font-weight: 600;
  cursor: pointer;
}
.sb-feedback button:hover { background: var(--btn-strong) }

/* New-run button */
.sb-newbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  background: var(--btn);
  color: #fff;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
.sb-newbtn:hover { background: var(--btn-strong) }
.sb-newbtn .mi { font-size: 1.1rem }

/* ── Main content area ────────────────────────────────────────────────────── */
.content { max-width: 820px; margin: 0 auto; padding: 28px 26px 90px; width: 100% }

/* ── Metric cards (mirrors Streamlit st.metric feel) ─────────────────────── */
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px }
.metric-card {
  background: linear-gradient(180deg, #fffdfa 0%, #f6efe4 100%);
  border: 1px solid #e7d3b3;
  border-radius: 14px;
  padding: .9rem 1rem;
}
.metric-card .mc-label {
  font-size: .78rem;
  color: #7a5b3f;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.metric-card .mc-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: #2c2416;
  word-break: break-all;
}

/* ── Progress bars ────────────────────────────────────────────────────────── */
.pbar-wrap { margin: 10px 0 }
.pbar-label { font-size: .82rem; color: var(--muted); margin-bottom: 4px }
.pbar { height: 6px; border-radius: 99px; background: #e7eaee; overflow: hidden }
.pbar .pfill { height: 100%; width: 0; background: var(--blue); border-radius: 99px; transition: width .3s }

/* ── Stage info box ───────────────────────────────────────────────────────── */
.stage-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 14px 0;
}
.stage-box .mi { color: var(--blue); font-size: 1.4rem }
.stage-title { font-weight: 700; font-size: 1rem }
.stage-sub { color: var(--muted); font-size: .88rem; margin-top: 2px }

/* ── Tracked-change preview ───────────────────────────────────────────────── */
.trackchange-preview {
  background: #f7f4ed;
  border: 1px solid #d8c9a8;
  border-radius: 12px;
  padding: .9rem 1rem;
  line-height: 1.65;
  white-space: pre-wrap;
  font-size: .93rem;
  color: #2c2416;
  margin: 10px 0;
}
.trackchange-preview ins {
  background: var(--ins);
  color: var(--ins-text);
  text-decoration: none;
  padding: 0 .08rem;
  border-radius: .2rem;
}
.trackchange-preview del {
  background: var(--del);
  color: var(--del-text);
  text-decoration: line-through;
  padding: 0 .08rem;
  border-radius: .2rem;
}
.ctx-sep { color: #b8a88a; font-size: .85rem; letter-spacing: .1em }

/* ── Upload drop zone ─────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--blue);
  background: var(--blue-soft);
}
.dropzone .dz-icon { font-size: 2.4rem; color: var(--slate); margin-bottom: 10px }
.dropzone .dz-label { font-size: 1rem; font-weight: 600; color: var(--ink) }
.dropzone .dz-sub { font-size: .86rem; color: var(--muted); margin-top: 4px }
.dropzone .dz-file { font-size: .9rem; font-weight: 600; color: var(--blue); margin-top: 10px }
#fileInput { display: none }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: .96rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: .15s;
}
.btn-primary { background: var(--btn); color: #fff }
.btn-primary:hover { background: var(--btn-strong) }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink) }
.btn-ghost:hover { border-color: #aaa }
.btn:disabled { opacity: .45; cursor: not-allowed }
.btn-row { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert { border-radius: 10px; padding: 12px 16px; font-size: .9rem; margin: 10px 0 }
.alert-info { background: var(--blue-soft); border: 1px solid #c0cfe6; color: var(--blue-strong) }
.alert-warn { background: #fff8e1; border: 1px solid #ffe082; color: #7a5c00 }
.alert-err  { background: #fdecea; border: 1px solid #f5c6c0; color: #8b1a1a }
.alert-ok   { background: #e8f5e9; border: 1px solid #a5d6a7; color: #1b5e20 }

/* ── Readiness checklist ──────────────────────────────────────────────────── */
.readiness { border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px; margin: 14px 0 }
.readiness-h { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 0 6px }
.readiness-row { display: flex; align-items: center; gap: 9px; font-size: .9rem; padding: 7px 0; border-top: 1px solid #f0f0f0 }
.readiness-row .mi { font-size: 1.1rem; flex: 0 0 auto }
.ok-ico { color: var(--blue) }
.warn-ico { color: #c27c00 }
.err-ico { color: #BA5757 }

/* ── Download buttons ─────────────────────────────────────────────────────── */
.dl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 }
.dl-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  transition: .15s;
}
.dl-btn:hover { border-color: var(--blue); color: var(--blue) }
.dl-btn.full { grid-column: 1 / -1 }
.dl-btn .mi { font-size: 1.2rem; color: var(--blue) }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .sidebar { position: fixed; z-index: 45; box-shadow: 0 0 0 100vmax rgba(0,0,0,.22) }
  .metric-grid, .dl-row { grid-template-columns: 1fr }
  .dl-btn.full { grid-column: auto }
}
