/* ==========================================================================
   IGS-G-BOT Spec Review — Midnight Observatory
   Matches the audit UI design system. Responsive: sidebar drawer on mobile.
   ========================================================================== */

/* ── Design tokens (mirrored from audit/ui/styles.css) ── */
:root {
  --bg:             #070812;
  --bg-base:        #070812;
  --bg-alt:         #0b0d1a;
  --bg-card:        #12142a;
  --bg-raised:      #1a1d36;
  --bg-sunken:      #05060f;
  --bg-glass:       rgba(18,20,42,0.55);

  --border:         rgba(255,255,255,0.07);
  --border-subtle:  rgba(255,255,255,0.04);
  --border-strong:  rgba(255,255,255,0.14);
  --border-accent:  rgba(122,181,255,0.35);

  --text:           #f0f1f7;
  --text-dim:       #a6aac0;
  --text-faint:     #6b6f8a;
  --text-ghost:     #474a63;

  --accent:         #8fb6ff;
  --accent-bright:  #a9c9ff;
  --accent-deep:    #4f7cc3;
  --accent-glow:    rgba(143,182,255,0.18);

  --green:          #5ee4a4;
  --green-glow:     rgba(94,228,164,0.18);
  --yellow:         #fbcc5e;
  --yellow-glow:    rgba(251,204,94,0.18);
  --red:            #fb7a94;
  --red-glow:       rgba(251,122,148,0.18);
  --purple:         #c7a7ff;
  --purple-glow:    rgba(199,167,255,0.18);
  --orange:         #ffb06b;
  --orange-glow:    rgba(255,176,107,0.18);

  --font-serif:     "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-sans:      "Instrument Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:      "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --sidebar-w:      264px;
  --topbar-h:       56px;
  --actionbar-h:    60px;
  --radius:         8px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a      { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Atmosphere ── */
.atmosphere {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
}
.atmosphere-gradient {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 70% 40% at 30% 0%,
    rgba(143,182,255,0.06) 0%, transparent 60%);
}
.atmosphere-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.013) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.013) 1px, transparent 1px);
  background-size: 44px 44px;
}

/* ── Mobile sidebar overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(7,8,18,0.7);
  backdrop-filter: blur(2px);
  z-index: 49;
  opacity: 0;
  transition: opacity 0.25s;
}
.sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.back-link {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-faint);
  letter-spacing: 0.05em;
  text-decoration: none;
  transition: color 0.15s;
}
.back-link:hover { color: var(--text-dim); text-decoration: none; }

.sidebar-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--text-dim);
  font-style: italic;
}

.sidebar-search {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.7rem;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.15s;
}
.sidebar-search input::placeholder { color: var(--text-ghost); }
.sidebar-search input:focus { border-color: var(--border-accent); }

.spec-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0;
}
.spec-list::-webkit-scrollbar { width: 4px; }
.spec-list::-webkit-scrollbar-track { background: transparent; }
.spec-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

.spec-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  text-align: left;
  border-radius: 0;
  transition: background 0.12s;
  position: relative;
}
.spec-item:hover  { background: rgba(255,255,255,0.03); }
.spec-item.active {
  background: rgba(143,182,255,0.08);
  border-right: 2px solid var(--accent);
}
.spec-item.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--accent);
}

.spec-num {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-ghost);
  min-width: 28px;
  flex-shrink: 0;
}
.spec-item.active .spec-num { color: var(--accent); }

.spec-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.spec-item-title {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.spec-item.active .spec-item-title { color: var(--text); }

.spec-item-sub {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.03em;
}

.spec-item-badges {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.review-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.review-dot.review-approved  { background: var(--green); }
.review-dot.review-declined  { background: var(--red); }
.review-dot.review-needs-clarification { background: var(--orange); }

.comment-badge {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  background: rgba(255,255,255,0.08);
  color: var(--text-faint);
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}

/* Status colour helpers */
.status-yellow { color: var(--yellow); }
.status-green  { color: var(--green); }
.status-red    { color: var(--red); }
.status-blue   { color: var(--accent); }
.status-orange { color: var(--orange); }
.status-dim    { color: var(--text-faint); }

