/* Biblioteca de secțiuni din dialogul editorului de temă. Se încarcă înaintea lui admin-theme-editor.css (ordine alfabetică),
   deci regulile câștigă prin specificitate (.te .te-...), nu prin ordine. */

.te .te-dialog:has(.te-lib-results) { max-width: 54rem; }
.te .te-dialog[open]:has(.te-lib-results) { display: flex; flex-direction: column; gap: 0.5rem; overflow: hidden; max-height: 90dvh; }
.te .te-dialog .te-lib-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.te .te-dialog .te-lib-controls .field { margin: 0; }
.te .te-dialog .te-lib-controls :is(input, select) { width: 100%; max-width: 100%; }
.te .te-dialog .te-lib-filters { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.te .te-dialog .te-lib-filter {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--te-border-strong);
  border-radius: 999px;
  background: var(--te-surface);
  color: var(--te-text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}
.te .te-dialog .te-lib-filter:hover { background: var(--te-hover); }
.te .te-dialog .te-lib-filter[aria-pressed="true"] { background: var(--te-accent-soft); border-color: var(--te-accent); font-weight: 600; }
.te .te-dialog .te-lib-status { margin: 0; padding: 0; border: 0; background: none; color: var(--te-muted); font-size: 0.875rem; }

/* Lista derulează, titlul, căutarea și butonul de închidere rămân în vedere. */
.te .te-dialog .te-lib-results { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0.25rem; }
.te .te-dialog .te-lib-results [hidden] { display: none; }
.te .te-dialog .te-lib-cat-title { margin: 0.75rem 0 0.5rem; font-size: 0.9375rem; }
.te .te-dialog .te-lib-cat:first-child .te-lib-cat-title { margin-top: 0; }
.te .te-dialog .te-lib-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, 240px); justify-content: center; gap: 1rem; }

/* Cardul e <li>: miniatura și butonul stau în aceeași celulă, iar butonul, cu spațiu sus cât miniatura, acoperă tot cardul. */
.te .te-dialog .te-lib-item {
  display: grid;
  width: 240px;
  border: 1px solid var(--te-border-strong);
  border-radius: 8px;
  background: var(--te-surface);
  overflow: hidden;
}
.te .te-dialog .te-lib-item:hover { background: var(--te-hover); }
.te .te-dialog .te-lib-thumb {
  grid-area: 1 / 1;
  width: 240px;
  height: 150px;
  overflow: hidden;
  /* Același alb ca iframe-ul: o secțiune scundă, centrată, nu lasă o bandă de altă culoare deasupra. */
  background: #fff;
  border-bottom: 1px solid var(--te-border);
  pointer-events: none;
}
.te .te-dialog .te-lib-thumb iframe {
  display: block;
  width: 960px;
  height: 600px;
  border: 0;
  background: #fff;
  transform: translateY(var(--te-lib-shift, 0)) scale(0.25);
  transform-origin: 0 0;
  pointer-events: none;
}
.te .te-dialog .te-lib-thumb iframe[hidden] { display: none; }
.te .te-dialog .te-lib-nothumb { margin: 0; padding: 0.75rem; font-size: 0.8125rem; color: var(--te-muted); text-align: center; }
.te .te-dialog .te-lib-card {
  grid-area: 1 / 1;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  width: 100%;
  padding: calc(150px + 0.5rem) 0.75rem 0.75rem;
  border: 0;
  background: transparent;
  color: var(--te-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.te .te-dialog .te-lib-card:focus-visible { outline: 2px solid var(--te-accent); outline-offset: -2px; box-shadow: inset 0 0 0 4px var(--te-surface); }
.te .te-dialog .te-lib-name { font-weight: 600; }
.te .te-dialog .te-lib-desc { font-size: 0.8125rem; color: var(--te-muted); }

@media (max-width: 40rem) {
  .te .te-dialog .te-lib-controls { grid-template-columns: minmax(0, 1fr); }
}

/* Lista și, pe ecran lat cu mouse, previzualizarea mare (H5, ca în Shopify): aceeași pagină-miniatură la scara 0,5 (480x300). */
.te .te-dialog .te-lib-body { display: flex; gap: 1rem; flex: 1 1 auto; min-height: 0; }
.te .te-dialog .te-lib-body .te-lib-results { flex: 1 1 auto; min-width: 0; }
.te .te-dialog .te-lib-preview { display: none; }
@media (hover: hover) and (min-width: 60rem) {
  .te .te-dialog:has(.te-lib-preview) { max-width: 72rem; }
  .te .te-dialog .te-lib-preview { display: flex; flex-direction: column; gap: 0.5rem; flex: 0 0 30rem; align-self: flex-start; }
  .te .te-dialog .te-lib-preview-title { margin: 0; font-weight: 600; min-height: 1.25rem; }
  .te .te-dialog .te-lib-preview-note { margin: 0; font-size: 0.8125rem; }
  .te .te-dialog .te-lib-preview-stage { position: relative; width: 480px; height: 300px; overflow: hidden; border: 1px solid var(--te-border-strong); border-radius: 8px; background: var(--te-surface-2); }
  .te .te-dialog .te-lib-preview-stage iframe { position: absolute; top: 0; left: 0; width: 960px; height: 600px; border: 0; background: #fff; transform: scale(0.5); transform-origin: 0 0; }
  .te .te-dialog .te-lib-preview-stage iframe[hidden] { display: none; }
}
