/* ═══════════════════════════════════════════════════
   desktop.css — Multi-pane layout for Nota
   Activates at ≥ 1024px only.

   KEY RULES:
   ─ body.has-panes  → stage flex + content hidden
   ─ Desktop.enable() removes inline style="display:none"
     from #desktop-stage so the empty hint shows
   ─ 1 pane → 100%,  2 → 50/50,  3 → 33/33/34
   ─ No empty gaps ever
   ═══════════════════════════════════════════════════ */


/* ─────────────────────────────────────────────────
   SIDEBAR — collapsible to icon-only on desktop
   body.sb-collapsed toggled by JS on sb-close-btn
   ─────────────────────────────────────────────────*/
@media (min-width: 1024px) {

  #sidebar {
    transition: width .22s var(--ease), min-width .22s var(--ease);
  }

  body.sb-collapsed #sidebar {
    width: 56px !important;
    min-width: 56px !important;
    overflow: visible;  /* allow tooltips to escape */
  }

  /* Hide text content when collapsed */
  body.sb-collapsed .sb-appname,
  body.sb-collapsed .sb-dot,
  body.sb-collapsed .sb-section-lbl,
  body.sb-collapsed .sb-section-row,
  body.sb-collapsed .sb-viewall-btn,
  body.sb-collapsed #sb-ws-list,
  body.sb-collapsed .sb-divider,
  body.sb-collapsed .sb-ws-acts,
  body.sb-collapsed #sb-nav .sb-nav-btn span,
  body.sb-collapsed #sb-nav .sb-nav-btn em,
  body.sb-collapsed .sb-footer .sb-nav-btn span {
    display: none !important;
    visibility: hidden;
  }

  /* Logo: just show icon + toggle btn */
  body.sb-collapsed .sb-logo {
    justify-content: center;
    padding: 10px 0;
    gap: 4px;
  }
  body.sb-collapsed .sb-logo-img { width: 26px; height: 26px; }
  body.sb-collapsed .sb-close-btn { display: flex !important; }

  /* Nav buttons: icon-only centred */
  body.sb-collapsed .sb-nav-btn {
    justify-content: center;
    padding: 10px 0;
    width: calc(100% - 8px);
    margin: 1px 4px;
    position: relative;
  }
  body.sb-collapsed .sb-nav-btn i {
    width: auto;
    font-size: 18px;
    margin: 0;
  }

  /* Hover tooltip — shows page name to the right */
  body.sb-collapsed .sb-nav-btn:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--ink);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: var(--r-sm);
    white-space: nowrap;
    z-index: 9999;
    box-shadow: var(--sh);
    pointer-events: none;
  }

  /* Badges still visible when collapsed */
  body.sb-collapsed .sb-nav-btn em {
    display: inline-flex !important;
    visibility: visible;
    position: absolute;
    top: 4px; right: 4px;
    min-width: 14px; height: 14px;
    font-size: 9px;
    padding: 0 3px;
  }
}


/* ─────────────────────────────────────────────────
   DESKTOP STAGE
   JS removes inline style="display:none" on enable().
   Then body.has-panes makes it flex and hides content.
   ─────────────────────────────────────────────────*/
#desktop-stage {
  flex: 1;
  overflow: hidden;
  background: var(--bg2);
  min-height: 0;
  /* display & flex-direction set by JS - start hidden */
  flex-direction: row;
}

/* JS adds has-panes when panes open - hides normal content */
body.has-panes #content { display: none !important; }


/* ─────────────────────────────────────────────────
   EMPTY HINT — when stage is open but no panes yet
   ─────────────────────────────────────────────────*/
.dt-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px 40px;
  color: var(--ink4);
}
.dt-empty-ico {
  width: 72px;
  height: 72px;
  border-radius: var(--r-lg);
  background: var(--bg3);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--ink4);
}
.dt-empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink3);
}
.dt-empty-sub {
  font-size: 14px;
  color: var(--ink4);
  text-align: center;
  max-width: 320px;
  line-height: 1.6;
}
.dt-empty-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}


/* ─────────────────────────────────────────────────
   INDIVIDUAL PANE
   ─────────────────────────────────────────────────*/
.dt-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  border-right: 1.5px solid var(--border);
  position: relative;
  animation: dt-pane-in .18s ease both;
}
.dt-pane:last-child { border-right: none; }

@keyframes dt-pane-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dt-pane.pane-active {
  border-top: 2.5px solid var(--accent-violet);
}
.dt-pane:not(.pane-active) {
  border-top: 2.5px solid transparent;
  opacity: .72;
  cursor: pointer;
}
.dt-pane:not(.pane-active):hover { opacity: 1; }


