/* ══════════════════════════════════════════════════════════
   Email Builder — the .et-* rule block extracted from the
   original admin.html panel. Tool-specific styling for the
   builder layout, color pickers, device mockups, and preview
   frames. Relies on CSS variables from css/brand.css.
   ══════════════════════════════════════════════════════════ */

/* Local alias variables so the extracted admin.html rules (which reference
   --bg-surface, --text-primary, etc. from the Mesh admin chrome) map cleanly
   to the AE brand.css token names. */
:root {
  --bg-page: var(--ae-grey-light);
  --bg-surface: var(--ae-white);
  --bg-muted: var(--ae-grey-light);
  --border: var(--ae-grey-border);
  --text-primary: var(--ae-text);
  --text-secondary: var(--ae-text-secondary);
  --text-muted: var(--ae-text-secondary);
  --text-faint: var(--ae-text-muted);
  --btn-primary-bg: var(--ae-purple);
  --btn-primary-color: var(--ae-white);
  --btn-primary-hover: 0.85;
  --shadow: rgba(38, 38, 38, 0.08);
}

/* ── Builder layout ── */
.et-builder-layout { display: flex; gap: 24px; align-items: flex-start; }
.et-panel-left { width: 340px; min-width: 340px; flex-shrink: 0; }
.et-panel-right { flex: 1; min-width: 0; }
@media (max-width: 900px) {
  .et-builder-layout { flex-direction: column; }
  .et-panel-left { width: 100%; min-width: 0; }
}

/* ── Sections ── */
.et-section { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--ae-radius-md); padding: 18px; margin-bottom: 12px; }
.et-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin-bottom: 12px; }
.et-field-row { margin-bottom: 12px; }
.et-field-row:last-child { margin-bottom: 0; }
.et-field-label { font-size: 12px; font-weight: 600; margin-bottom: 5px; display: block; color: var(--text-primary); }
.et-field-input { width: 100%; box-sizing: border-box; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; background: var(--bg-surface); color: var(--text-primary); outline: none; transition: border-color .15s; }
.et-field-input:focus { border-color: var(--ae-purple); }

/* ── Theme toggle ── */
.et-theme-toggle { display: flex; gap: 6px; }
.et-theme-btn { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg-surface); cursor: pointer; text-align: center; font-family: inherit; font-size: 11px; font-weight: 600; color: var(--text-muted); transition: all .15s; }
.et-theme-btn:hover { border-color: var(--ae-purple); }
.et-theme-btn.active { background: var(--ae-purple); color: var(--ae-white); border-color: var(--ae-purple); }

/* ── Color inputs (shared with any AE tool that uses a color picker) ── */
.color-swatch-input { -webkit-appearance: none; appearance: none; width: 36px; height: 30px; border: 1px solid var(--border); border-radius: 5px; cursor: pointer; padding: 0; overflow: hidden; background: transparent; flex-shrink: 0; }
.color-swatch-input::-webkit-color-swatch-wrapper { padding: 2px; }
.color-swatch-input::-webkit-color-swatch { border: none; border-radius: 3px; }
.color-swatch-input::-moz-color-swatch { border: none; border-radius: 3px; }
.color-hex-input { font-family: 'SF Mono', 'Cascadia Code', monospace; font-size: 11px; flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid var(--border); border-radius: 5px; color: var(--text-primary); background: var(--bg-surface); }
.color-hex-input:focus { outline: none; border-color: var(--ae-purple); }
.color-hex-input::placeholder { color: var(--text-faint); font-size: 10px; }

/* ── Logo upload area ── */
.et-logo-upload-area { border: 2px dashed var(--border); border-radius: 8px; padding: 20px; text-align: center; cursor: pointer; transition: all .15s; }
.et-logo-upload-area:hover { border-color: var(--ae-purple); background: var(--bg-muted); }
.et-logo-upload-label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.et-logo-upload-hint { font-size: 10px; color: var(--text-faint); margin-top: 2px; }

