/* admin-email-templates.css — Email Templates editor
   Uses standard app theme tokens (var(--bg), var(--border), var(--text) etc.)
   Class prefix: et- (email template)
*/

/* ── Section header ──────────────────────────────────────────────────────────── */
.et-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.et-header h3 { margin: 0 0 4px; font-size: 1.05rem; font-weight: 700; color: var(--text); }
.et-header-desc { margin: 0; font-size: 0.82rem; color: var(--muted); line-height: 1.5; }

/* ── Loading / error ─────────────────────────────────────────────────────────── */
.et-loading { padding: 28px; text-align: center; color: var(--muted); font-size: 0.88rem; }
.et-error   { padding: 14px; border-radius: 8px; background: rgba(220,38,38,0.08); color: #dc2626; font-size: 0.85rem; }

/* ── Template list ───────────────────────────────────────────────────────────── */
.et-list { display: flex; flex-direction: column; gap: 10px; }

/* ── Template card ───────────────────────────────────────────────────────────── */
.et-card {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.et-card:hover { border-color: var(--blue); }
.et-card-custom {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245,158,11,0.1);
}

.et-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
.et-card-header:hover { background: var(--bg2); }

.et-card-left { flex: 1; min-width: 0; }
.et-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.et-card-desc { font-size: 0.78rem; color: var(--muted); }

.et-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Status badges ───────────────────────────────────────────────────────────── */
.et-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.et-badge-default  { background: var(--bg2); color: var(--muted); border: 1px solid var(--border); }
.et-badge-custom   { background: rgba(245,158,11,0.15); color: #b45309; border: 1px solid rgba(245,158,11,0.3); }
.et-updated        { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.et-chevron        { font-size: 1.1rem; color: var(--muted); transition: transform 0.2s; width: 20px; text-align: center; }
.et-chevron.open   { transform: rotate(90deg); }

/* ── Full-screen editor overlay ──────────────────────────────────────────────── */
.et-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.et-editor-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.et-editor-title {
  flex: 1;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  min-width: 0;
}
.et-editor-subtitle {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}
.et-editor-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.et-editor-close:hover { background: var(--bg3, var(--bg2)); color: var(--text); }

/* Subject row */
.et-subject-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.et-subject-bar label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.et-subject-input {
  flex: 1;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.88rem;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.et-subject-input:focus { border-color: var(--blue); }

/* Tab bar */
.et-tabs {
  display: flex;
  gap: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.et-tab {
  padding: 9px 16px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.et-tab:hover { color: var(--text); }
.et-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* Editor body */
.et-editor-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.et-tab-pane { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.et-tab-pane.active { display: flex; }

/* HTML / Text textarea pane */
.et-textarea-wrap {
  flex: 1;
  display: flex;
  gap: 0;
  overflow: hidden;
}
.et-textarea {
  flex: 1;
  resize: none;
  background: var(--bg);
  border: none;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.6;
  padding: 16px 20px;
  font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
  outline: none;
  overflow-y: auto;
}
.et-textarea::placeholder { color: var(--muted); }

/* Variables sidebar */
.et-vars-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bg2);
  overflow-y: auto;
  padding: 14px 12px;
}
.et-vars-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
}
.et-vars-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.4;
}
.et-var-item {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  margin-bottom: 7px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.et-var-item:hover { border-color: var(--blue); background: var(--bg3, var(--bg2)); }
.et-var-item code {
  display: block;
  font-size: 0.75rem;
  color: var(--blue);
  font-family: 'Menlo', 'Consolas', monospace;
  margin-bottom: 2px;
}
.et-var-item span {
  font-size: 0.72rem;
  color: var(--muted);
}
.et-var-inserted {
  border-color: #22c55e !important;
  background: rgba(34,197,94,0.06) !important;
}

/* Preview pane */
.et-preview-pane {
  flex: 1;
  overflow: auto;
  padding: 20px;
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.et-preview-notice {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 14px;
}
.et-preview-frame {
  width: 100%;
  max-width: 640px;
  min-height: 400px;
  border: none;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
}

/* Bottom action bar — centred */
.et-action-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.et-action-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
/* Purple save button */
.et-btn-save {
  background: #6366f1;
  color: #ffffff;
  border: none;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 10px 28px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.et-btn-save:hover  { background: #4f46e5; box-shadow: 0 2px 12px rgba(99,102,241,0.35); }
.et-btn-save:active { background: #4338ca; }

.et-feedback-inline {
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: 8px;
  display: none;
  text-align: center;
}
.et-feedback-inline.ok   { display: block; background: rgba(34,197,94,0.1);  color: #16a34a; }
.et-feedback-inline.fail { display: block; background: rgba(220,38,38,0.1);  color: #dc2626; }
.et-feedback-inline.info { display: block; background: var(--bg); color: var(--muted); }

/* Text rendered-preview panel */
.et-text-preview-wrap {
  border-top: 1px solid var(--border);
  padding: 12px 20px 16px;
  flex-shrink: 0;
  background: var(--bg2);
  max-height: 160px;
  overflow-y: auto;
}
.et-text-preview-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 7px;
}
.et-text-preview-body {
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
/* Variable badge inline in text preview */
.et-var-badge {
  display: inline-flex;
  align-items: center;
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #c4b5fd;
  border-radius: 6px;
  padding: 0 7px;
  font-size: 0.76rem;
  font-weight: 600;
  font-family: inherit;
  vertical-align: middle;
  line-height: 1.6;
  white-space: nowrap;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .et-vars-sidebar { display: none; }
  .et-subject-bar  { flex-wrap: wrap; }
  .et-card-right   { flex-wrap: wrap; }
  .et-updated      { display: none; }
}
