/**
 * Email Signature Builder — UI Stylesheet
 * CertifID EMD Tools
 *
 * Dependencies: Inter (Google Fonts), Thicccboi (@font-face in HTML), Tabler Icons
 * Used by: index.html (builder interface)
 *
 * Sections:
 *   1. Design Tokens
 *   2. Reset & Base
 *   3. Control Panel (Sidebar)
 *   4. Panel Header & Scrollable
 *   5. Sections & Form Fields
 *   6. Color Picker
 *   7. Variant & CTA Selectors
 *   8. Photo Upload
 *   9. Link Input
 *  10. Action Footer & Split Copy Button
 *  11. Main Content & Preview Area
 *  12. Content Cards
 *  13. Install Tabs & Instructions
 *  14. Toast Notification
 *  15. Responsive — Tablet (≤1024px)
 *  16. Responsive — Mobile (≤480px)
 */


/* ──────────────────────────────────────────────
   1. Design Tokens
   ────────────────────────────────────────────── */

:root {
  /* Brand HSL base */
  --brand-h: 216;
  --brand-s: 79%;
  --brand-l: 48%;

  /* Semantic colors */
  --c-primary:       hsl(var(--brand-h), var(--brand-s), var(--brand-l));
  --c-primary-hover: hsl(var(--brand-h), var(--brand-s), 40%);
  --c-primary-light: hsl(var(--brand-h), 50%, 72%);
  --c-primary-wash:  hsl(var(--brand-h), 50%, 96%);

  /* Interaction */
  --c-focus-border:  hsl(var(--brand-h), 50%, 82%);
  --c-focus-ring:    hsl(var(--brand-h), var(--brand-s), 94%);
  --c-focus-ring-sm: hsl(var(--brand-h), var(--brand-s), 92%);

  /* Text hierarchy */
  --t-dark:   hsl(var(--brand-h), 28%, 16%);
  --t-medium: hsl(var(--brand-h), 7%, 34%);
  --t-light:  hsl(var(--brand-h), 7%, 46%);

  /* Surfaces & borders */
  --s-white:  #ffffff;
  --s-light:  hsl(var(--brand-h), 12%, 97%);
  --s-border: hsl(var(--brand-h), 10%, 91%);

  /* Toast (success) */
  --toast-bg:     hsl(145, 55%, 93%);
  --toast-text:   hsl(145, 50%, 30%);
  --toast-border: hsl(145, 40%, 82%);
  --toast-icon:   hsl(145, 50%, 36%);

  /* Typography */
  --font-heading: 'Thicccboi', system-ui, sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'SF Mono', 'Fira Code', monospace;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;

  /* Spacing (panel) */
  --panel-w:   360px;
  --panel-pad: 32px;

  /* Shadows */
  --shadow-panel: 8px 0 25px rgba(0, 0, 0, 0.05);
  --shadow-card:  0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-toast: 0 4px 16px rgba(0, 0, 0, 0.08);

  /* Transitions */
  --ease-fast: 0.15s ease;
  --ease-base: 0.2s ease;

  /* Preview area */
  --preview-w: 660px;
}


/* ──────────────────────────────────────────────
   2. Reset & Base
   ────────────────────────────────────────────── */

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

body {
  font-family: var(--font-body);
  background: var(--s-white);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}


/* ──────────────────────────────────────────────
   3. Control Panel (Sidebar)
   ────────────────────────────────────────────── */

.control-panel {
  width: var(--panel-w);
  height: 100vh;
  background: var(--s-white);
  border-right: 1px solid var(--s-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-panel);
}


/* ──────────────────────────────────────────────
   4. Panel Header & Scrollable
   ────────────────────────────────────────────── */

.panel-header {
  padding: 36px var(--panel-pad) var(--panel-pad);
  border-bottom: 1px solid var(--s-border);
  animation: builderSlideDown 0.12s ease-out;
  animation-fill-mode: backwards;
}

.panel-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  color: var(--c-primary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.panel-back-link:hover {
  color: var(--c-primary-hover);
}

.logo-mark {
  width: 32px;
  height: 32px;
  margin-bottom: 16px;
}

.logo-mark img {
  width: 100%;
  height: 100%;
}

.panel-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--t-dark);
  margin-bottom: 4px;
}

.panel-subtitle {
  font-size: 13px;
  color: var(--t-light);
  font-weight: 400;
  letter-spacing: -0.01em;
}

.panel-aux-links {
  margin-top: 14px;
}

