/**
 * Email Templates page — v20260524a
 * Reuses the .library-* classes from campaigns-audiences.css for layout chrome,
 * adds template-specific card grid + preview modal styles.
 */

@import url('/css/campaigns-audiences.css?v=20260524a');

/* Card grid */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-top: 4px;
}

.template-card {
  background: white;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.template-card:hover {
  border-color: #C7D2FE;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.07);
}
.template-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.template-card-name {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
}
.template-card-badge {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.template-card-badge--system { background: #EEF2FF; color: #4338CA; }
.template-card-badge--mine { background: #DCFCE7; color: #166534; }
.template-card-cat {
  display: inline-block;
  font-size: 11px;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.template-card-desc {
  font-size: 13px;
  color: #4B5563;
  margin: 0;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.template-card-subject {
  font-size: 12px;
  color: #6B7280;
  margin: 0;
  border-top: 1px solid #F3F4F6;
  padding-top: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.template-card-subject strong {
  color: #4B5563;
  font-weight: 500;
}

/* Preview / edit modal */
.template-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 24px;
}
.template-preview-overlay[hidden] { display: none; }
.template-preview-modal {
  background: white;
  border-radius: 12px;
  max-width: 840px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.2);
}
.template-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid #F3F4F6;
}
.template-preview-name-input {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  color: #111827;
  border: 0;
  outline: none;
  font-family: inherit;
  background: transparent;
  padding: 4px 6px;
  border-radius: 6px;
}
.template-preview-name-input:not([readonly]):focus { background: #F9FAFB; }
.template-preview-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.template-preview-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.template-preview-meta-label {
  font-size: 11px;
  font-weight: 600;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.template-preview-input {
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  color: #111827;
  background: white;
}
.template-preview-input:focus {
  outline: none;
  border-color: #6366F1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.template-preview-input[readonly] {
  background: #F9FAFB;
  color: #4B5563;
  cursor: default;
}
.template-preview-frame-wrap {
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  overflow: hidden;
  background: #F9FAFB;
}
.template-preview-frame {
  width: 100%;
  height: 460px;
  border: 0;
  background: white;
  display: block;
}
.template-preview-readonly-hint {
  font-size: 12px;
  color: #92400E;
  background: #FEF3C7;
  padding: 8px 10px;
  border-radius: 6px;
  margin: 0;
  border-left: 3px solid #F59E0B;
}
.template-preview-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid #F3F4F6;
  background: #FAFAFA;
}

/* Secondary "+ New Campaign" link in the templates header */
.library-btn-ghost {
  background: white;
  border: 1px solid #E5E7EB;
  color: #374151;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  margin-left: 8px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.library-btn-ghost:hover {
  background: #F9FAFB;
  border-color: #D1D5DB;
}

/* Editor modal — same shell as preview but with Quill-friendly content */
.template-editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9100;
  padding: 24px;
}
.template-editor-overlay[hidden] { display: none; }
.template-editor-modal {
  background: white;
  border-radius: 12px;
  max-width: 880px;
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.2);
}
.template-editor-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  color: #111827;
  margin: 0;
}
.template-editor-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.template-editor-row {
  display: flex;
  gap: 12px;
}
.template-editor-row .template-editor-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Quill snow theme overrides — match the rest of the dashboard */
.template-editor-quill-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.template-editor-quill {
  min-height: 320px;
  border: 1px solid #E5E7EB;
  border-radius: 0 0 8px 8px;
  font-size: 14px;
  background: white;
}
.template-editor-quill-wrap .ql-toolbar.ql-snow {
  border: 1px solid #E5E7EB;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #FAFAFA;
}
.template-editor-quill .ql-editor {
  min-height: 280px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #111827;
  line-height: 1.6;
}
.template-editor-help {
  font-size: 12px;
  color: #6B7280;
  margin: 4px 0 0 0;
}
.template-editor-help code {
  background: #EEF2FF;
  color: #4338CA;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}
