/* ─── Fonts ─────────────────────────────────────────────────────────────────── */
@font-face {
  font-family: "Sora";
  src: url("../assets/fonts/Sora-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Sora";
  src: url("../assets/fonts/Sora-SemiBold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Sora";
  src: url("../assets/fonts/Sora-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("../assets/fonts/OpenSans-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("../assets/fonts/OpenSans-Italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("../assets/fonts/OpenSans-SemiBold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("../assets/fonts/OpenSans-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

/* ─── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

:root {
  --color-bg:        #f4f5f7;
  --color-panel:     #ffffff;
  --color-border:    #e0e2e8;
  --color-header:    #1a1a2e;
  --color-accent:    #4361ee;
  --color-accent-dk: #3451d1;
  --color-text:      #1a1a2e;
  --color-muted:     #6b7280;
  --color-success:   #059669;
  --color-error:     #dc2626;
  --radius:          8px;
  --shadow-sm:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:       0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --font-ui:         "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-head:       "Sora", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --panel-width:     380px;
}

html {
  height: 100%;
}

body {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}

/* ─── Header ───────────────────────────────────────────────────────────────── */
header {
  background: var(--color-header);
  color: #fff;
  padding: 16px 28px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.header-logo { line-height: 0; color: #fff; }
.header-logo svg { height: 19px; width: auto; display: block; }

.header-inner h1 {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: #fff;
}

.header-inner p {
  font-size: 12px;
  color: rgba(255,255,255,.55);
  margin-top: 2px;
}

.header-all-apps {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  white-space: nowrap;
  justify-self: end;
  transition: color .15s;
}
.header-all-apps:hover { color: #fff; }

/* ─── Footer ───────────────────────────────────────────────────────────────── */
footer {
  padding: 16px 28px;
  font-size: 12px;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
  text-align: center;
  flex-shrink: 0;
}

footer a {
  color: var(--color-muted);
  text-decoration: none;
}

footer a:hover { color: var(--color-accent); }

/* ─── Layout ───────────────────────────────────────────────────────────────── */
main {
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ─── Form panel ───────────────────────────────────────────────────────────── */
.form-panel {
  width: var(--panel-width);
  min-width: var(--panel-width);
  background: var(--color-panel);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding-bottom: 40px;
}

.form-panel::-webkit-scrollbar { width: 5px; }
.form-panel::-webkit-scrollbar-track { background: transparent; }
.form-panel::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ─── Form sections ────────────────────────────────────────────────────────── */
.form-section {
  border-bottom: 1px solid var(--color-border);
  padding: 0;
}

.section-title {
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--color-muted);
  padding: 14px 20px;
  cursor: default;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.collapsible .section-title { cursor: pointer; }
.collapsible .section-title:hover { color: var(--color-text); }

.chevron {
  font-size: 16px;
  transition: transform .2s;
  color: var(--color-muted);
}

.collapsible .section-body { display: none; }
.collapsible.open .section-body { display: block; }
.collapsible.open .chevron { transform: rotate(180deg); }

.section-body { padding: 0 20px 16px; }

/* ─── Field groups ─────────────────────────────────────────────────────────── */
.field-group { margin-top: 12px; }
.field-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: 5px;
}

.field-group input[type="text"],
.field-group input[type="email"],
.field-group input[type="url"],
.field-group textarea,
.field-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-ui);
  color: var(--color-text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(67,97,238,.12);
}

.field-group textarea { resize: vertical; }

.field-group small {
  display: block;
  font-size: 11px;
  color: var(--color-muted);
  margin-top: 5px;
  line-height: 1.4;
}

.field-group input[type="range"] {
  width: 100%;
  accent-color: var(--color-accent);
}

.field-row {
  display: flex;
  gap: 12px;
}
.field-row .field-group { flex: 1; }

/* ─── Color fields ─────────────────────────────────────────────────────────── */
.color-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-field input[type="color"] {
  width: 38px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  background: #fff;
  flex-shrink: 0;
}

.hex-input {
  flex: 1;
  font-family: "SF Mono", "Fira Code", monospace !important;
  font-size: 13px !important;
  letter-spacing: .5px;
}

/* ─── Font toggle ──────────────────────────────────────────────────────────── */
.font-toggle {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.font-btn {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-ui);
  color: var(--color-muted);
  transition: border-color .15s, background .15s, color .15s;
  text-align: left;
  display: flex;
  flex-direction: column;
}

.font-btn span {
  font-size: 10px;
  color: var(--color-muted);
  margin-top: 2px;
  opacity: .7;
}

.font-btn.active {
  border-color: var(--color-accent);
  background: rgba(67,97,238,.06);
  color: var(--color-accent);
  font-weight: 600;
}

/* ─── Template cards ───────────────────────────────────────────────────────── */
.template-grid {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
}

.template-card {
  flex: 1;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  padding: 8px 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color .15s, box-shadow .15s;
  font-size: 11px;
  color: var(--color-muted);
  font-family: var(--font-ui);
}

.template-card:hover { border-color: #93c5fd; }
.template-card.active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(67,97,238,.12);
  color: var(--color-accent);
  font-weight: 600;
}

.template-thumb {
  width: 80px;
  height: 54px;
  background: #f8f9fa;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

/* T1 — Clean Minimal */
.t1 .th-name  { height: 7px; background: #1a1a2e; border-radius: 3px; width: 65%; }
.t1 .th-title { height: 4px; background: #ccc;    border-radius: 3px; width: 85%; }
.t1 .th-hr    { height: 1px; background: #e0e0e0; margin: 2px 0; }
.t1 .th-contact { height: 3px; background: #ccc; border-radius: 3px; width: 90%; }

/* T2 — Left Bar */
.t2 { flex-direction: row; padding: 0; }
.t2 .th-bar {
  border-left: 3px solid var(--color-accent);
  padding: 6px 4px 6px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.t2 .th-name    { height: 7px; background: #1a1a2e; border-radius: 3px; width: 55px; }
.t2 .th-title   { height: 4px; background: #ccc;    border-radius: 3px; width: 50px; }
.t2 .th-contact { height: 3px; background: #ccc;    border-radius: 3px; width: 45px; }

/* T3 — Classic Split */
.t3 {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.t3 .th-logo-box  { width: 22px; height: 22px; background: #e5e7eb; border-radius: 3px; flex-shrink: 0; }
.t3 .th-divider   { width: 1px; height: 36px; background: #e0e0e0; flex-shrink: 0; }
.t3 .th-right     { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.t3 .th-name      { height: 6px; background: #1a1a2e; border-radius: 3px; }
.t3 .th-title     { height: 4px; background: #ccc;    border-radius: 3px; }
.t3 .th-contact   { height: 3px; background: #ccc;    border-radius: 3px; }

/* ─── Social rows ──────────────────────────────────────────────────────────── */
.social-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}

.social-platform {
  flex: 0 0 130px;
  padding: 7px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-ui);
  background: #fff;
  outline: none;
  cursor: pointer;
}
.social-platform:focus { border-color: var(--color-accent); }

.social-url {
  flex: 1;
  padding: 7px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-ui);
  outline: none;
}
.social-url:focus { border-color: var(--color-accent); }

.social-remove {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.social-remove:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

.add-social-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  border: 1px dashed var(--color-border);
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  font-family: var(--font-ui);
  color: var(--color-muted);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  text-align: center;
}
.add-social-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: rgba(67,97,238,.04);
}

/* ─── Preview panel ────────────────────────────────────────────────────────── */
.preview-panel {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.preview-panel::-webkit-scrollbar { width: 6px; }
.preview-panel::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.preview-header h2 {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
}

.copy-actions {
  display: flex;
  gap: 10px;
}

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary {
  padding: 9px 18px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  border: none;
  transition: all .15s;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(67,97,238,.35);
}
.btn-primary:hover { background: var(--color-accent-dk); box-shadow: 0 2px 6px rgba(67,97,238,.4); }
.btn-primary:active { transform: translateY(1px); }

.btn-secondary {
  background: #fff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: #f9fafb; border-color: #9ca3af; }

/* ─── Preview window ───────────────────────────────────────────────────────── */
.preview-window {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.email-chrome {
  background: #f0f0f0;
  border-bottom: 1px solid var(--color-border);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chrome-dots {
  display: flex;
  gap: 6px;
}
.chrome-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ddd;
  display: block;
}
.chrome-dots span:nth-child(1) { background: #f87171; }
.chrome-dots span:nth-child(2) { background: #fbbf24; }
.chrome-dots span:nth-child(3) { background: #34d399; }

.chrome-label {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 500;
}

.preview-body {
  padding: 32px 36px;
  min-height: 160px;
}

#signature-preview {
  display: inline-block;
}

/* ─── Copy feedback ────────────────────────────────────────────────────────── */
.copy-feedback {
  font-size: 13px;
  font-weight: 500;
  padding: 0;
  min-height: 20px;
  transition: opacity .2s;
}
.copy-feedback.success { color: var(--color-success); }
.copy-feedback.error   { color: var(--color-error); }

/* ─── Instructions card ────────────────────────────────────────────────────── */
.instructions-card {
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.instructions-toggle {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafafa;
  border-bottom: 1px solid var(--color-border);
  text-transform: none;
  letter-spacing: 0;
}

.instructions-card .section-body {
  padding: 0;
}
.instructions-card.open .section-body { display: block; }
.instructions-card .section-body { display: none; }
.instructions-card.open .chevron { transform: rotate(180deg); }

.instructions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.instruction-block {
  padding: 18px 22px;
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}
.instruction-block:nth-child(even) { border-right: none; }
.instruction-block:nth-last-child(-n+2) { border-bottom: none; }

.instruction-block h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 10px;
}

.instruction-block ol {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.instruction-block li {
  font-size: 12px;
  color: var(--color-muted);
  line-height: 1.45;
}

.instruction-block strong { color: var(--color-text); }
.instruction-block em     { color: var(--color-muted); }

kbd {
  display: inline-block;
  padding: 1px 5px;
  font-family: var(--font-ui);
  font-size: 11px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  color: var(--color-text);
}

/* ─── Brand divider ────────────────────────────────────────────────────────── */
.brand-divider {
  border-top: 1px solid var(--color-border);
  margin: 16px 0 4px;
}

/* ─── Toggle switch ────────────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.toggle-row .toggle-label { flex: 1; }

.toggle-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted);
  cursor: pointer;
  user-select: none;
}

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #d1d5db;
  border-radius: 20px;
  transition: background .2s;
}

.switch .slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.switch input:checked + .slider { background: var(--color-accent); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* ─── Mobile (≤768px) ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Natural page scroll */
  html, body { height: auto; min-height: 100%; display: block; overflow: visible; }

  main {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  /* Form panel: full width, stacks above preview */
  .form-panel {
    width: 100%;
    min-width: 0;
    overflow-y: visible;
    padding-bottom: 20px;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  /* Preview panel: full width below form */
  .preview-panel {
    overflow-y: visible;
    padding: 20px;
  }

  /* Header: stack to single column — logo top, page name, ← All Apps */
  header {
    grid-template-columns: 1fr;
    padding: 14px 20px;
    gap: 6px;
    text-align: center;
  }
  .header-logo    { order: -1; justify-self: center; }
  .header-inner   { order: 0; }
  .header-all-apps { order: 1; justify-self: center; }
  .header-inner p { display: block; font-size: 11px; }
  .header-inner h1 { font-size: 16px; }

  /* Copy buttons: wrap onto second row if needed */
  .copy-actions { flex-wrap: wrap; }

  /* Instructions: single column */
  .instructions-grid { grid-template-columns: 1fr; }
  .instruction-block { border-right: none; }
  .instruction-block:nth-last-child(-n+2) { border-bottom: 1px solid var(--color-border); }
  .instruction-block:last-child { border-bottom: none; }

}
