/* ═══════════════════════════════════════════════
   TechBridge Jupyter Viewer  —  style.css
   ═══════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Variables ── */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface2: #f0f3f9;
  --border: #e2e8f4;
  --accent: #2563eb;
  --accent-h: #1d4ed8;
  --text: #0f172a;
  --muted: #64748b;
  --sidebar-w: 280px;
  --header-h: 54px;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

/* ─── HEADER ─── */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 800;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

#header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

#header .brand img {
  height: 28px;
  border-radius: 6px;
}

#header .brand span {
  color: var(--accent);
}

#header-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

.hbtn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  transition: all 0.15s;
  white-space: nowrap;
}

.hbtn:hover {
  background: var(--surface2);
  color: var(--text);
}

.hbtn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.hbtn.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.hbtn.accent:hover {
  background: var(--accent-h);
}

/* ─── LAYOUT ─── */
#layout {
  display: flex;
  height: 100vh;
  padding-top: var(--header-h);
}

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

#main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  background: var(--bg);
}

/* ─── SIDEBAR TABS ─── */
#sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.stab {
  flex: 1;
  padding: 10px 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.stab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ─── SIDEBAR PANELS ─── */
.sidebar-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.sidebar-panel.active {
  display: flex;
}

/* Files panel */
#search-box {
  margin: 10px 12px 6px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.8rem;
  font-family: var(--font);
  background: var(--surface2);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

#search-box:focus {
  border-color: var(--accent);
}

#search-box::placeholder {
  color: var(--muted);
}

.sidebar-section {
  padding: 8px 12px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

#file-list,
#hosted-list {
  overflow-y: auto;
  padding: 0 8px 8px;
  flex-shrink: 0;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text);
  transition: background 0.12s;
  user-select: none;
}

.file-item:hover {
  background: var(--surface2);
}

.file-item.active {
  background: #dbeafe;
  color: var(--accent);
}

.file-item .ficon {
  font-size: 0.95rem;
  flex-shrink: 0;
}

/* Drop zone */
#drop-zone {
  margin: 10px 12px;
  padding: 18px 12px;
  border-radius: 10px;
  border: 2px dashed var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}

#drop-zone.drag-over {
  border-color: var(--accent);
  background: #eff6ff;
  color: var(--accent);
}

#drop-zone input[type=file] {
  display: none;
}

/* TOC panel */
#toc-list {
  overflow-y: auto;
  padding: 8px;
  flex: 1;
}

.toc-item {
  display: block;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-item:hover {
  background: var(--surface2);
  color: var(--accent);
}

.toc-item.h1 {
  font-weight: 700;
  color: var(--text);
  padding-left: 10px;
}

.toc-item.h2 {
  font-weight: 600;
  padding-left: 20px;
}

.toc-item.h3 {
  padding-left: 30px;
}

#toc-empty {
  padding: 16px;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

/* ─── NOTEBOOK AREA ─── */
#notebook-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 24px 60px;
  position: relative;
}

#notebook-placeholder {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
}

#notebook-placeholder .ph-icon {
  font-size: 3rem;
  margin-bottom: 14px;
}

#notebook-placeholder h2 {
  font-size: 1.2rem;
  color: var(--text);
  margin-bottom: 8px;
}

#notebook-placeholder p {
  font-size: 0.875rem;
}

/* Cell copy button */
.cell-wrapper {
  position: relative;
}

.cell-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  pointer-events: none;
}

.cell-copy-btn.copied {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

.cell-wrapper:hover .cell-copy-btn {
  opacity: 1;
  pointer-events: auto;
}

/* ─── ANNOTATION TOOLBAR ─── */
#ann-toolbar {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  /* above canvas (100) and everything else */
  pointer-events: all;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 14px;
  gap: 6px;
  align-items: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  flex-wrap: wrap;
  max-width: calc(100vw - 40px);
}

#ann-toolbar.visible {
  display: flex;
}

.ann-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--muted);
  transition: all 0.12s;
  flex-shrink: 0;
  position: relative;
}

.ann-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.ann-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.ann-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--text);
  color: #fff;
  font-size: 0.65rem;
  padding: 3px 7px;
  border-radius: 4px;
  font-family: var(--font);
  pointer-events: none;
}

.ann-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 2px;
  flex-shrink: 0;
}

/* Color swatches */
#color-swatches {
  display: flex;
  gap: 5px;
  align-items: center;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
  flex-shrink: 0;
}

.swatch:hover {
  transform: scale(1.2);
}

.swatch.active {
  border-color: var(--text);
  transform: scale(1.1);
}

/* Stroke width */
#stroke-slider {
  width: 70px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

#stroke-preview {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#stroke-dot {
  border-radius: 50%;
  background: #fff;
}

/* Opacity slider label */
.slider-label {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ─── CANVAS OVERLAY ─── */
#ann-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 100;
  pointer-events: none;
  /* invisible — don't intercept clicks */
  cursor: crosshair;
  touch-action: none;
  /* always in DOM, just non-interactive until annotating */
}

#ann-canvas.active {
  pointer-events: all;
  /* annotating — capture all pointer events */
}

#ann-canvas.eraser {
  cursor: cell;
}

#ann-canvas.text-tool {
  cursor: text;
}

/* notebook-container must be the positioning parent for the canvas */
#notebook-container {
  position: relative;
}

/* ─── SCROLL BARS ─── */
::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}

/* ─── NOTEBOOK CONTENT STYLING ─── */
.nb-notebook {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.75;
}

.nb-code-cell pre,
.nb-raw-cell pre {
  background: #1e293b;
  color: #f8fafc;
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 13px;
  font-family: var(--mono);
  margin: 8px 0;
}

.nb-markdown-cell {
  padding: 4px 0;
}

.nb-markdown-cell h1,
.nb-markdown-cell h2,
.nb-markdown-cell h3 {
  margin: 1em 0 0.4em;
}

.nb-markdown-cell h1 {
  font-size: 1.6rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.3em;
}

.nb-markdown-cell h2 {
  font-size: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.2em;
}

.nb-output {
  border-left: 3px solid var(--border);
  padding: 8px 14px;
  margin: 4px 0;
  font-size: 13px;
}

.nb-output-text {
  font-family: var(--mono);
  white-space: pre-wrap;
}

.nb-output-error {
  border-left-color: #ef4444;
  color: #dc2626;
}

/* ─── PRINT STYLES ─── */
@media print {

  #header,
  #sidebar,
  #ann-toolbar {
    display: none !important;
  }

  #main {
    overflow: visible;
  }

  #notebook-container {
    padding: 0;
    max-width: 100%;
  }

  #ann-canvas {
    display: block !important;
  }
}