/* =========================================================
   MY LIBRARY — auto-builder Add From Library tab
   The card is always visible; the inner view shows when the
   user (logged-in) opens it. JS toggles .d-none on .my-library-view.
   ========================================================= */

/* ── Section Labels ── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #6b7280;
  text-transform: uppercase;
  margin: 0 0 10px 2px;
}

/* ── My Library Card (entry) ── */
.my-library-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 2px solid #7c5cfd;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  cursor: pointer;
  transition: box-shadow 0.2s, background 0.2s;
  gap: 14px;
}

.my-library-card:hover {
  background: #faf5ff;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.18);
}

.my-library-card .folder-arrow {
  font-size: 20px;
  color: #7c5cfd;
  line-height: 1;
}

.my-library-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #7c5cfd, #a855f7);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.my-library-card .folder-name {
  font-weight: 600;
  color: #1f2937;
}

.folder-sub {
  font-size: 12px;
  color: #7c5cfd;
  margin-top: 2px;
}

/* ── My Library inner view ── */
.my-library-view {
  margin-bottom: 18px;
}

.my-library-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.my-library-actions,
.my-library-folder-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* ── Upload to My Library Button ── */
.upload-to-my-library {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #f5f3ff;
  border: 1.5px dashed #c4b5fd;
  border-radius: 10px;
  padding: 11px 14px;
  cursor: pointer;
  font-size: 13px;
  color: #7c5cfd;
  font-weight: 500;
  transition: background 0.2s;
  flex: 1 1 auto;
  justify-content: center;
}

.upload-to-my-library:hover {
  background: #ede9fe;
}

/* ── New folder / sub-folder button ── */
.my-library-new-folder {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1.5px solid #ddd6fe;
  border-radius: 10px;
  padding: 11px 14px;
  cursor: pointer;
  font-size: 13px;
  color: #6d28d9;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s;
  flex: 1 1 auto;
  justify-content: center;
}

.my-library-new-folder:hover {
  background: #faf5ff;
  border-color: #a78bfa;
}

.upload-plus {
  font-size: 18px;
  line-height: 1;
}

.my-library-empty {
  font-size: 13px;
  color: #9ca3af;
  padding: 6px 2px 14px;
}

/* Folder cards inside the My Library home reuse .folder-card; just
   give them a subtle accent so they're visually grouped. */
.my-library-folders .folder-card.my-library-folder {
  border-color: #ede9fe;
}
.my-library-folders .folder-card.my-library-folder:hover {
  border-color: #c4b5fd;
}

/* ── Rename buttons ────────────────────────────────────────── */
.ml-rename-btn {
  background: transparent;
  border: 0;
  padding: 4px 6px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s;
  line-height: 1;
}
.ml-rename-btn:hover {
  opacity: 1;
  background: #f5f3ff;
}

/* On folder/sub-folder cards, the rename sits between the details and the
   chevron arrow — use the existing flex row, just nudge the arrow gap. */
.folder-card.my-library-folder .ml-rename-btn,
.folder-card.my-library-sub .ml-rename-btn {
  margin-left: auto;
  margin-right: 4px;
}

/* ── Media (thumb) cards in My Library ─────────────────────── */
.lib-card.ml-media-card {
  position: relative;
}
.lib-card.ml-media-card .ml-media-name {
  font-size: 12px;
  color: #4b5563;
  margin-top: 6px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
}
.lib-card.ml-media-card .ml-rename-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  opacity: 0;
}
.lib-card.ml-media-card:hover .ml-rename-btn,
.lib-card.ml-media-card .ml-rename-btn:focus {
  opacity: 1;
}

