/* Library (pages/library*.js) and Approval workflows (pages/approvals.js). Linked after styles.css. */

/* ---------- page bar bits (count, search) ---------- */
.lib-bar-meta { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.lib-bar-count:empty { display: none; }
.lib-bar-meta:has(.lib-bar-count:empty) { display: none; }
.lib-bar-search { flex: 0 1 240px; width: 240px; min-width: 150px; }
.lib-crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.lib-crumbs .icon-wrap { flex: none; }
.lib-crumb { color: var(--text-2); font-weight: 600; white-space: nowrap; }
.lib-crumb:hover { color: var(--accent-ink); }
.lib-crumb-current { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.lib-folder-actions { display: contents; }

/* ---------- list screens (labels, campaigns, UTM, hashtags, captions, replies, categories) ---------- */
.lib-list { min-width: 0; }
.lib-intro { font-weight: 400; max-width: 760px; }
.lib-list-card > .card-header { padding: 12px 16px; }
.lib-skel { padding: 8px 16px; }
.lib-fit { align-self: flex-start; }
.lib-mono, .input.lib-mono, .lib-mono-label { font-family: var(--mono); }
.lib-mono-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.lib-counter { font-variant-numeric: tabular-nums; }
.lib-row-actions { justify-content: flex-end; flex-wrap: nowrap; }
.lib-ph .btn { font-family: var(--mono); font-size: 11.5px; }

.lib-rows { list-style: none; margin: 0; padding: 0; }
.lib-row { display: flex; align-items: flex-start; gap: 12px 16px; padding: 12px 16px; border-bottom: 1px solid var(--border); min-width: 0; }
.lib-row:last-child { border-bottom: 0; }
.lib-row:hover { background: var(--hover); }
.lib-row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.lib-row-title { gap: 8px; }
.lib-row-title h3 { font-size: 13.5px; }
.lib-row-end { flex: none; gap: 4px; }
.lib-text { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-tag-chips .chip { font-weight: 500; }

.lib-params { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.lib-param { font-family: var(--mono); font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; color: var(--text-2); overflow-wrap: anywhere; }
.lib-url { display: block; font-size: 12px; word-break: break-all; background: var(--surface); }
.select.lib-preview-acct { width: auto; max-width: 100%; }

/* categories */
.lib-cat-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; }
.lib-cat-name { max-width: 240px; }
.lib-slot-summary { display: flex; flex-wrap: wrap; gap: 6px; }
.lib-slot-summary .chip { gap: 5px; font-weight: 500; white-space: normal; height: auto; min-height: 24px; padding: 3px 9px; line-height: 1.3; }
.lib-next { flex-wrap: wrap; }

/* ---------- media ---------- */
.lib-subfolders { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; min-width: 0; }
.chip.lib-subfolder { height: 28px; padding: 0 10px; background: var(--surface); color: var(--text); text-decoration: none; }
.chip.lib-subfolder:hover { border-color: var(--border-strong); text-decoration: none; }
.lib-card-filters { gap: 6px; }
.select.lib-filter { width: auto; flex: 0 1 auto; }

.lib-media-card { position: relative; }
.lib-media-card.is-dragover::after {
  content: attr(data-drop); position: absolute; inset: 0; z-index: 4; pointer-events: none;
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px;
  border: 2px dashed var(--accent); border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface)); color: var(--accent-ink); font-weight: 650; font-size: 15px;
}
.lib-grid-wrap { min-width: 0; transition: opacity .12s; }
.lib-grid-wrap.is-loading { opacity: .55; pointer-events: none; }
.lib-empty-drop { display: flex; align-items: center; justify-content: center; min-height: 320px; border: 1.5px dashed var(--border-strong); border-radius: var(--r); }

.lib-mcard .lib-thumb-btn { display: block; width: 100%; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.lib-mcard .lib-thumb-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.lib-thumb { position: relative; }
.lib-badge { position: absolute; left: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 3px; height: 20px; padding: 0 6px; border-radius: 5px; background: rgba(0, 0, 0, .62); color: #fff; font-size: 11px; font-weight: 650; line-height: 1; }
.lib-badge-end { left: auto; right: 6px; }
.lib-sel { display: flex; padding: 4px; border-radius: 6px; background: var(--surface); box-shadow: var(--shadow-pop); cursor: pointer; opacity: 0; transition: opacity .1s; }
.lib-sel input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.lib-mcard:hover .lib-sel, .lib-mcard:focus-within .lib-sel, .lib-grid.has-selection .lib-sel, .lib-mcard.is-selected .lib-sel { opacity: 1; }
.btn.lib-card-btn { background: color-mix(in srgb, var(--surface) 88%, transparent); border-color: var(--border); box-shadow: var(--shadow-pop); opacity: 0; }
.btn.lib-card-btn:hover { background: var(--surface); }
.lib-mcard:hover .lib-card-btn, .lib-mcard:focus-within .lib-card-btn, .btn.lib-card-btn[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .lib-sel, .btn.lib-card-btn { opacity: 1; } }

.callout.lib-upload { align-items: center; }
.lib-progress { width: 100%; height: 6px; accent-color: var(--accent); }
.lib-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; padding-top: 4px; }
.lib-pager:empty { display: none; }
.lib-bulk { top: calc(var(--topbar-h) + 72px); }

/* details modal */
.lib-detail { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.lib-preview { background: var(--surface-3); border-radius: 10px; display: flex; align-items: center; justify-content: center; min-height: 180px; overflow: hidden; color: var(--text-3); }
.lib-preview img, .lib-preview video { display: block; max-width: 100%; max-height: 56vh; object-fit: contain; }
.lib-details-modal .modal-footer .btn { height: 30px; padding: 0 10px; font-size: 13px; }

@media (max-width: 760px) {
  .lib-detail { grid-template-columns: minmax(0, 1fr); }
  .lib-bar-search { flex: 1 1 100%; width: auto; min-width: 0; order: 5; }
  .lib-bar .page-bar-end, .page-bar.lib-bar > .page-bar-end { margin-left: 0; }
  .lib-hide-sm, .table .lib-hide-sm { display: none; }
  .lib-row { flex-wrap: wrap; }
  .lib-row-end { width: 100%; justify-content: flex-end; }
  .lib-empty-drop { min-height: 240px; }
}
@media (max-width: 420px) {
  .lib-hide-xs { display: none; }
  .lib-grid.media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .lib-card-filters { width: 100%; }
  .select.lib-filter { flex: 1 1 120px; }
}

/* ---------- approval workflows ---------- */
.appr-how .card-body { padding: 14px 16px; }
.appr-how-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 20px; }
.appr-how-grid p { color: var(--text-2); }
.appr-how-grid strong { color: var(--text); }
.appr-how-icon { width: 28px; height: 28px; border-radius: 8px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-ink); }
@media (max-width: 900px) { .appr-how-grid { grid-template-columns: minmax(0, 1fr); } }

.appr-list { display: flex; flex-direction: column; gap: 12px; }
.appr-card { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.appr-card.is-default { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.appr-name { font-size: 15px; overflow-wrap: anywhere; }
.appr-flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; min-width: 0; }
.appr-step { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); min-width: 0; max-width: 100%; flex: 0 1 260px; }
.appr-names { overflow-wrap: anywhere; }
.appr-arrow { align-self: center; color: var(--text-3); display: inline-flex; }
.appr-num { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 11.5px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
@media (max-width: 640px) {
  .appr-flow { flex-direction: column; }
  .appr-step { flex-basis: auto; }
  .appr-arrow { transform: rotate(90deg); }
}

.appr-levels { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.appr-level { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 12px; background: var(--surface); min-width: 0; }
.appr-level.is-invalid { border-color: var(--danger); }
.appr-level-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.appr-level-head .appr-num { width: 26px; height: 26px; font-size: 12.5px; margin-right: 2px; }
.appr-members { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); gap: 6px; }
.appr-member { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; min-width: 0; transition: border-color .12s, background .12s; }
.appr-member:hover { border-color: var(--border-strong); }
.appr-member.is-on { border-color: var(--accent); background: var(--accent-soft); }
.appr-member input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; cursor: pointer; }
.appr-member:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.check.appr-default { align-items: flex-start; }
.check.appr-default input { margin-top: 2px; }

/* on phones the wrapped page bar would take a third of the screen if it stayed pinned */
@media (max-width: 560px) {
  .lib-page > .page-bar { position: static; }
  .bulk-bar.lib-bulk { top: calc(var(--topbar-h) + 8px); }
}
