/* =========================================================
   SIGNIT — Email Signature Manager
   Design: Editorial / Refined Utilitarian
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f5f3ef;
  --surface:   #ffffff;
  --border:    #e2ddd6;
  --text:      #1a1814;
  --muted:     #7a746b;
  --accent:    #800020;
  --accent-lt: #fdf0f3;
  --green:     #1a6b45;
  --green-lt:  #edf7f2;
  --danger:    #c0392b;
  --mono:      'DM Mono', monospace;
  --serif:     'DM Serif Display', Georgia, serif;
  --sans:      'DM Sans', sans-serif;
  --radius:    6px;
  --shadow:    0 2px 12px rgba(26,24,20,.08);
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* ── NAV ── */
.nav {
  background: var(--text);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-family: var(--serif);
  font-size: 1.3rem;
  color: #fff;
  text-decoration: none;
  letter-spacing: .02em;
}
.nav-brand span { color: var(--accent); }
.nav-spacer { flex: 1; }
.nav a.btn-nav {
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #fff;
  text-decoration: none;
  padding: .45rem 1.1rem;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius);
  transition: background .15s, border-color .15s;
}
.nav a.btn-nav:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.4); }
.nav a.btn-nav.primary { background: var(--accent); border-color: var(--accent); }
.nav a.btn-nav.primary:hover { background: #9a0028; border-color: #9a0028; }

/* ── LAYOUT ── */
.container { max-width: 1000px; margin: 0 auto; padding: 2.5rem 1.5rem; }
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-family: var(--serif); font-size: 2rem; font-weight: 400; }
.page-header p { color: var(--muted); font-size: .9rem; margin-top: .3rem; }

/* ── CARDS / TABLE ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.sig-table { width: 100%; border-collapse: collapse; }
.sig-table th {
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: .9rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: #faf9f7;
}
.sig-table td {
  padding: .85rem 1.2rem;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  vertical-align: middle;
}
.sig-table tr:last-child td { border-bottom: none; }
.sig-table tr:hover td { background: #faf9f7; }

.sig-name { font-weight: 600; color: var(--text); }
.sig-title { font-size: .8rem; color: var(--muted); margin-top: 1px; }

.avatar-sm {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
  display: block;
}
.avatar-placeholder {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: var(--muted);
}

.actions { display: flex; gap: .5rem; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: var(--sans); font-size: .8rem; font-weight: 500;
  padding: .42rem .9rem; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
  text-decoration: none; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #9a0028; border-color: #9a0028; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: transparent; color: var(--danger); border-color: #f5c6c3; }
.btn-danger:hover { background: #fdf3f2; }
.btn-green { background: var(--green); color: #fff; border-color: var(--green); }
.btn-green:hover { background: #155a39; }

/* ── FORM ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem 1.5rem;
  padding: 1.8rem;
}
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group.full { grid-column: 1 / -1; }
.form-group label {
  font-size: .75rem; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
}
.form-group input, .form-group select {
  font-family: var(--sans); font-size: .9rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .6rem .85rem;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(128,0,32,.08);
}
.form-group .hint { font-size: .76rem; color: var(--muted); }

.form-actions {
  display: flex; gap: 1rem; align-items: center;
  padding: 1.2rem 1.8rem;
  border-top: 1px solid var(--border);
  background: #faf9f7;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── AVATAR UPLOAD ── */
.avatar-upload-area {
  display: flex; align-items: center; gap: 1.2rem;
}
.avatar-preview-wrap {
  width: 72px; height: 72px; border-radius: 50%;
  border: 2px solid var(--border); overflow: hidden;
  background: var(--bg); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; color: var(--muted); text-align: center;
}
.avatar-preview-wrap img { width: 100%; height: 100%; object-fit: cover; }
.avatar-upload-right { display: flex; flex-direction: column; gap: .5rem; }
#avatar-url-field { font-family: var(--mono); font-size: .78rem; }

/* ── COLOR SWATCH ── */
.color-row { display: flex; align-items: center; gap: .8rem; }
.color-row input[type=color] {
  width: 40px; height: 40px; padding: 2px; border-radius: 6px;
  cursor: pointer; background: var(--bg);
}
.color-row input[type=text] { width: 110px; font-family: var(--mono); font-size: .85rem; }

/* ── PREVIEW PANEL ── */
.preview-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.preview-label {
  font-size: .72rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 1rem;
}
.preview-email-bg {
  background: #f8f8f8; border: 1px solid #e8e8e8;
  border-radius: 4px; padding: 1.5rem;
}

