/* ============================================================
   discussion-layout.css — Cardinal Energy Discussions
   STRUCTURAL LAYOUT ONLY — scoped to #tab-discussion.
   Nothing here applies to dynamically-created message elements.
   Message/component styles live in discussion-components.css.
   ============================================================ */

/* ── Tab container ───────────────────────────────────────────── */
#tab-discussion {
  padding: 0;
  display: flex;
  height: calc(100vh - 180px);
  min-height: 540px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 0.75rem;
}

/* ── Topic rail ──────────────────────────────────────────────── */
#tab-discussion .topic-rail {
  width: 176px;
  flex-shrink: 0;
  border-right: 1px solid var(--border, #e2e8f0);
  background: #ffffff;
  padding: 8px;
  overflow-y: auto;
}
#tab-discussion .rail-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  padding: 6px 8px;
  font-weight: 600;
}
#tab-discussion .topic-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 12px;
  color: #0f172a;
  cursor: pointer;
  font-family: inherit;
  transition: background 120ms;
}
#tab-discussion .topic-btn:hover { background: rgba(224,242,254,0.6); }
#tab-discussion .topic-btn.active {
  background: rgba(14,165,233,0.1);
  color: #0ea5e9;
  font-weight: 500;
}
#tab-discussion .topic-btn .left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
#tab-discussion .topic-dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
  display: inline-block;
}
#tab-discussion .badge {
  display: inline-flex; align-items: center; justify-content: center;
  height: 16px; min-width: 16px; padding: 0 4px;
  border-radius: 999px;
  background: #0ea5e9; color: white;
  font-size: 10px; font-weight: 600;
}
#tab-discussion .add-topic-btn {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 6px 8px; border-radius: 6px;
  border: none; background: transparent; cursor: pointer;
  font-size: 12px; color: #64748b;
  text-align: left; font-family: inherit;
  transition: background 120ms; margin-top: 4px;
}
#tab-discussion .add-topic-btn:hover {
  background: rgba(224,242,254,0.6); color: #0f172a;
}

/* ── Main panel ──────────────────────────────────────────────── */
#tab-discussion .main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
#tab-discussion .main-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  background: #ffffff;
}
#tab-discussion .main-header .topic-name { font-size: 14px; font-weight: 600; color: #0f172a; }
#tab-discussion .main-header .count { font-size: 12px; color: #64748b; margin-left: auto; }

/* ── Phase context card ──────────────────────────────────────── */
#tab-discussion .phase-card {
  margin: 0;
  border: none;
  border-left: 3px solid #0ea5e9;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: #ffffff;
  padding: 10px 16px;
  flex-shrink: 0;
}
#tab-discussion .phase-row {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 12px;
}
#tab-discussion .phase-row .strong { font-weight: 600; color: #0f172a; }
#tab-discussion .phase-row .muted {
  color: #64748b; display: inline-flex; align-items: center; gap: 4px;
}
#tab-discussion .phase-row svg { width: 12px; height: 12px; }
#tab-discussion .gates {
  margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
#tab-discussion .gates-label {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 600; color: #64748b;
}
#tab-discussion .gate-chip {
  font-size: 11px; padding: 2px 8px; border-radius: 4px;
  background: rgba(245,158,11,0.1); color: #f59e0b;
  border: 1px solid rgba(245,158,11,0.25);
}

/* ── Messages area ───────────────────────────────────────────── */
#tab-discussion .messages {
  flex: 1; overflow-y: auto;
  padding: 12px 16px; background: #ffffff;
}
#tab-discussion .messages::-webkit-scrollbar { width: 8px; }
#tab-discussion .messages::-webkit-scrollbar-thumb {
  background: #e2e8f0; border-radius: 999px;
}