/* ── Reset pill ── */
.et-reset-pill { padding: 5px 14px; font-size: 11px; font-weight: 600; border: 1px solid #E8B4B4; border-radius: 5px; cursor: pointer; background: transparent; color: var(--ae-error); font-family: inherit; transition: all .12s; letter-spacing: .02em; }
.et-reset-pill:hover { background: var(--ae-error); color: #fff; border-color: var(--ae-error); }

/* ── Export button bar ── */
.et-export-bar { display: flex; gap: 8px; margin-bottom: 8px; }
.et-export-btn { flex: 1; padding: 10px 16px; border: none; border-radius: 8px; font-family: inherit; font-size: 12px; font-weight: 700; cursor: pointer; transition: all .15s; letter-spacing: .02em; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.et-export-btn-primary { background: var(--ae-purple); color: var(--ae-white); }
.et-export-btn-primary:hover { background: #4F43B5; }
.et-export-btn-secondary { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border); }
.et-export-btn-secondary:hover { background: var(--bg-muted); }

/* ── Template tabs ── */
.et-tabs { display: flex; gap: 0; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--ae-radius-md) var(--ae-radius-md) 0 0; overflow: hidden; }
.et-tab { flex: 1; padding: 12px 16px; border: none; background: none; cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 600; color: var(--text-muted); text-align: center; transition: all .15s; border-right: 1px solid var(--border); position: relative; }
.et-tab:last-child { border-right: none; }
.et-tab:hover { background: var(--bg-muted); color: var(--text-secondary); }
.et-tab.active { background: var(--bg-muted); color: var(--ae-purple); }
.et-tab.active::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: var(--ae-purple); }
.et-tab-label { display: block; font-size: 12px; font-weight: 700; }
.et-tab-sub { display: block; font-size: 10px; font-weight: 400; color: var(--text-faint); margin-top: 2px; }

/* ── Preview area ── */
.et-preview-wrap { background: var(--bg-surface); border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--ae-radius-md) var(--ae-radius-md); padding: 24px; min-height: 600px; }
.et-preview-inner { margin: 0 auto; }
.et-preview-wrap:has(.et-macbook-body), .et-preview-wrap:has(.et-iphone-body) { overflow: visible; }
.et-preview-wrap:has(.et-macbook-body) .et-preview-inner, .et-preview-wrap:has(.et-iphone-body) .et-preview-inner { overflow: visible; }

/* ── Device switcher ── */
.et-device-switcher { display: flex; gap: 4px; justify-content: center; margin-bottom: 16px; }
.et-device-btn { width: 36px; height: 32px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-surface); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .15s; color: var(--text-faint); }
.et-device-btn:hover { border-color: var(--ae-purple); color: var(--ae-purple); }
.et-device-btn.active { background: var(--ae-purple); color: var(--ae-white); border-color: var(--ae-purple); }
.et-device-btn svg { width: 16px; height: 16px; }