.panel-aux-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--t-medium);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}

.panel-aux-link:hover {
  color: var(--c-primary);
}

.panel-scrollable {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.panel-scrollable::-webkit-scrollbar {
  display: none;
}

.panel-content {
  padding: 0 var(--panel-pad) var(--panel-pad);
}


/* ──────────────────────────────────────────────
   5. Sections & Form Fields
   ────────────────────────────────────────────── */

.section {
  padding: 24px 0;
  border-bottom: 1px solid var(--s-border);
  animation: builderSlideDown 0.22s ease-out;
  animation-fill-mode: backwards;
}

.section:last-child {
  border-bottom: none;
}

.section:nth-child(1) { animation-delay: 0.10s; }
.section:nth-child(2) { animation-delay: 0.15s; }
.section:nth-child(3) { animation-delay: 0.20s; }
.section:nth-child(4) { animation-delay: 0.25s; }
.section:nth-child(5) { animation-delay: 0.30s; }
.section:nth-child(6) { animation-delay: 0.35s; }

.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--t-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

.form-field {
  margin-bottom: 16px;
}

.form-field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--t-medium);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--s-border);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--s-white);
  transition: border-color var(--ease-base), box-shadow var(--ease-base);
}

.form-input:hover {
  border-color: var(--c-primary-light);
}

.form-input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-focus-ring-sm);
}

.form-input--mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}


/* ──────────────────────────────────────────────
   6. Color Picker
   ────────────────────────────────────────────── */

.color-input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--s-border);
  border-radius: var(--r-sm);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all var(--ease-fast);
  flex-shrink: 0;
}

.color-button:hover {
  border-color: var(--c-primary);
  transform: scale(1.05);
}

.color-picker-input {
  position: absolute;
  width: 200%;
  height: 200%;
  top: -50%;
  left: -50%;
  cursor: pointer;
  border: none;
}


/* ──────────────────────────────────────────────
   7. Variant Selector
   ────────────────────────────────────────────── */

.variant-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.variant-grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.variant-option {
  position: relative;
}

.variant-option input[type="radio"] {
  position: absolute;
  opacity: 0;
}

.variant-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border: 1.5px solid var(--s-border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--ease-base), box-shadow var(--ease-base), background var(--ease-base);
}

.variant-option input:checked + .variant-tile {
  border-color: var(--c-primary);
  background: var(--c-primary-wash);
  box-shadow: 0 0 0 3px var(--c-focus-ring);
}

.variant-tile:hover {
  border-color: var(--c-focus-border);
}

.variant-thumb {
  width: 100%;
  height: 46px;
  border-radius: 4px;
  background: var(--s-border);
  overflow: hidden;
}

.variant-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--t-medium);
  text-align: center;
}

.variant-option input:checked + .variant-tile .variant-name {
  color: var(--c-primary);
}