/* ── Composer area ───────────────────────────────────────────── */
#tab-discussion .composer {
  border-top: 1px solid var(--border, #e2e8f0);
  padding: 12px; background: #ffffff;
  flex-shrink: 0; position: relative;
}
#tab-discussion .composer textarea {
  width: 100%; min-height: 56px; max-height: 140px;
  resize: vertical; font-family: inherit; font-size: 14px;
  padding: 8px 10px; border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px; background: #ffffff; color: #0f172a;
  outline: none; display: block; box-sizing: border-box;
}
#tab-discussion .composer textarea:focus {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 2px rgba(14,165,233,0.2);
}
#tab-discussion .composer-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px; font-size: 11px; color: #64748b;
}
#tab-discussion .composer-hints code {
  font-family: ui-monospace, monospace;
  background: #f1f5f9; padding: 1px 4px; border-radius: 3px;
  font-size: 10px; margin: 0 2px;
}
#tab-discussion .send-btn {
  height: 28px; padding: 0 12px; border: 0;
  border-radius: 6px; background: #0ea5e9;
  color: white; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; font-family: inherit; transition: background 0.15s;
}
#tab-discussion .send-btn:hover { background: #38bdf8; }
#tab-discussion .send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#tab-discussion .send-btn svg { width: 12px; height: 12px; }

/* ── Inline replies ──────────────────────────────────────────── */
#tab-discussion .replies-wrap {
  margin-left: 38px; margin-top: 2px;
  padding-left: 10px; border-left: 2px solid var(--border, #e2e8f0);
}