/* State messages */
.loading-specs, .load-error {
  padding: 1.5rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
  line-height: 1.6;
}
.load-error { color: var(--red); }

/* ── Main layout ── */
.layout {
  position: fixed;
  left: var(--sidebar-w);
  right: 0; top: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

/* ── Top bar ── */
.top-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
  flex-shrink: 0;
  overflow: hidden;
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 0.35rem;
  border-radius: var(--radius);
  flex-shrink: 0;
  transition: background 0.15s;
}
.hamburger:hover { background: rgba(255,255,255,0.05); }
.hamburger span {
  display: block;
  width: 18px; height: 1.5px;
  background: var(--text-dim);
  border-radius: 1px;
}

.spec-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.spec-id-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-faint);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.spec-heading {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

.status-badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.status-badge.status-yellow { border-color: rgba(251,204,94,0.3); color: var(--yellow); background: var(--yellow-glow); }
.status-badge.status-green  { border-color: rgba(94,228,164,0.3); color: var(--green);  background: var(--green-glow); }
.status-badge.status-red    { border-color: rgba(251,122,148,0.3); color: var(--red);   background: var(--red-glow); }
.status-badge.status-orange { border-color: rgba(255,176,107,0.3); color: var(--orange);background: var(--orange-glow); }
.status-badge.status-blue   { border-color: rgba(143,182,255,0.3); color: var(--accent);background: var(--accent-glow); }

.created-date {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-ghost);
  flex-shrink: 0;
  white-space: nowrap;
}

.artifact-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.artifact-tab {
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  color: var(--text-faint);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}
.artifact-tab:hover { color: var(--text-dim); background: rgba(255,255,255,0.04); }
.artifact-tab.active {
  color: var(--accent-bright);
  background: var(--accent-glow);
  border-color: rgba(143,182,255,0.25);
}

/* ── Content area ── */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  background: var(--bg-base);
}
.content-area::-webkit-scrollbar { width: 5px; }
.content-area::-webkit-scrollbar-track { background: transparent; }
.content-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

.content-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 0.75rem;
  color: var(--text-ghost);
}
.empty-icon { font-size: 2rem; opacity: 0.3; }
.content-empty p { font-size: 0.85rem; }

.content-loading, .content-error {
  padding: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-faint);
  line-height: 1.6;
}
.content-error { color: var(--red); }

/* ── Markdown body ── */
.md-body {
  max-width: 760px;
  margin: 0 auto;
  line-height: 1.75;
}

.md-body h1 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.md-body h2 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text);
  margin-top: 2.25rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-subtle);
}
.md-body h3 {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 1.75rem;
  margin-bottom: 0.6rem;
}
.md-body h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-top: 1.25rem;
  margin-bottom: 0.4rem;
}

.md-body p { color: var(--text-dim); margin-bottom: 1rem; }
.md-body strong { color: var(--text); font-weight: 600; }
.md-body em { color: var(--text-dim); font-style: italic; }

.md-body ul, .md-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text-dim);
}
.md-body li { margin-bottom: 0.3rem; }
.md-body li > p { margin-bottom: 0.3rem; }

/* Checkboxes (for requirements checklist) */
.md-body input[type="checkbox"] {
  accent-color: var(--green);
  margin-right: 0.4rem;
}
.md-body li:has(input[type="checkbox"]:checked) { color: var(--text-faint); }
.md-body li:has(input[type="checkbox"]:checked) strong { color: var(--text-faint); }

.md-body code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent-bright);
}
.md-body pre {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}
.md-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.md-body blockquote {
  border-left: 3px solid var(--accent-deep);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  background: rgba(143,182,255,0.05);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-faint);
  font-style: italic;
}

.md-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.md-body a { color: var(--accent); }
.md-body a:hover { color: var(--accent-bright); }

