/* Pinned chats and folders in the sidebar (chat-folders.js). Shared by Learny
   AI and Learny Code; colors follow currentColor so dark, light, and glass
   themes need only small overrides. */

/* ---------------------------------------------------------------- Sections */
.chat-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 4px 4px;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.55;
}

.chat-section-label:first-child {
  margin-top: 2px;
}

.chat-section-icon {
  width: 11px;
  height: 11px;
  object-fit: contain;
}

/* ---------------------------------------------------------------- Chat rows */
.chat-more-button {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms ease, background 150ms ease;
}

.chat-more-button img {
  width: 14px;
  height: 14px;
  object-fit: contain;
}

.chat-item:hover .chat-more-button,
.chat-item:focus-within .chat-more-button,
.chat-item.active .chat-more-button,
.chat-folder-header:hover .chat-more-button,
.chat-folder-header:focus-within .chat-more-button,
.chat-more-button[aria-expanded="true"] {
  opacity: 0.75;
}

.chat-more-button:hover,
.chat-more-button:focus-visible,
.chat-more-button[aria-expanded="true"] {
  opacity: 1 !important;
  background: color-mix(in srgb, currentColor 10%, transparent);
}

@media (hover: none) {
  .chat-more-button {
    opacity: 0.6;
  }
}

/* Rows with a "more" button gain one more trailing column for it. */
.chat-item:has(> .chat-more-button):not(.renaming) {
  grid-template-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  grid-auto-columns: 26px;
}

.chat-pin-marker {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  vertical-align: -1px;
  object-fit: contain;
  opacity: 0.6;
}

.chat-item[draggable="true"] {
  cursor: grab;
}

.chat-item.is-dragging {
  opacity: 0.45;
}

/* ---------------------------------------------------------------- Folders */
.chat-folder {
  display: grid;
  gap: 2px;
  margin: 2px 0;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.chat-folder-header {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 34px;
  padding: 0 4px 0 2px;
  border-radius: 10px;
}

.chat-folder-header:hover {
  background: color-mix(in srgb, currentColor 6%, transparent);
}

.chat-folder-toggle {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 32px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chat-folder-chevron {
  flex: none;
  width: 7px;
  height: 7px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  opacity: 0.6;
  transform: rotate(45deg) translate(-2px, -1px);
  transition: transform 180ms ease;
}

.chat-folder.is-collapsed .chat-folder-chevron {
  transform: rotate(-45deg) translate(-1px, 0);
}

.chat-folder-icon {
  flex: none;
  width: 15px;
  height: 15px;
  object-fit: contain;
  opacity: 0.85;
}

.chat-folder-name {
  min-width: 0;
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-folder-count {
  flex: none;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 10%, transparent);
  font-size: 0.66rem;
  font-weight: 750;
  text-align: center;
  opacity: 0.8;
}

.chat-folder-body {
  display: grid;
  gap: 2px;
  padding-left: 14px;
  border-left: 1px solid color-mix(in srgb, currentColor 12%, transparent);
  margin-left: 12px;
}

.chat-folder.is-collapsed .chat-folder-body {
  display: none;
}

.chat-folder-empty {
  margin: 2px 0 6px;
  font-size: 0.72rem;
  opacity: 0.5;
}

.chat-folder-rename {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 20px;
}

.chat-folder-rename input {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 1px solid rgba(79, 157, 255, 0.7);
  border-radius: 8px;
  background: color-mix(in srgb, currentColor 6%, transparent);
  color: inherit;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 157, 255, 0.16);
}

/* Drag-and-drop: folders glow as drop targets while a chat is dragged. */
.chat-folders-dragging .chat-folder {
  border-color: color-mix(in srgb, currentColor 14%, transparent);
  border-style: dashed;
}

.chat-folder.is-drop-target,
.chat-folders-unfiled.is-drop-target {
  border-color: rgba(79, 157, 255, 0.85) !important;
  border-style: solid !important;
  background: rgba(79, 157, 255, 0.1);
  box-shadow: 0 0 0 3px rgba(79, 157, 255, 0.14);
}

.chat-folders-unfiled {
  border: 1px solid transparent;
  border-radius: 12px;
  transition: border-color 160ms ease, background 160ms ease;
}

/* ---------------------------------------------------------------- Menu */
.chat-folders-menu {
  position: fixed;
  z-index: 3000;
  display: grid;
  min-width: 210px;
  max-width: 280px;
  max-height: min(420px, calc(100vh - 16px));
  padding: 6px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: #17181d;
  color: #f2f3f7;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top right;
  transition: opacity 140ms ease, transform 160ms ease;
}

.chat-folders-menu.is-open {
  opacity: 1;
  transform: none;
}

.chat-folders-menu-heading {
  padding: 6px 10px 4px;
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.5;
}

.chat-folders-menu-separator {
  height: 1px;
  margin: 5px 6px;
  background: currentColor;
  opacity: 0.12;
}

.chat-folders-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}

.chat-folders-menu-item:hover,
.chat-folders-menu-item:focus-visible {
  outline: none;
  background: color-mix(in srgb, currentColor 9%, transparent);
}

.chat-folders-menu-item:disabled {
  cursor: default;
  opacity: 0.45;
}

.chat-folders-menu-item.is-danger {
  color: #ff8a80;
}

.chat-folders-menu-icon,
.chat-folders-menu-icon-space {
  flex: none;
  width: 15px;
  height: 15px;
  object-fit: contain;
}

.chat-folders-menu-icon {
  filter: brightness(0) invert(1);
  opacity: 0.85;
}

.chat-folders-menu-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-folders-menu-check {
  flex: none;
  color: #4f9dff;
  font-weight: 800;
}

:root[data-theme="light"] .chat-folders-menu {
  border-color: rgba(0, 0, 0, 0.1);
  background: #ffffff;
  color: #14161c;
  box-shadow: 0 18px 48px rgba(20, 40, 70, 0.18);
}

:root[data-theme="light"] .chat-folders-menu-icon {
  filter: brightness(0);
}

:root[data-theme="light"] .chat-folders-menu-item.is-danger {
  color: #d32f2f;
}

@media (prefers-reduced-motion: reduce) {
  .chat-folders-menu,
  .chat-folder-chevron {
    transition: none;
  }
}
