/* =========================================================================
   Prompt Library — library-only styles
   Pulls all design tokens (colors, radii, shadows) from theme.css.
   ========================================================================= */

/* Search input lives in the header on this page only. */
.search-wrap {
  position: relative;
}
.search-wrap input[type="search"] {
  width: 100%;
  padding: 10px 14px 10px 40px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  font-family: inherit;
}
.search-wrap .icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* The library page uses a 4-column header to fit the search input between
   the brand and the action buttons (theme.css uses a 3-column header). */
.header-inner.library {
  grid-template-columns: auto 1fr auto auto;
}

/* =========================
   Layout
   ========================= */
main.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
}

/* =========================
   Filters sidebar
   ========================= */
aside.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  align-self: start;
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}
.filters h2 { margin: 0 0 12px; font-size: 1rem; }
.filter-group { margin-bottom: 14px; }
.filter-group:last-child { margin-bottom: 0; }
.filter-group h3 {
  margin: 0 0 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.filters-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px;
  font-family: inherit;
}
.link-btn:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Mobile filter toggle */
.filter-toggle {
  display: none;
  width: 100%;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

/* =========================
   Results header + status
   ========================= */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}
.results-count {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.sort-wrap label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-right: 6px;
}
.sort-wrap select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}
.api-status {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--warn);
  color: var(--warn);
}

/* Active filter pills */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.active-pill {
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.active-pill button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

/* =========================
   Card grid (library-specific layout; .card itself is in theme.css)
   ========================= */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* =========================
   Empty state
   ========================= */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty h3 { color: var(--text); margin: 0 0 8px; }

/* =========================
   Responsive
   ========================= */
@media (max-width: 860px) {
  main.page { grid-template-columns: 1fr; }
  aside.filters {
    position: static;
    max-height: none;
    display: none;
  }
  aside.filters.open { display: block; }
  .filter-toggle { display: block; }

  /* On mobile the search input drops below brand+actions on its own row. */
  .header-inner.library {
    grid-template-columns: auto 1fr auto;
  }
  .header-inner.library .search-wrap {
    grid-column: 1 / -1;
    order: 3;
  }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
  main.page { padding: 12px; }
}
