/* ─────────────────────────────────────────────
   layout.css
   Structural layout: topbar → sidebars → editor.
   ───────────────────────────────────────────── */

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--surface-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ══ TOPBAR ══════════════════════════════════ */

#topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  z-index: 100;
}

.topbar-logo {
  font-family: var(--font-code);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--brand);
  white-space: nowrap;
}
.topbar-logo em {
  font-style: normal;
  color: var(--text-muted);
  font-weight: 400;
}

.topbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

.topbar-role-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--r-sm);
}
.topbar-role-badge.candidate   { background: var(--brand-ghost); color: var(--brand); }
.topbar-role-badge.interviewer { background: rgba(61,214,140,0.1); color: var(--ok); }



.topbar-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}
.status-led {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
}
.status-led[data-state="live"]    { background: var(--ok);   box-shadow: 0 0 0 3px var(--ok-ghost); animation: led-pulse 2.4s ease-in-out infinite; }
.status-led[data-state="saving"]  { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-ghost); }
.status-led[data-state="offline"] { background: var(--text-muted); box-shadow: none; }

@keyframes led-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--ok-ghost); }
  50%       { box-shadow: 0 0 0 5px rgba(61,214,140,0.04); }
}

.topbar-spacer { flex: 1; }

/* ── Topbar buttons ── */
.btn {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 13px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--ease);
  white-space: nowrap;
  line-height: 1;
}
.btn:hover       { background: var(--surface-subtle); color: var(--text-primary); border-color: var(--border-strong); }
.btn.btn--brand  { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.btn--brand:hover { background: var(--brand-dim); border-color: var(--brand-dim); }
.btn.btn--ghost  { border-color: transparent; }
.btn.btn--ghost:hover { border-color: var(--border-default); }
.btn.btn--danger { color: var(--danger); border-color: transparent; }
.btn.btn--danger:hover { background: rgba(240,80,110,0.08); border-color: rgba(240,80,110,0.3); }

/* ══ ROOT LAYOUT ════════════════════════════ */

#workspace {
  display: flex;
  height: calc(100vh - var(--topbar-h));
  margin-top: var(--topbar-h);
}

/*
 * When sidebars are disabled, #editor-column is the only flex child
 * and naturally fills the full width. No changes needed here.
 * Re-enable sidebar-left / sidebar-right in index.html to restore
 * the three-column layout.
 */

/* ══ LEFT SIDEBAR ═══════════════════════════ */

#sidebar-left {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface-raised);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-section {
  padding: 11px 11px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}

/* Participants */
.participant-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: var(--r-md);
  cursor: default;
  transition: background var(--ease);
}
.participant-row:hover { background: var(--surface-overlay); }

