/**
 * Prompt Library page — v20260428a
 */

.library-page {
  padding: 24px 32px;
  max-width: 1200px;
  margin: 0 auto;
}

.library-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
}
.library-header-left { display: flex; flex-direction: column; gap: 6px; }
.library-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #6B7280;
  text-decoration: none;
  font-weight: 500;
}
.library-back-link:hover { color: #111827; }
.library-title {
  font-size: 24px;
  font-weight: 600;
  color: #111827;
  margin: 0;
  letter-spacing: -0.02em;
}
.library-subtitle {
  font-size: 14px;
  color: #6B7280;
  margin: 0;
  max-width: 600px;
}
.library-btn-primary {
  background: #6366F1;
  color: white;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid #6366F1;
  transition: background 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
}
.library-btn-primary:hover { background: #4F46E5; }

/* Toolbar */
.library-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.library-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 480px;
  background: white;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 6px 10px;
}
.library-search-wrap svg { color: #9CA3AF; flex-shrink: 0; }
.library-search {
  flex: 1;
  border: 0;
  outline: none;
  font: inherit;
  font-size: 14px;
  background: transparent;
  color: #111827;
}
.library-sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #6B7280;
}
.library-sort {
  background: white;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
  color: #111827;
}

/* Table */
.library-table-wrap {
  background: white;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}
.library-table {
  width: 100%;
  border-collapse: collapse;
}
.library-table thead {
  background: #F9FAFB;
}
.library-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #E5E7EB;
  white-space: nowrap;
}
.library-th-meta { width: 1%; white-space: nowrap; }
.library-th-actions { width: 1%; text-align: right; padding-right: 16px; }
.library-table tbody tr {
  border-bottom: 1px solid #F3F4F6;
  transition: background 0.12s ease;
}
.library-table tbody tr:hover { background: #FAFAFA; }
.library-table tbody tr:last-child { border-bottom: 0; }
.library-table td {
  padding: 14px 16px;
  font-size: 14px;
  color: #111827;
  vertical-align: middle;
}
.library-name {
  font-weight: 500;
  color: #111827;
}
.library-desc {
  color: #4B5563;
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 480px;
  line-height: 1.45;
}
.library-target {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}
.library-target--customers { background: #DBEAFE; color: #1D4ED8; }
.library-target--leads { background: #FEF3C7; color: #92400E; }
.library-target--both { background: #EDE9FE; color: #6D28D9; }
.library-cell-dash { color: #9CA3AF; }

/* Actions */
.library-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}
.library-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 1px solid #E5E7EB;
  color: #374151;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.library-action:hover { background: #F3F4F6; border-color: #D1D5DB; }
.library-action--use {
  background: #6366F1;
  border-color: #6366F1;
  color: white;
}
.library-action--use:hover { background: #4F46E5; border-color: #4F46E5; }
.library-action--delete:hover { color: #B91C1C; border-color: #FECACA; background: #FEF2F2; }
.library-action svg { display: block; }

/* Empty + loading */
.library-empty {
  padding: 60px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.library-empty[hidden] { display: none; }
.library-empty svg { color: #D1D5DB; margin-bottom: 8px; }
.library-empty h3 { font-size: 16px; margin: 0; color: #111827; font-weight: 600; }
.library-empty p { font-size: 14px; color: #6B7280; margin: 0 0 12px 0; }
.library-loading {
  padding: 60px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.library-loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #E5E7EB;
  border-top-color: #6366F1;
  border-radius: 50%;
  animation: lib-spin 0.8s linear infinite;
}
@keyframes lib-spin { to { transform: rotate(360deg); } }
.library-loading p { font-size: 13px; color: #6B7280; margin: 0; }
.library-no-match {
  padding: 32px !important;
  text-align: center;
  color: #6B7280;
}

/* Responsive */
@media (max-width: 720px) {
  .library-page { padding: 16px; }
  .library-header { flex-direction: column; align-items: flex-start; }
  .library-desc { display: none; }
  .library-th-meta:nth-of-type(2) { display: none; }
  .library-target { display: none; }
}

/* ─── Presets-specific styles ─────────────────────────────────────── */

/* Secondary button used in modal footer */
.library-btn-secondary {
  background: #FFFFFF;
  color: #374151;
  border: 1px solid #D1D5DB;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.library-btn-secondary:hover { background: #F9FAFB; border-color: #9CA3AF; }

/* Table row content */
.preset-row-name { font-weight: 600; color: #111827; font-size: 14px; }
.preset-row-desc { font-size: 12.5px; color: #6B7280; margin-top: 2px; }
.preset-row-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.preset-row-chip--saved   { background: #EDE9FE; color: #5B21B6; }
.preset-row-chip--builtin { background: #DBEAFE; color: #1D4ED8; }
.preset-row-template { font-size: 13px; color: #374151; }

/* Modal */
.preset-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  z-index: 1000;
  overflow-y: auto;
}
/* Honor the [hidden] attribute toggled by JS — `display: flex` above
   would otherwise keep the modal permanently visible on page load. */
.preset-modal-overlay[hidden] { display: none; }
.preset-modal {
  background: #FFFFFF;
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.18);
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
}
.preset-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #F3F4F6;
}
.preset-modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #111827;
}
.preset-modal-close {
  background: none;
  border: 0;
  padding: 6px;
  cursor: pointer;
  color: #6B7280;
  border-radius: 6px;
}
.preset-modal-close:hover { background: #F3F4F6; color: #111827; }
.preset-modal-body {
  padding: 20px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.preset-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid #F3F4F6;
  margin-top: 12px;
}

.preset-field-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin: 12px 0 4px;
}
.preset-field-optional {
  font-weight: 400;
  color: #9CA3AF;
  font-size: 12px;
}
.preset-input {
  width: 100%;
  padding: 9px 11px;
  font-size: 14px;
  color: #111827;
  background: #FFFFFF;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  outline: none;
}
.preset-input:focus {
  border-color: #6366F1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.preset-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
  border-bottom: 1px solid #E5E7EB;
}
.preset-tab {
  background: none;
  border: 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #6B7280;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.preset-tab:hover { color: #374151; }
.preset-tab--active { color: #1D4ED8; border-bottom-color: #1D4ED8; }

.preset-audience-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
}
/* Same [hidden] suppression — switchAudienceTab toggles .hidden on the
   inactive panel, but `display: grid` would otherwise keep both panels
   visible at once. */
.preset-audience-list[hidden] { display: none; }
@media (max-width: 540px) {
  .preset-audience-list { grid-template-columns: 1fr; }
}
.preset-audience-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.preset-audience-card:hover { border-color: #9CA3AF; background: #F9FAFB; }
.preset-audience-card--on {
  border-color: #1D4ED8;
  background: #EFF6FF;
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.15);
}
.preset-audience-name { font-size: 13px; font-weight: 600; color: #111827; }
.preset-audience-meta { font-size: 11.5px; color: #6B7280; margin-top: 2px; text-transform: capitalize; }
.preset-audience-desc { font-size: 12px; color: #4B5563; margin-top: 4px; line-height: 1.4; }

.preset-empty-hint {
  font-size: 13px;
  color: #6B7280;
  padding: 12px 4px;
  margin: 0;
}
.preset-empty-link {
  color: #1D4ED8;
  text-decoration: none;
  font-weight: 500;
}
.preset-empty-link:hover { text-decoration: underline; }

.preset-form-err {
  font-size: 13px;
  color: #B91C1C;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px 0 0;
}