/* ── iPhone mockup ── */
.et-iphone-body { position: relative; width: 375px; margin: 0 auto; }
.et-iphone-shell-img { display: block; width: 100%; height: auto; pointer-events: none; -webkit-user-select: none; user-select: none; }
.et-iphone-screen-area { position: absolute; top: 3.73%; left: 7.67%; width: 84.66%; height: 92.53%; overflow: hidden; border-radius: 40px; background: #000; direction: ltr; }
.et-iphone-screen-inner { width: 100%; height: 100%; overflow: hidden; display: flex; flex-direction: column; }
.et-iphone-sbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px 8px; position: relative; z-index: 10; background: #000; flex-shrink: 0; }
.et-iphone-sbar-time { font-size: 14px; font-weight: 600; color: #fff; font-family: -apple-system, 'SF Pro Text', 'Aptos', system-ui, sans-serif; letter-spacing: -0.01em; }
.et-iphone-sbar-icons { display: flex; align-items: center; gap: 5px; }
.et-iphone-sbar-icons svg { width: 16px; height: 12px; }
.et-iphone-home-bar { display: flex; justify-content: center; padding: 8px 0 6px; flex-shrink: 0; }
.et-iphone-home-pill { width: 130px; height: 5px; background: #666; border-radius: 3px; }

/* ── iOS Mail chrome ── */
.et-ios-mail { display: flex; flex-direction: column; width: 100%; flex: 1; min-height: 0; font-family: -apple-system, 'SF Pro Text', 'Helvetica Neue', sans-serif; color: #fff; }
.et-ios-mail-nav { display: flex; align-items: center; padding: 6px 16px 8px; flex-shrink: 0; }
.et-ios-mail-nav-back { display: flex; align-items: center; gap: 2px; font-size: 16px; color: #007AFF; font-weight: 400; }
.et-ios-mail-nav-back svg { width: 20px; height: 20px; }
.et-ios-mail-nav-spacer { flex: 1; }
.et-ios-mail-nav-btn { color: #007AFF; margin-left: 16px; }
.et-ios-mail-nav-btn svg { width: 20px; height: 20px; }
.et-ios-mail-hdr { padding: 8px 16px 10px; flex-shrink: 0; }
.et-ios-mail-subject { font-size: 16px; font-weight: 600; color: #fff; margin: 0 0 6px; }
.et-ios-mail-meta-row { display: flex; align-items: center; gap: 8px; }
.et-ios-mail-avatar { width: 28px; height: 28px; border-radius: 50%; background: #007AFF; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: #fff; flex-shrink: 0; }
.et-ios-mail-from { font-size: 13px; font-weight: 600; color: #fff; }
.et-ios-mail-date { font-size: 11px; color: #8E8E93; margin-left: auto; }
.et-ios-mail-to { font-size: 11px; color: #8E8E93; margin-top: 2px; padding-left: 36px; }
.et-ios-mail-hdr-divider { height: 0.5px; background: #38383A; margin-top: 8px; }
.et-ios-mail-body { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; zoom: 0.8; }
.et-ios-mail-body .et-preview-inner { padding: 0; margin: 0; }
.et-ios-mail-body .et-preview-inner > div { max-width: 100% !important; margin: 0 !important; border-radius: 0 !important; }
/* ^ zoom shrinks all inner content (padding, font sizes, the OTP digit
   block) proportionally so a desktop-sized email card visually fits
   inside the ~317px iPhone screen area. Without this, templates
   designed for 600px desktop width overflow — especially the OTP
   template where font-size:36px + letter-spacing:0.3em on ${otp}
   blows past the narrow card. zoom is non-standard but works in
   Chromium/WebKit which is all we target for internal CS. Matches
   the pattern .et-macbook-screen-inner uses at zoom:0.55. */

/* ── MacBook mockup ── */
.et-macbook-body { position: relative; width: calc(100% - 24px); max-width: 700px; margin: 12px auto 0; }
.et-macbook-shell-img { display: block; width: 100%; height: auto; pointer-events: none; -webkit-user-select: none; user-select: none; }
.et-macbook-screen-area { position: absolute; top: 10.8%; left: 10.1%; width: 79.8%; height: 79.5%; overflow: hidden; border-radius: 12px 12px 0 0; background: #000; }
.et-macbook-screen-inner { width: 100%; height: 100%; overflow: hidden; background: #000; zoom: 0.55; display: flex; flex-direction: column; }

/* ── macOS Mail chrome ── */
.et-mac-mail { display: flex; flex-direction: column; width: calc(100% + 2px); height: calc(100% + 2px); margin: -1px; min-height: 0; font-family: -apple-system, 'SF Pro Text', 'Helvetica Neue', sans-serif; background: #1d1d1f; color: #1d1d1f; flex: 1; }
.et-mac-mail-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: linear-gradient(180deg, #f6f6f6 0%, #e8e8e8 100%); border-bottom: 1px solid #c8c8c8; min-height: 38px; flex-shrink: 0; }
.et-mac-mail-tl { display: flex; gap: 7px; align-items: center; margin-right: 12px; }
.et-mac-mail-tl-dot { width: 12px; height: 12px; border-radius: 50%; border: 0.5px solid rgba(0, 0, 0, .12); }
.et-mac-mail-tl-r { background: #FF5F57; }
.et-mac-mail-tl-y { background: #FEBC2E; }
.et-mac-mail-tl-g { background: #28C840; }
.et-mac-mail-tb-sep { width: 1px; height: 22px; background: #c8c8c8; margin: 0 4px; }
.et-mac-mail-tb-btn { display: flex; align-items: center; justify-content: center; width: 28px; height: 24px; border-radius: 4px; cursor: default; color: #555; }
.et-mac-mail-tb-btn:hover { background: rgba(0, 0, 0, .06); }
.et-mac-mail-tb-btn svg { width: 18px; height: 18px; }
.et-mac-mail-tb-spacer { flex: 1; }
.et-mac-mail-tb-search { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid #c8c8c8; border-radius: 6px; background: #fff; font-size: 12px; color: #999; min-width: 160px; height: 24px; }
.et-mac-mail-tb-search svg { width: 13px; height: 13px; color: #999; flex-shrink: 0; }
.et-mac-mail-hdr { padding: 16px 20px 14px; border-bottom: 1px solid #e0e0e0; background: #fafafa; }
.et-mac-mail-subject { font-size: 20px; font-weight: 600; color: #1d1d1f; margin: 0 0 10px; letter-spacing: -0.02em; }
.et-mac-mail-meta { display: flex; align-items: flex-start; gap: 10px; }
.et-mac-mail-avatar { width: 36px; height: 36px; border-radius: 50%; background: #007AFF; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; color: #fff; flex-shrink: 0; letter-spacing: 0.01em; }
.et-mac-mail-meta-info { flex: 1; min-width: 0; }
.et-mac-mail-from { font-size: 13px; font-weight: 600; color: #1d1d1f; }
.et-mac-mail-from-email { font-size: 11px; color: #86868b; font-weight: 400; margin-left: 4px; }
.et-mac-mail-to-date { display: flex; align-items: center; gap: 0; margin-top: 1px; }
.et-mac-mail-to { font-size: 11px; color: #86868b; }
.et-mac-mail-date { font-size: 11px; color: #86868b; margin-left: auto; white-space: nowrap; }
.et-mac-mail-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0; background: transparent; min-height: 0; }
.et-mac-mail-body .et-preview-inner { padding: 0; margin: 0; }
.et-mac-mail-body .et-preview-inner > div { max-width: 100% !important; margin: 0 !important; border-radius: 0 !important; }

/* ── Generic email frame (desktop preview, no device chrome) ── */
.et-frame-email { max-width: 680px; margin: 0 auto; border: 1px solid var(--border); border-radius: var(--ae-radius-md); overflow: hidden; background: var(--bg-surface); }
.et-frame-email-toolbar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--bg-muted); }
.et-frame-email-toolbar svg { width: 16px; height: 16px; color: var(--text-faint); }
.et-frame-email-toolbar-spacer { flex: 1; }
.et-frame-email-fields { padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 11px; color: var(--text-muted); line-height: 2; }
.et-frame-email-fields span { color: var(--text-faint); font-weight: 600; margin-right: 6px; }
.et-frame-email-body { overflow-y: auto; }
.et-preview-scale .et-frame-email { max-width: 100%; }
.et-preview-scale .et-frame-email-body { max-height: none; }
.et-preview-scale .et-preview-inner > div { max-width: 100% !important; }

/* ── Toast ── */
.et-toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: #111; color: #fff; padding: 9px 18px; border-radius: 100px; font-size: 11px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 9999; white-space: nowrap; }
.et-toast.show { opacity: 1; }