.participant-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0;
}
.avatar--blue   { background: rgba(79,142,247,0.18); color: #6aa3f9; }
.avatar--green  { background: rgba(61,214,140,0.15); color: #3dd68c; }
.avatar--amber  { background: rgba(245,166,35,0.15); color: #f5a623; }
.avatar--purple { background: rgba(178,100,255,0.15); color: #b264ff; }

.participant-info { flex: 1; min-width: 0; }
.participant-name { font-size: 12px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.participant-role { font-size: 10px; color: var(--text-muted); }
.participant-online { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }

/* File tree */
.file-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-family: var(--font-code);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--ease);
  border-left: 2px solid transparent;
}
.file-row:hover  { background: var(--surface-overlay); color: var(--text-primary); }
.file-row.active { background: var(--surface-subtle); color: var(--text-primary); border-left-color: var(--brand); }

.file-icon { font-size: 10px; opacity: 0.5; }
.file-row.active .file-icon { opacity: 1; color: var(--brand); }

/* Notes */
#notes-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
#notes {
  flex: 1;
  background: transparent;
  border: none;
  resize: none;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.7;
  padding: 9px 11px;
  outline: none;
  min-height: 0;
}
#notes::placeholder { color: var(--text-muted); }

/* ══ EDITOR COLUMN ══════════════════════════ */

#editor-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* File tabs */
#tabs-bar {
  height: 36px;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-end;
  padding: 0 10px 0 6px;
  gap: 1px;
  overflow-x: auto;
  overflow-y: hidden;
}
#tabs-bar::-webkit-scrollbar { height: 0; }

.tab {
  height: 32px;
  padding: 0 13px;
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all var(--ease);
  white-space: nowrap;
  flex-shrink: 0;
}
.tab:hover  { color: var(--text-secondary); background: var(--surface-overlay); }
.tab.active { background: var(--surface-base); color: var(--text-primary); border-color: var(--border-subtle); }

.tab-close {
  width: 14px; height: 14px;
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0;
  transition: all var(--ease);
  line-height: 1;
}
.tab:hover .tab-close,
.tab.active .tab-close { opacity: 1; }
.tab-close:hover { background: var(--surface-subtle); color: var(--danger); }

.tab-new-btn {
  height: 22px; width: 22px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  margin: auto 0 5px 4px;
  transition: all var(--ease);
  flex-shrink: 0;
}
.tab-new-btn:hover { background: var(--surface-overlay); color: var(--text-secondary); border-color: var(--border-default); }

/* CodeMirror overrides */
#editor-mount { flex: 1; overflow: hidden; position: relative; }

.CodeMirror {
  height: 100% !important;
  font-family: var(--font-code) !important;
  font-size: 13.5px !important;
  line-height: 1.72 !important;
  background: var(--surface-base) !important;
  color: var(--syn-plain) !important;
}
.CodeMirror-scroll       { padding-bottom: 80px; }
.CodeMirror-gutters      { background: var(--surface-base) !important; border-right: 1px solid var(--border-subtle) !important; width: 52px; }
.CodeMirror-linenumber   { color: var(--text-muted) !important; font-size: 11px !important; padding: 0 10px 0 6px !important; min-width: 36px; }
.CodeMirror-cursor       { border-left: 2px solid var(--brand) !important; }
.CodeMirror-activeline-background { background: rgba(255,255,255,0.02) !important; }
.CodeMirror-selected,
.CodeMirror-focused .CodeMirror-selected { background: rgba(79,142,247,0.15) !important; }

/* Syntax tokens */
.cm-keyword  { color: var(--syn-keyword) !important; }
.cm-def      { color: var(--syn-fn) !important; }
.cm-type     { color: var(--syn-type) !important; }
.cm-number   { color: var(--syn-number) !important; }
.cm-string, .cm-string-2 { color: var(--syn-string) !important; }
.cm-comment  { color: var(--syn-comment) !important; font-style: italic !important; }
.cm-operator { color: var(--syn-operator) !important; }
.cm-meta     { color: var(--syn-preproc) !important; }
.cm-variable, .cm-variable-2 { color: var(--syn-plain) !important; }
.cm-atom     { color: var(--syn-number) !important; }
.cm-bracket  { color: var(--text-secondary) !important; }
.cm-builtin  { color: var(--syn-type) !important; }

/* Format flash */
.format-flash {
  position: absolute;
  top: 8px; right: 14px;
  font-size: 11px;
  font-family: var(--font-code);
  color: var(--ok);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 10;
}
.format-flash.visible { opacity: 1; }

/* Status bar */
#statusbar {
  height: var(--statusbar-h);
  background: var(--surface-raised);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-code);
  flex-shrink: 0;
}
.sb-tag { display: flex; align-items: center; gap: 4px; }
.sb-tag.--brand    { color: var(--brand); }
.sb-tag.--ok       { color: var(--ok); }
.sb-tag.--warn     { color: var(--warn); }
.sb-spacer         { flex: 1; }
.sb-cursor         { cursor: pointer; }
.sb-cursor:hover   { color: var(--text-secondary); }

/* ══ RIGHT SIDEBAR ══════════════════════════ */

#sidebar-right {
  width: var(--rightbar-w);
  min-width: var(--rightbar-w);
  background: var(--surface-raised);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-tabs {
  display: flex;
  background: var(--surface-overlay);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.panel-tab {
  flex: 1;
  padding: 9px 4px;
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all var(--ease);
  white-space: nowrap;
}
.panel-tab:hover  { color: var(--text-secondary); }
.panel-tab.active { color: var(--brand); border-bottom-color: var(--brand); background: var(--surface-raised); }

.panel-pane {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.panel-pane.active { display: flex; }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