/* ─────────────────────────────────────────────────
   PANE CONTROL BAR
   "WorkspaceName > PageLabel    [anon][clear][↔][×]"
   ─────────────────────────────────────────────────*/
.pane-ctrlbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 8px;
  border-bottom: 1.5px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  min-height: 36px;
  user-select: none;
}
.dt-pane.pane-active .pane-ctrlbar { background: var(--bg); }

.pane-ctrlbar-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  flex: 1;
}
.pane-ws-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}
.pane-bc-sep { font-size: 13px; color: var(--ink4); flex-shrink: 0; }

.pane-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dt-pane.pane-active .pane-label { color: var(--ink); }

.pane-ctrlbar-right {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Anon tag badge */
.pane-anon-tag {
  display: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-radius: 99px;
  padding: 2px 7px;
  white-space: nowrap;
}

/* Window buttons */
.pane-win-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--ink4);
  flex-shrink: 0;
  cursor: pointer;
  transition: background var(--t), color var(--t);
  border: none;
  background: transparent;
}
.pane-win-btn:hover                  { background: var(--bg3); color: var(--ink); }
.pane-win-btn.pane-close:hover       { background: var(--error-bg); color: var(--error); }
.pane-win-btn.pane-clear-chat:hover  { background: var(--error-bg); color: var(--error); }
.pane-win-btn.pane-anon.pill-active  { color: var(--error); background: var(--error-bg); }


/* ─────────────────────────────────────────────────
   PANE BODY
   ─────────────────────────────────────────────────*/
.pane-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Real .page hosted inside pane */
.pane-body > .page {
  display: flex !important;
  flex: 1 !important;
  flex-direction: column;
  overflow: hidden;
  animation: none !important;
  min-height: 0;
}

.pane-body .page-scroll  { flex: 1; overflow-y: auto; min-height: 0; }
.pane-body .reader-shell { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.pane-body .chat-shell   { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }

/* Slim scrollbars */
.pane-body *::-webkit-scrollbar       { width: 4px; height: 4px; }
.pane-body *::-webkit-scrollbar-track  { background: transparent; }
.pane-body *::-webkit-scrollbar-thumb  { background: var(--border2); border-radius: 99px; }


/* ─────────────────────────────────────────────────
   PANE WIDTHS — fills 100% with no gaps
   ─────────────────────────────────────────────────*/
#desktop-stage[data-panes="1"] .dt-pane { flex: 1 1 100%;     max-width: 100%; }
#desktop-stage[data-panes="2"] .dt-pane { flex: 1 1 50%;      max-width: 50%; }
#desktop-stage[data-panes="3"] .dt-pane { flex: 1 1 33.333%;  max-width: 33.333%; }
#desktop-stage[data-panes="3"] .dt-pane:last-child { flex: 1 1 33.334%; max-width: 33.334%; }


/* ─────────────────────────────────────────────────
   PILL BUTTONS injected into topbar
   ─────────────────────────────────────────────────*/
#desk-pills {
  display: none;
  align-items: center;
  gap: 4px;
  margin-right: 6px;
}
@media (min-width: 1024px) { #desk-pills { display: flex; } }

.desk-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink4);
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
  line-height: 1;
}
.desk-pill i                 { font-size: 13px; }
.desk-pill:hover             { border-color: var(--ink3); color: var(--ink2); background: var(--bg2); }
.desk-pill.pill-open         { background: var(--bg3); color: var(--ink2); border-color: var(--border2); }
.desk-pill.pill-active       { background: var(--ink); color: #fff; border-color: var(--ink); }
.desk-pill.pill-active:hover { background: var(--ink2); }


/* ─────────────────────────────────────────────────
   MOBILE — disable all desktop features
   ─────────────────────────────────────────────────*/
@media (max-width: 1023px) {
  #desktop-stage          { display: none !important; }
  #desk-pills             { display: none !important; }
  body.has-panes #content { display: flex !important; }

  body.sb-collapsed #sidebar { width: var(--sb-w) !important; min-width: var(--sb-w) !important; }
  body.sb-collapsed .sb-appname,
  body.sb-collapsed .sb-dot,
  body.sb-collapsed #sb-nav .sb-nav-btn span,
  body.sb-collapsed #sb-nav .sb-nav-btn em,
  body.sb-collapsed .sb-section-row,
  body.sb-collapsed .sb-divider,
  body.sb-collapsed #sb-ws-list,
  body.sb-collapsed .sb-footer .sb-nav-btn span { display: revert !important; }
}