/* ============================================================
   PASSAGE by Khoshà — Email Templates (Settings)
   Companion to emailtemplates.js. Only styles for the bits that
   aren't already covered by the shared .panel/.fld/.frow/.btn/.pill
   component classes in styles.css. Mobile-first: base rules target
   a phone; inputs and the body textarea are 16px throughout so iOS
   Safari never zooms on focus, in or out of the mobile breakpoint.
   All new selectors are prefixed `et-`.
   ============================================================ */

.et-page{ display:flex; flex-direction:column; gap:16px; }
.et-head p{ max-width:640px; }

.et-layout{
  display:grid;
  grid-template-columns: 260px 1fr;
  gap:16px;
  align-items:start;
}
.et-list-col{ display:flex; flex-direction:column; gap:10px; min-width:0; }
.et-detail-col{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:16px;
  align-items:start;
  min-width:0;
}

/* -------- list column -------- */
.et-list{ display:flex; flex-direction:column; gap:8px; }
.et-card{
  background:rgba(255,255,255,.6);
  border:1px solid var(--stroke-soft);
  border-radius:var(--r-md);
  padding:12px 14px;
  cursor:pointer;
  transition:border-color .18s, transform .18s, background .18s;
}
.et-card:hover{ border-color:var(--gold); transform:translateY(-1px); }
.et-card.active{ border-color:var(--gold); background:rgba(169,130,76,.08); }
.et-card-top{ display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:4px; }
.et-card-name{ font-weight:700; font-size:13.5px; color:var(--ink); }
.et-card-fires{ font-size:11.5px; color:var(--ink-soft); line-height:1.4; margin-bottom:4px; }
.et-card-subject{ font-size:11.5px; color:var(--ink-faint); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* -------- editor panel -------- */
.et-editor-panel{ min-width:0; }
.et-editor-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
.et-fires{ margin:2px 0 14px; }

.et-editor-panel input#etSubject,
.et-editor-panel textarea#etBody{
  font-size:16px;
  min-height:44px;
}
.et-body{
  font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:13px;
  line-height:1.5;
  resize:vertical;
  min-height:220px;
  white-space:pre;
  overflow-wrap:normal;
  overflow-x:auto;
}
/* the mono textarea overrides the 16px rule above on purpose — this
   is HTML source, not a form field a phone should zoom for editing */
.et-body{ font-size:13px; }

.et-vars{ margin:6px 0 16px; }
.et-vars-title{ font-size:12px; font-weight:700; letter-spacing:.04em; color:var(--ink-faint); text-transform:uppercase; margin-bottom:8px; display:flex; align-items:center; gap:8px; }
.et-vars-title .hint{ text-transform:none; letter-spacing:0; font-weight:500; font-size:11.5px; }
.et-var-list{ display:flex; flex-wrap:wrap; gap:6px; }
.et-var-chip{
  border:1px solid var(--stroke);
  background:var(--paper);
  color:var(--ink);
  border-radius:999px;
  padding:6px 12px;
  font-size:12px;
  font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  cursor:pointer;
  transition:all .18s;
  max-width:100%;
  overflow:hidden;
  text-overflow:ellipsis;
}
.et-var-chip:hover{ border-color:var(--gold); color:var(--gold-deep); transform:translateY(-1px); }
.et-var-chip.auto{ background:var(--bone); color:var(--ink-soft); }

.et-actions{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-top:6px; }
.et-actions-spacer{ flex:1; }
.et-dirty{ box-shadow:0 0 0 3px rgba(169,130,76,.28); }

.et-result{
  margin-top:12px;
  border-radius:var(--r-sm);
  padding:9px 12px;
  font-size:12.5px;
  line-height:1.5;
}
.et-result[hidden]{ display:none; }
.et-result.ok{ background:rgba(30,58,51,.08); border:1px solid rgba(30,58,51,.25); color:var(--green); }
.et-result.err{ background:rgba(140,59,46,.08); border:1px solid rgba(140,59,46,.25); color:var(--red); }

/* -------- preview panel -------- */
.et-preview-panel{ min-width:0; display:flex; flex-direction:column; }
.et-preview-toolbar{ display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-bottom:10px; }
.et-seg{ display:inline-flex; border:1px solid var(--stroke); border-radius:999px; padding:3px; gap:2px; }
.et-seg-btn{
  border:0;
  background:transparent;
  color:var(--ink-soft);
  font-size:12.5px;
  font-weight:600;
  padding:6px 14px;
  border-radius:999px;
  cursor:pointer;
  transition:all .18s;
}
.et-seg-btn.active{ background:var(--gold); color:#fff; }

.et-preview-subject{
  font-size:12.5px;
  color:var(--ink-soft);
  margin-bottom:10px;
  padding:8px 12px;
  background:var(--bone);
  border-radius:var(--r-sm);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.et-preview-frame-wrap{
  overflow-x:auto;
  border-radius:var(--r-md);
  background:repeating-conic-gradient(var(--bone) 0% 25%, transparent 0% 50%) 50% / 16px 16px;
  padding:14px;
}
.et-preview-frame-inner{
  margin:0 auto;
  background:#fff;
  border-radius:8px;
  box-shadow:var(--shadow-soft);
  overflow:hidden;
  transition:width .22s ease;
}
/* Deliberately NOT clamped with max-width:100% — the point of the
   toggle is to show the true simulated width (a real desktop email
   client is ~600px, a real phone client ~375px) even when the
   Settings column hosting it is narrower than that. The wrap above
   scrolls internally when it has to, so the CRM page itself never
   gains horizontal overflow — only this one boxed-off preview does. */
.et-preview-frame-inner.et-w-desktop{ width:600px; min-width:600px; }
.et-preview-frame-inner.et-w-mobile{ width:375px; min-width:375px; }
.et-preview-frame{
  display:block;
  width:100%;
  height:560px;
  border:0;
  background:#fff;
}

.et-empty{ display:flex; align-items:center; min-height:160px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width:1100px){
  .et-detail-col{ grid-template-columns:1fr; }
}

@media (max-width:760px){
  .et-layout{ grid-template-columns:1fr; }
  /* one screen at a time on a phone: the list route hides the (empty)
     detail column, the detail route hides the list. */
  .et-layout[data-mode="list"] .et-detail-col{ display:none; }
  .et-layout[data-mode="detail"] .et-list-col{ display:none; }
  .et-preview-frame{ height:480px; }
  .et-card-fires{ display:none; }
}