.code-box {
  background: #1a1814;
  color: #d4c9bc;
  font-family: var(--mono);
  font-size: .75rem;
  border-radius: var(--radius);
  padding: 1.2rem;
  overflow-x: auto;
  max-height: 280px;
  overflow-y: auto;
  line-height: 1.7;
  white-space: pre;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center; padding: 4rem 2rem;
  color: var(--muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; opacity: .4; }
.empty-state h3 { font-family: var(--serif); font-weight: 400; font-size: 1.3rem; color: var(--text); margin-bottom: .5rem; }

/* ── FLASH ── */
.flash {
  padding: .8rem 1.2rem; border-radius: var(--radius);
  font-size: .88rem; margin-bottom: 1.5rem;
  display: flex; align-items: center; gap: .6rem;
}
.flash.success { background: var(--green-lt); color: var(--green); border: 1px solid #b6e4ce; }
.flash.error   { background: #fdf3f2; color: var(--danger); border: 1px solid #f5c6c3; }

/* ── SECTION DIVIDER ── */
.section-title {
  font-size: .72rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  padding: .9rem 1.8rem .5rem;
  border-top: 1px solid var(--border);
  margin-top: .5rem;
}
.section-title:first-child { border-top: none; margin-top: 0; }

/* ── TABS ── */
.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: #faf9f7;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
}
button.tab-btn {
  -webkit-appearance: none;
  appearance: none;
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  border: none;
  outline: none;
  background: transparent;
  color: var(--muted);
  padding: .85rem 1.15rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s, background .15s;
  white-space: nowrap;
}
button.tab-btn:hover   { color: var(--text); background: rgba(0,0,0,.03); }
button.tab-btn.active  { color: var(--accent); border-bottom-color: var(--accent); background: var(--surface); }

.tab-panel       { display: none; }
.tab-panel.active{ display: block; }

/* ── EXTRA FIELD ROWS ── */
.extra-field-row {
  display: flex;
  gap: .6rem;
  align-items: center;
  margin-bottom: .6rem;
}
.extra-field-row .ef-name  { flex: 1.2; }
.extra-field-row .ef-value { flex: 2; }
.extra-field-row .ef-type  {
  flex: 0 0 90px;
  font-family: var(--sans); font-size: .85rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .55rem .6rem;
}
.extra-field-row input {
  font-family: var(--sans); font-size: .85rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .55rem .75rem;
}

/* ── SOCIAL ROWS ── */
.social-row {
  display: flex;
  gap: .6rem;
  align-items: center;
  margin-bottom: .6rem;
}
.social-row .social-platform {
  flex: 0 0 160px;
  font-family: var(--sans); font-size: .85rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .55rem .6rem;
}
.social-row .social-url {
  flex: 1;
  font-family: var(--sans); font-size: .85rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .55rem .75rem;
}

/* ── ADDON CARDS ── */
.addon-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  margin-bottom: .9rem;
  overflow: hidden;
}
.addon-head {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .7rem .9rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.addon-toggle {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .9rem;
}
.addon-toggle input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--accent);
}
.addon-hint {
  font-size: .76rem;
  color: var(--muted);
}
.addon-body {
  padding: .8rem .9rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.addon-body input,
.addon-body textarea {
  font-family: var(--sans); font-size: .85rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .55rem .75rem;
  width: 100%; box-sizing: border-box;
  resize: vertical;
}
.badge-row {
  display: flex; gap: .5rem; margin-bottom: .5rem; align-items: center;
}
.badge-row input { flex: 1; }
.badge-row .badge-alt { flex: 0 0 110px; }

/* ── TEMPLATE PICKER ── */
.tpl-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: .55rem;
}
.tpl-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .15rem;
  padding: .65rem .75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s, box-shadow .15s;
  font-family: var(--sans);
}
.tpl-btn:hover { border-color: var(--muted); background: #fafaf7; }
.tpl-btn.active {
  border-color: var(--accent);
  background: var(--accent-lt);
  box-shadow: 0 0 0 2px rgba(128,0,32,.08);
}
.tpl-btn .tpl-num {
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--accent);
  line-height: 1;
}
.tpl-btn .tpl-name {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text);
}
.tpl-btn .tpl-desc {
  font-size: .68rem;
  color: var(--muted);
  line-height: 1.3;
}

/* ── EDITOR LAYOUT (create/edit pages) ── */
.editor-container { max-width: 1360px; }
.two-col {
  display: grid;
  grid-template-columns: minmax(480px, 1fr) minmax(560px, 1fr);
  gap: 2rem;
  align-items: start;
}
.sticky-preview { position: sticky; top: 72px; }
.preview-email-bg { overflow-x: auto; }

/* When the form column gets narrow, drop its inner grid to 1-col */
@media (max-width: 1180px) {
  .two-col .form-grid { grid-template-columns: 1fr; }
  .two-col .form-group.full { grid-column: 1; }
}
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: 1; }
  .nav { padding: 0 1rem; gap: 1rem; }
  .container { padding: 1.5rem 1rem; }
  .tpl-picker { grid-template-columns: repeat(2, 1fr); }
}
