/* ----------------------------------------------------------------------------
   files-panel.css — Selective context: the Files toggle and its sibling header pills, plus
   the File/Folder View panel (tree rows, checkboxes, token meter).
   Slice 12 of 16 (see css/tokens.css for the full load order).
   ------------------------------------------------------------------------- */
/* Files toggle (left gutter), Clear chat & Get started (right gutter) — fixed pills matching Library / Chat tab size.
   Their .chat-pills wrapper is display:contents on desktop (zero layout
   impact); on mobile it becomes an in-flow toolbar row — see the 979px query. */
.chat-pills {
  display: contents;
}

.chat-files-toggle,
.clear-chat-btn,
.get-started-btn {
  position: fixed;
  top: calc(var(--header-h) + 8px);
  z-index: 31;
  height: 36px;
  padding: 7px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  gap: 8px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  white-space: nowrap;
}

.chat-files-toggle {
  left: 24px;
}

.clear-chat-btn,
.get-started-btn {
  right: 24px;
}

.get-started-btn {
  background: var(--grad);
  background-size: 200% 200%;
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.get-started-btn:hover {
  filter: brightness(1.08);
}

.get-started-btn:active {
  transform: scale(0.97);
}

.chat-files-toggle svg,
.clear-chat-btn svg,
.get-started-btn svg {
  width: 15px;
  height: 15px;
  display: block;
}

.chat-files-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.clear-chat-btn:hover {
  color: var(--danger-text);
  border-color: var(--border-strong);
}

/* Selective context is ON — pill stays highlighted while the mode is active. */
.chat-files-toggle.active {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.files-badge {
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--primary-bg);
  color: var(--primary-text);
  font-size: 11px;
  font-weight: 600;
  line-height: 17px;
  text-align: center;
}

.chat-files {
  display: none;
  position: fixed;
  top: calc(var(--header-h) + 62px);
  left: 24px;
  bottom: 18px;
  width: 280px;
  z-index: 30;
  min-height: 0;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 12px;
}

.chat-page.files-open .chat-files {
  display: flex;
}

.files-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.files-close {
  padding: 2px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
}

.files-close:hover {
  color: var(--text);
  background: var(--surface-2);
}

.files-close svg {
  width: 14px;
  height: 14px;
  display: block;
}

.files-title {
  font-weight: 600;
  font-size: 14px;
}

.files-hint {
  margin: 6px 0 10px;
  line-height: 1.45;
}

.files-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.35;
}

.files-status .btn {
  flex-shrink: 0;
}

.files-tree {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.files-empty {
  padding: 12px 4px;
  line-height: 1.5;
}

.files-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 6px;
  padding-left: calc(6px + var(--depth, 0) * 16px);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  min-width: 0;
}

.files-row:hover {
  background: var(--surface-2);
}

.files-chevron {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  flex-shrink: 0;
}

.files-chevron svg {
  width: 12px;
  height: 12px;
  transition: transform 0.15s ease;
}

.files-chevron.closed svg {
  transform: rotate(-90deg);
}

.files-check {
  width: 15px;
  height: 15px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.files-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--muted);
}

.files-icon svg {
  width: 14px;
  height: 14px;
}

/* files sit one indent level inside their folder's checkbox column */
.files-row.files-file {
  padding-left: calc(6px + 18px + var(--depth, 0) * 16px);
}

.files-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-folder .files-name {
  font-weight: 600;
}

.files-count,
.files-tokens {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.files-meter {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.files-meter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.files-meter-head #files-meter-text {
  font-variant-numeric: tabular-nums;
}

.files-meter-track {
  height: 5px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}

.files-meter-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--accent-2);
  transition: width 0.25s ease;
}

.files-meter-fill.warn {
  background: var(--accent);
}

.files-meter-note {
  margin-top: 7px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--danger-text);
}

/* Narrow screens: panel overlays the conversation edge — still fixed, still
   does not reflow the centred chat column. */
/* Narrow screens: there are no side gutters for fixed pills to live in, so
   the .chat-pills wrapper becomes a real toolbar row above the messages —
   nothing can scroll underneath it — and the Files panel grows into a
   full-width sheet over a dimmed backdrop instead of a floating gutter card. */
@media (max-width: 979px) {
  .chat-pills {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 0;
    flex-shrink: 0;
  }

  .chat-files-toggle,
  .clear-chat-btn,
  .get-started-btn {
    position: static;
    /* flex items honour z-index even when static — without this the pills'
       desktop z-index (31) would paint them over the Files sheet (30) */
    z-index: auto;
    height: 32px;
    padding: 6px 14px;
    font-size: 13px;
  }

  .clear-chat-btn,
  .get-started-btn {
    margin-left: auto;
  }

  .chat-page.files-open::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 29;
    background: color-mix(in srgb, #000 45%, transparent);
  }

  .chat-files {
    top: calc(var(--header-h) + 10px);
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    box-shadow: 0 12px 40px color-mix(in srgb, #000 35%, transparent);
  }
}

