/* ---------- Media sidebar (media-sidebar.js) ----------
   Docked to the right of the canvas (see .app-body in base.css) rather
   than a floating popup, since it's meant to stay open while working the
   canvas underneath. */
.media-sidebar {
  flex: 0 0 300px;
  width: 300px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.media-sidebar.hidden { display: none; }

.media-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 12px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.media-sidebar-header h2 { font-size: 14px; margin: 0; }

.media-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 16px;
}
.media-sidebar-empty {
  padding: 30px 18px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 12.5px;
}

.media-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 16px 6px;
  border: none;
  background: transparent;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  cursor: pointer;
}
.media-section-header:hover { color: var(--ink); }
.media-section-header .media-section-chevron {
  width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2.2;
  transition: transform 0.12s ease;
  flex-shrink: 0;
}
.media-section.collapsed .media-section-chevron { transform: rotate(-90deg); }
.media-section.collapsed .media-section-list { display: none; }

.media-section-list {
  display: flex;
  flex-direction: column;
  padding: 0 8px;
}

/* Images/Tables-only second level (see groupedSectionListHtml in
   media-sidebar.js) — a category name between the section header and its
   items, independently collapsible the same way the section itself is,
   just styled a step smaller/plainer so it still reads as nested under it
   rather than as another top-level section. */
.media-subgroup-title {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 8px 8px 2px;
  border: none;
  background: transparent;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.media-subgroup-title:hover { color: var(--ink); }
.media-subgroup-title .media-subgroup-chevron {
  width: 10px; height: 10px; stroke: currentColor; fill: none; stroke-width: 2.2;
  transition: transform 0.12s ease;
  flex-shrink: 0;
}
.media-subgroup.collapsed .media-subgroup-chevron { transform: rotate(-90deg); }
.media-subgroup.collapsed .media-subgroup-list { display: none; }

.media-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.media-item:hover { background: #f4f6f9; }

.media-item-thumb {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 1px solid var(--node-border);
  overflow: hidden;
  background: #fafbfc;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-item-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item-thumb svg { width: 18px; height: 18px; stroke: var(--accent); fill: none; stroke-width: 1.8; }

/* A table's thumbnail is the actual table markup, shrunk to fit — gives a
   real (if tiny) sense of its layout/colors rather than a generic icon. */
.media-item-table-thumb {
  overflow: hidden;
  position: relative;
}
.media-item-table-thumb table {
  border-collapse: collapse;
  transform: scale(0.32);
  transform-origin: top left;
  position: absolute;
  top: 3px;
  left: 3px;
}
.media-item-table-thumb td {
  border: 1px solid var(--node-border);
  padding: 3px 5px;
  font-size: 11px;
  white-space: nowrap;
  color: var(--ink);
  background: white;
}

.media-item-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.media-item-label {
  font-size: 12.5px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-item-caption {
  font-size: 11px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