/* ── Tag editor button on media cards ──────────────────────── */
.lib-card.ml-media-card .ml-tags-btn {
  position: absolute;
  top: 4px;
  right: 36px;          /* leaves room for the rename ✏️ at right: 4px */
  width: auto;
  padding: 4px 6px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  line-height: 1;
  transition: opacity 0.15s, background 0.15s;
}
.lib-card.ml-media-card:hover .ml-tags-btn,
.lib-card.ml-media-card .ml-tags-btn:focus {
  opacity: 1;
}
.lib-card.ml-media-card .ml-tags-btn:hover {
  background: #f5f3ff;
}

/* ── Tag editor modal ──────────────────────────────────────── */
.tag-editor-overlay { display: none; }
.tag-editor-overlay.is-open {
  display: grid;
  place-items: center;
  position: fixed;
  inset: 0;
  z-index: 2050;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: tag-editor-fade 0.2s ease;
}
.tag-editor-card {
  width: min(480px, 92vw);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 30px 60px -20px rgba(15, 23, 42, 0.45);
  overflow: hidden;
  position: relative;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  animation: tag-editor-pop 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.tag-editor-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: #475569;
  padding: 0;
}
.tag-editor-close:hover {
  background: #f0f2f8;
  color: #090f1a;
}
.tag-editor-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px 12px;
  border-bottom: 1px solid #f0f2f8;
}
.tag-editor-thumb {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  background: #f0f2f8;
  flex-shrink: 0;
}
.tag-editor-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #6d28d9;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.tag-editor-name {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #090f1a;
  word-break: break-word;
  line-height: 1.25;
}
.tag-editor-body {
  padding: 16px 22px 20px;
}
.tag-editor-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 6px;
  min-height: 36px;
  padding: 8px;
  border: 1.5px dashed #ddd6fe;
  border-radius: 10px;
  background: #faf5ff;
  margin-bottom: 12px;
}
.tag-editor-loading,
.tag-editor-empty {
  font-size: 12.5px;
  color: #94a3b8;
  padding: 4px 6px;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1px solid #ddd6fe;
  color: #7c5cfd;
  border-radius: 999px;
  padding: 4px 6px 4px 10px;
  font-size: 12px;
  line-height: 1;
}
.tag-chip-x {
  width: 16px;
  height: 16px;
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
}
.tag-chip-x:hover {
  background: #f0f2f8;
  color: #ef4444;
}
.tag-editor-add-form {
  display: flex;
  gap: 8px;
}
.tag-editor-add-form input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 9px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.tag-editor-add-form input:focus {
  border-color: #a78bfa;
}
.tag-editor-add-btn {
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: #6d28d9;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.tag-editor-add-btn:hover { background: #7c5cfd; }

.tag-editor-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.tag-editor-retag {
  flex: 1;
  height: 40px;
  border: 1.5px solid #ddd6fe;
  background: #f5f3ff;
  color: #6d28d9;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tag-editor-retag:hover {
  background: #ede9fe;
}
.tag-editor-retag[disabled] {
  opacity: 0.6;
  cursor: progress;
}
.tag-editor-done {
  height: 40px;
  padding: 0 18px;
  border: 0;
  background: #090f1a;
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.tag-editor-done:hover { background: #1e293b; }

.tag-editor-note {
  font-size: 11.5px;
  color: #94a3b8;
  margin-top: 8px;
  text-align: center;
}

@keyframes tag-editor-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tag-editor-pop {
  from { transform: translateY(8px) scale(0.97); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ── Smart search ──────────────────────────────────────────── */
.my-library-search {
  position: relative;
  margin: 14px 0 6px;
}
.my-library-search input {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  font-size: 13.5px;
  background: #fff;
  color: #111827;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.my-library-search input:focus {
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}
.my-library-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: 0;
  background: #f3f4f6;
  color: #6b7280;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}
.my-library-search-clear:hover {
  background: #e5e7eb;
  color: #111827;
}

.my-library-results-count {
  color: #9ca3af;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  font-size: 12px;
  margin-left: 4px;
}
.my-library-results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.my-library-results-empty {
  font-size: 13px;
  color: #9ca3af;
  padding: 6px 2px 14px;
}