.md-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}
.md-body th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-strong);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.md-body td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-dim);
  vertical-align: top;
}
.md-body tr:last-child td { border-bottom: none; }

/* Front-matter key/value pairs rendered as <strong>Key</strong>: value */
.md-body > p:first-child strong { color: var(--text-faint); }

/* ── Action bar ── */
.action-bar {
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  flex-shrink: 0;
  height: var(--actionbar-h);
}
.action-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 1.25rem;
  height: 100%;
}

.action-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.action-btn {
  font-size: 0.78rem;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-dim);
  transition: all 0.15s;
  white-space: nowrap;
}
.action-btn:hover { background: rgba(255,255,255,0.07); border-color: var(--border-strong); color: var(--text); }

.approve-btn.active  { background: var(--green-glow);  border-color: rgba(94,228,164,0.35);  color: var(--green); }
.decline-btn.active  { background: var(--red-glow);    border-color: rgba(251,122,148,0.35); color: var(--red); }
.comment-btn         { border-style: dashed; }
.comment-btn:hover   { border-style: solid; }

.action-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.comment-count, .review-status-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-faint);
  white-space: nowrap;
}
.review-status-label:not(:empty) { color: var(--text-dim); }

/* ── Comment dialog ── */
.dialog-overlay {
  position: fixed; inset: 0;
  background: rgba(7,8,18,0.75);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
}
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.dialog-header h3 {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 400;
  font-style: italic;
}
.dialog-close {
  font-size: 1.25rem;
  color: var(--text-faint);
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}
.dialog-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.dialog-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.dialog-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.comment-types {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.type-btn {
  font-size: 0.78rem;
  padding: 0.3rem 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-dim);
  transition: all 0.15s;
}
.type-btn:hover  { border-color: var(--border-strong); color: var(--text); background: rgba(255,255,255,0.06); }
.type-btn.active { border-color: var(--border-accent); color: var(--accent-bright); background: var(--accent-glow); }

.dialog-body textarea {
  width: 100%;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  min-height: 100px;
}
.dialog-body textarea:focus { border-color: var(--border-accent); }
.dialog-body textarea::placeholder { color: var(--text-ghost); }

.dialog-hint {
  font-size: 0.75rem;
  color: var(--text-faint);
  line-height: 1.7;
  padding: 0.6rem 0.85rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}
.dialog-hint code {
  font-family: var(--font-mono);
  font-size: 0.75em;
  color: var(--accent);
  background: rgba(143,182,255,0.1);
  padding: 1px 4px;
  border-radius: 3px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--border);
}
.btn-secondary {
  font-size: 0.82rem;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-faint);
  transition: all 0.15s;
}
.btn-secondary:hover { border-color: var(--border-strong); color: var(--text-dim); }
.btn-primary {
  font-size: 0.82rem;
  padding: 0.45rem 1.1rem;
  border-radius: 6px;
  border: 1px solid rgba(143,182,255,0.35);
  background: var(--accent-glow);
  color: var(--accent-bright);
  transition: all 0.15s;
}
.btn-primary:hover { background: rgba(143,182,255,0.25); }

/* ── Responsive — mobile ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,0.5);
  }

  .layout { left: 0; }

  .hamburger { display: flex; }

  .spec-heading { font-size: 0.9rem; }
  .created-date { display: none; }

  .artifact-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .artifact-tabs::-webkit-scrollbar { display: none; }

  .content-area { padding: 1.25rem; }

  .action-bar-inner { gap: 0.5rem; }
  .action-btn { padding: 0.35rem 0.65rem; font-size: 0.74rem; }

  .md-body h1 { font-size: 1.4rem; }
  .md-body h2 { font-size: 1.1rem; }
}

@media (max-width: 420px) {
  .spec-meta { gap: 0.4rem; }
  .spec-id-badge { display: none; }
  .status-badge { display: none; }
  .comment-count, .review-status-label { display: none; }
}