/* Variant thumbnails — shared */
.vt-photo { background: #cbd5e1; flex-shrink: 0; }
.vt-line  { background: #e2e8f0; }
.vt-line.dark { background: #94a3b8; }
.vt-line--w32 { width: 32px; }
.vt-line--w20 { width: 20px; }

/* Minimal thumbnail — compact one-liner */
.vt-minimal { display: flex; align-items: center; padding: 8px 5px; gap: 4px; background: white; height: 100%; border: 1px solid #e2e8f0; border-radius: 4px; }
.vt-minimal .vt-photo { width: 16px; height: 16px; border-radius: 50%; }
.vt-minimal .vt-line  { height: 3px; border-radius: 2px; flex-shrink: 0; }

/* Simple thumbnail — 3-col with CTA button */
.vt-simple { display: flex; align-items: center; padding: 6px; gap: 4px; background: white; height: 100%; border: 1px solid #e2e8f0; border-radius: 4px; }
.vt-simple .vt-photo { width: 22px; height: 22px; border-radius: 50%; }
.vt-simple .vt-lines { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.vt-simple .vt-line  { height: 3px; border-radius: 2px; }
.vt-simple .vt-line.dark { width: 70%; }
.vt-simple .vt-cta   { width: 20px; height: 10px; background: var(--c-primary); border-radius: 6px; flex-shrink: 0; }

/* Card thumbnail — accent bar + bordered card */
.vt-card { display: flex; align-items: center; background: white; height: 100%; border: 1px solid #e2e8f0; border-radius: 4px; overflow: hidden; }
.vt-card .vt-bar   { width: 3px; height: 100%; background: linear-gradient(180deg, #156EBC, #0d1b2e); flex-shrink: 0; }
.vt-card .vt-inner { flex: 1; display: flex; align-items: center; padding: 4px 5px; gap: 3px; }
.vt-card .vt-photo { width: 16px; height: 16px; border-radius: 50%; }
.vt-card .vt-mid   { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.vt-card .vt-line  { height: 2px; border-radius: 1px; }
.vt-card .vt-line.dark { width: 80%; }
.vt-card .vt-right { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.vt-card .vt-btn   { width: 18px; height: 7px; background: var(--c-primary); border-radius: 4px; }

/* Banner thumbnail — card top + colored footer */
.vt-banner { display: flex; flex-direction: column; background: white; height: 100%; border: 1px solid #e2e8f0; border-radius: 4px; overflow: hidden; }
.vt-banner .vt-top { flex: 1; display: flex; align-items: center; padding: 5px; gap: 4px; }
.vt-banner .vt-photo { width: 14px; height: 14px; border-radius: 50%; }
.vt-banner .vt-lines { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.vt-banner .vt-line  { height: 2px; border-radius: 1px; }
.vt-banner .vt-line.dark { width: 70%; }
.vt-banner .vt-footer { height: 10px; background: var(--c-primary); }

/* CTA module tile icons */
.cta-tile-icon {
  font-size: 20px;
  line-height: 1;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--t-light);
}
.cta-option input:checked + .variant-tile .cta-icon--emd   { color: var(--c-primary); }
.cta-option input:checked + .variant-tile .cta-icon--fraud  { color: #b45309; }
.cta-option input:checked + .variant-tile .cta-icon--trust  { color: #059669; }

/* CTA module color accents */
.cta-option input[value="emd"]:checked + .variant-tile {
  border-color: var(--c-primary);
  background: var(--c-primary-wash);
  box-shadow: 0 0 0 3px var(--c-focus-ring);
}
.cta-option input[value="emd"]:checked + .variant-tile .variant-name { color: var(--c-primary); }

.cta-option input[value="fraud"]:checked + .variant-tile {
  border-color: #b45309;
  background: #fffbeb;
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.1);
}
.cta-option input[value="fraud"]:checked + .variant-tile .variant-name { color: #b45309; }

.cta-option input[value="trust"]:checked + .variant-tile {
  border-color: #059669;
  background: #ecfdf5;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}
.cta-option input[value="trust"]:checked + .variant-tile .variant-name { color: #059669; }



/* ──────────────────────────────────────────────
   8. Photo Upload
   ────────────────────────────────────────────── */

.photo-upload-area {
  border: 1.5px dashed var(--s-border);
  border-radius: var(--r-sm);
  padding: 18px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--ease-base), background var(--ease-base);
  position: relative;
  overflow: hidden;
}

.photo-upload-area:hover {
  border-color: var(--c-primary);
  background: var(--c-primary-wash);
}

.photo-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-upload-icon {
  width: 36px;
  height: 36px;
  background: var(--c-primary-wash);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
  color: var(--c-primary);
  font-size: 18px;
}

.photo-upload-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--t-medium);
}

.photo-upload-sub {
  font-size: 11px;
  color: var(--t-light);
  margin-top: 3px;
}

.photo-preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--s-border);
  border-radius: var(--r-sm);
  background: var(--s-light);
}

.photo-thumb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.logo-thumb {
  width: 96px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--s-border);
  padding: 4px;
  flex-shrink: 0;
}

.photo-filename {
  font-size: 12px;
  color: var(--t-medium);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-remove {
  background: none;
  border: none;
  color: var(--t-light);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px;
  transition: color var(--ease-fast);
  display: flex;
  align-items: center;
}

.photo-remove:hover {
  color: #e11d48;
}


/* ──────────────────────────────────────────────
   9. Link Input
   ────────────────────────────────────────────── */

.link-input-wrapper {
  position: relative;
}

.link-input-wrapper input {
  padding-right: 34px;
}

.link-badge {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-primary);
  font-size: 15px;
  pointer-events: none;
  display: flex;
  align-items: center;
}


/* ──────────────────────────────────────────────
   10. Action Footer & Split Copy Button
   ────────────────────────────────────────────── */

.action-footer {
  padding: var(--panel-pad);
  border-top: 1px solid var(--s-border);
  flex-shrink: 0;
  animation: builderSlideDown 0.3s ease-out;
  animation-delay: 0.18s;
  animation-fill-mode: backwards;
}

/* Split copy button */
.copy-split {
  display: flex;
  width: 100%;
  position: relative;
}

.copy-main {
  flex: 1;
  padding: 13px 20px;
  background: var(--c-primary);
  color: white;
  border: none;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--ease-base), transform var(--ease-fast);
}

.copy-main:hover {
  background: var(--c-primary-hover);
}

.copy-icon {
  width: 18px;
  height: 18px;
}

.copy-toggle {
  width: 40px;
  background: var(--c-primary);
  color: white;
  border: none;
  border-left: 1px solid rgba(255,255,255,0.2);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background var(--ease-base);
}

.copy-toggle:hover {
  background: var(--c-primary-hover);
}

.copy-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--s-border);
  border-radius: var(--r-sm);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
  display: none;
  overflow: hidden;
  z-index: 200;
}

.copy-menu.open {
  display: block;
}

.copy-menu-item {
  width: 100%;
  padding: 11px 16px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--t-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--ease-fast);
}

.copy-menu-item:hover {
  background: var(--s-light);
}

.copy-menu-item + .copy-menu-item {
  border-top: 1px solid var(--s-border);
}

.copy-menu-icon {
  width: 18px;
  height: 18px;
}


/* ──────────────────────────────────────────────
   11. Main Content & Preview Area
   ────────────────────────────────────────────── */

.main-content {
  flex: 1;
  margin-left: var(--panel-w);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.preview-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--s-light);
  padding: 40px;
  animation: builderSlideDown 0.5s ease-out;
  animation-fill-mode: backwards;
}

.preview-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: var(--preview-w);
}

@keyframes builderSlideDown {
  0%   { opacity: 0; transform: translateY(-10px); }
  100% { opacity: 1; transform: translateY(0); }
}


/* ──────────────────────────────────────────────
   12. Content Cards
   ────────────────────────────────────────────── */

.content-card {
  width: 100%;
  max-width: 600px;
  background: var(--s-white);
  border-radius: var(--r-md);
  border: 1px solid var(--s-border);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.content-card--preview {
  padding: 28px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.card-header--preview {
  margin-bottom: 20px;
}

.card-header i {
  font-size: 16px;
  color: var(--c-primary);
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--t-light);
}


/* ──────────────────────────────────────────────
   13. Install Tabs & Instructions
   ────────────────────────────────────────────── */

.install-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  background: var(--s-light);
  border-radius: var(--r-sm);
  padding: 3px;
}

.install-tab {
  flex: 1;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--t-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--ease-fast);
}

.install-tab:hover {
  color: var(--t-medium);
}

.install-tab.active {
  background: white;
  color: var(--t-dark);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.install-tab-icon {
  width: 14px;
  height: 14px;
}

.instructions-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.instructions-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--t-medium);
}

.step-num {
  width: 20px;
  height: 20px;
  background: var(--c-primary-wash);
  color: var(--c-primary);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}


/* ──────────────────────────────────────────────
   14. Toast Notification
   ────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 12px 20px;
  border-radius: var(--r-sm);
  border: 1px solid var(--toast-border);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-toast);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 9999;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast i {
  font-size: 17px;
  color: var(--toast-icon);
}


/* ──────────────────────────────────────────────
   15. Responsive — Tablet (≤1024px)
   ────────────────────────────────────────────── */

@media (max-width: 1024px) {
  :root {
    --panel-w: 300px;
    --panel-pad: 24px;
    --preview-w: 100%;
  }

  .panel-header {
    padding: 28px var(--panel-pad) 24px;
  }

  .preview-area {
    padding: 24px;
  }
}


/* ──────────────────────────────────────────────
   16. Responsive — Mobile (≤480px)
   ────────────────────────────────────────────── */

@media (max-width: 480px) {
  body {
    flex-direction: column;
    overflow: auto;
  }

  .control-panel {
    position: relative;
    width: 100%;
    height: auto;
    max-height: none;
    box-shadow: none;
    border-right: none;
    border-bottom: 1px solid var(--s-border);
  }

  .panel-scrollable {
    overflow-y: visible;
  }

  .main-content {
    margin-left: 0;
    height: auto;
    min-height: 60vh;
  }

  .preview-area {
    padding: 20px 16px;
  }

  .action-footer {
    padding: 20px var(--panel-pad);
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    justify-content: center;
  }
}
