/**
 * 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;
}
/* The `display: flex` above overrides the UA stylesheet's
   `[hidden] { display: none }`, so explicit attribute-selector
   suppression is required for the empty state to actually hide
   when rows are present. */
.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; }
}

/* ─── Secondary button + New Audience modal ─────────────────────── */

.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; }

.audience-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;
}
.audience-modal-overlay[hidden] { display: none; }

.audience-modal {
  background: #FFFFFF;
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.18);
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
}
.audience-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #F3F4F6;
}
.audience-modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #111827;
}
.audience-modal-close {
  background: none;
  border: 0;
  padding: 6px;
  cursor: pointer;
  color: #6B7280;
  border-radius: 6px;
}
.audience-modal-close:hover { background: #F3F4F6; color: #111827; }
.audience-modal-body {
  padding: 20px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.audience-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid #F3F4F6;
  margin-top: 12px;
}

.audience-field-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin: 12px 0 4px;
}
.audience-input {
  width: 100%;
  padding: 9px 11px;
  font-size: 14px;
  color: #111827;
  background: #FFFFFF;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  outline: none;
  font-family: inherit;
}
.audience-input:focus {
  border-color: #6366F1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.audience-textarea { resize: vertical; min-height: 88px; }
.audience-field-hint {
  font-size: 12.5px;
  color: #6B7280;
  margin: 4px 0 0;
  line-height: 1.4;
}

.audience-form-err {
  font-size: 13px;
  color: #B91C1C;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 6px;
  padding: 8px 12px;
  margin: 12px 0 0;
}
.audience-form-err[hidden] { display: none; }
.audience-form-ok {
  font-size: 13px;
  color: #065F46;
  background: #ECFDF5;
  border: 1px solid #A7F3D0;
  border-radius: 6px;
  padding: 8px 12px;
  margin: 12px 0 0;
}
.audience-form-ok[hidden] { display: none; }