/* ── Global hub panel ────────────────────────────────────────── */
.disc-hub-overlay { position: fixed; inset: 0; z-index: 800; pointer-events: none; }
.disc-hub-overlay.open { pointer-events: auto; }
.disc-hub-panel {
  position: fixed; top: 0; bottom: 0; left: 256px;
  width: 780px; max-width: calc(100vw - 256px);
  background: #ffffff; border-right: 1px solid #e2e8f0;
  box-shadow: 4px 0 24px rgba(0,0,0,0.12);
  display: flex; z-index: 801;
  transform: translateX(calc(-100% - 300px)); transition: transform 0.25s ease;
}
.disc-hub-panel.open { transform: translateX(0); }
.disc-filter-rail {
  width: 240px; min-width: 240px; flex-shrink: 0;
  border-right: 1px solid #e2e8f0;
  background: #f8fafc; display: flex; flex-direction: column;
}
.disc-filter-head { padding: 14px 16px; border-bottom: 1px solid #e2e8f0; }
.disc-filter-head h2 { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; margin: 0; color: #0f172a; }
.disc-filter-head p { font-size: 11px; color: #64748b; margin-top: 2px; }
.disc-filter-list { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.disc-filter-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border-radius: 6px; border: none; background: transparent;
  cursor: pointer; font-size: 13px; color: #0f172a;
  text-align: left; font-family: inherit; transition: background 120ms;
}
.disc-filter-btn:hover { background: #f1f5f9; }
.disc-filter-btn.active { background: rgba(14,165,233,0.1); color: #0ea5e9; font-weight: 600; }
.disc-filter-btn .lbl { flex: 1; }
.disc-hub-badge {
  min-width: 18px; height: 18px; border-radius: 9px; background: #0ea5e9; color: white;
  font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.disc-hub-badge.warn { background: #f59e0b; }
.disc-hub-search { padding: 8px 8px 4px; }
.disc-hub-search input {
  width: 100%; height: 28px; padding: 0 10px; font-size: 12px;
  border: 1px solid #e2e8f0; border-radius: 6px;
  background: #ffffff; color: #0f172a; outline: none; box-sizing: border-box;
}
.disc-hub-proj-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.disc-hub-proj-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  border-radius: 6px; cursor: pointer; font-size: 12px; color: #0f172a; transition: background 120ms;
}
.disc-hub-proj-row:hover { background: #f1f5f9; }
.disc-hub-proj-row.selected { background: rgba(14,165,233,0.1); color: #0ea5e9; font-weight: 600; }
.disc-hub-star { background: none; border: none; cursor: pointer; color: #94a3b8; padding: 0; font-size: 14px; flex-shrink: 0; }
.disc-hub-star.on { color: #f59e0b; }
.disc-hub-right { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.disc-hub-close {
  position: absolute; top: 12px; right: 12px; background: none; border: none;
  cursor: pointer; color: #94a3b8; font-size: 20px; padding: 4px 8px; border-radius: 6px; z-index: 802;
}
.disc-hub-close:hover { background: #f8fafc; }
.disc-feed-card {
  border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.disc-feed-card:hover { border-color: rgba(14,165,233,0.3); background: rgba(14,165,233,0.02); }
.disc-feed-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.disc-feed-proj { font-size: 13px; font-weight: 700; color: #0f172a; }
.disc-feed-count { font-size: 11px; color: #94a3b8; }
.disc-feed-time  { font-size: 10px; color: #94a3b8; }
.disc-source-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; padding: 1px 6px; border-radius: 4px;
  background: #f8fafc; color: #94a3b8; white-space: nowrap;
}

/* ── Mini thread viewer (structural) ─────────────────────────── */
.disc-thread-viewer {
  position: absolute; inset: 0; background: #ffffff;
  z-index: 10; display: flex; flex-direction: column;
}
.disc-thread-hdr {
  padding: 11px 14px; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.disc-thread-back {
  background: none; border: none; cursor: pointer;
  color: #94a3b8; padding: 4px; border-radius: 6px; display: flex; align-items: center;
}
.disc-thread-back:hover { background: #f8fafc; }
.disc-thread-ttl { font-size: 13px; font-weight: 600; flex: 1; color: #0f172a; }
.disc-thread-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 4px; font-size: 10px; font-weight: 500;
  background: #f8fafc; color: #94a3b8;
}
.disc-thread-parent-msg {
  padding: 10px 14px; background: #f8fafc;
  border-bottom: 1px solid #e2e8f0; flex-shrink: 0;
}
.disc-thread-stream {
  flex: 1; overflow-y: auto; padding: 10px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.disc-thread-stream::-webkit-scrollbar { width: 4px; }
.disc-thread-stream::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }
.disc-thread-composer {
  border-top: 1px solid #e2e8f0; padding: 8px 12px; flex-shrink: 0;
}
.disc-thread-ta {
  width: 100%; min-height: 40px; max-height: 100px;
  resize: none; font-family: inherit; font-size: 13px;
  padding: 7px 10px; border: 1px solid #e2e8f0;
  border-radius: 7px; background: #ffffff; color: #0f172a;
  outline: none; box-sizing: border-box; display: block;
}
.disc-thread-ta:focus { border-color: #0ea5e9; }
.disc-thread-foot {
  display: flex; justify-content: space-between; align-items: center; margin-top: 6px;
}
.disc-thread-hint { font-size: 10px; color: #94a3b8; }
.disc-thread-send {
  height: 26px; padding: 0 10px; border: 0; border-radius: 6px;
  background: #0ea5e9; color: white; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  font-family: inherit; transition: background 0.15s;
}
.disc-thread-send:hover { background: #38bdf8; }
.disc-thread-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Backlink cards (task panel) ─────────────────────────────── */
.disc-backlink-card {
  border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 9px 12px; margin-bottom: 6px; cursor: pointer;
  background: #ffffff; transition: background 120ms, border-color 120ms;
}
.disc-backlink-card:hover { background: rgba(14,165,233,0.04); border-color: rgba(14,165,233,0.3); }
.disc-backlink-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: #94a3b8; margin-bottom: 5px; flex-wrap: wrap;
}
.disc-backlink-preview {
  font-size: 12px; color: #0f172a;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.disc-backlink-replies {
  font-size: 10px; color: #94a3b8; margin-top: 4px;
  display: flex; align-items: center; gap: 4px;
}

/* ── Critical: ensure hidden attribute works despite display:flex ── */
#tab-discussion[hidden] {
  display: none !important;
}
