/*
 * Lenovo Email Signature Builder — Plugin Stylesheet
 * Applies only to .app-body and its children.
 * Variables are declared on :root so they cascade into the signature output.
 *
 * --esb-header-h: Height of your WP theme's fixed header.
 *   Default: 80px (matches the Brandworld theme header).
 *   Override in your child theme's style.css if your header is a different height:
 *     :root { --esb-header-h: 96px; }
 */

:root {
  --esb-red:             #E2001A;
  --esb-black:           #1E0013;
  --esb-deep-gray:       #4E444E;
  --esb-mid-gray:        #ABA8B1;
  --esb-muted:           #8a8a8a;
  --esb-light:           #f4f4f4;
  --esb-lighter:         #fafafa;
  --esb-border:          #e0e0e0;
  --esb-border-strong:   #c8c8c8;
  --esb-border-selected: #353F47;
  --esb-white:           #ffffff;
  --esb-font-ui:         'Montserrat', sans-serif;
  --esb-radius:          4px;
  --esb-radius-lg:       8px;
  --esb-shadow-lg:       0 8px 32px rgba(0,0,0,0.12);
  --esb-header-h:        80px;
  --esb-deep-purple-1:   #4D144A;
  --esb-deep-purple-2:   #7A126B;
  --esb-pale-purple-1:   #D9C1D8;
  --esb-deep-blue-1:     #11184F;
  --esb-deep-blue-2:     #294E95;
  --esb-pale-blue-1:     #C9D0F0;
  --esb-pale-blue-2:     #EAEEF5;
}

/* ─── LAYOUT ──────────────────────────────────────────────────────────────── */

.app-body {
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: calc(100vh - var(--esb-header-h));
  align-items: start;
  font-family: var(--esb-font-ui);
  font-size: 16px;
  line-height: 1.5;
  color: var(--esb-deep-gray);
  background: var(--esb-light);
  /* margin-top, min-height overrides are in the ADMIN BAR OFFSET block above */
}

/* ─── FORM PANEL ──────────────────────────────────────────────────────────── */

.form-panel {
  background: var(--esb-light);
  border-right: 1px solid var(--esb-border);
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  /* min-height set in ADMIN BAR OFFSET block */
}

.form-section {
  background: var(--esb-white);
  overflow: hidden;
}

.form-section-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: var(--esb-white);
}
.form-section-header:hover { background: var(--esb-lighter); }

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--esb-black);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-dot { display: none; }

.section-chevron {
  width: 20px;
  height: 20px;
  position: relative;
  flex-shrink: 0;
  font-size: 0;
  color: transparent;
}
.section-chevron::before {
  content: '';
  display: block;
  width: 12px;
  height: 12px;
  border-right: 3px solid var(--esb-black);
  border-bottom: 3px solid var(--esb-black);
  transform: rotate(45deg);
  position: absolute;
  top: 3px;
  left: 6px;
  transition: transform 0.2s, top 0.2s;
}
.section-chevron.open::before {
  transform: rotate(-135deg);
  top: 7px;
}

.form-section-body {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
  transition: max-height 0.3s ease, padding-bottom 0.3s ease;
}
.form-section-body.collapsed {
  max-height: 0;
  padding-bottom: 0;
}

/* ─── ADMIN BAR OFFSET ────────────────────────────────────────────────────── */
/* WordPress adds margin-top: 32px to body when the admin bar is visible.
   The .app-body and .preview-panel sticky positioning need to account for
   both the admin bar AND the theme header. The plugin PHP injects
   --esb-adminbar-h via wp_add_inline_style when is_admin_bar_showing(). */

.app-body {
  margin-top: calc(var(--esb-header-h) + var(--esb-adminbar-h, 0px));
}
.preview-panel {
  top: calc(var(--esb-header-h) + var(--esb-adminbar-h, 0px));
  height: calc(100vh - var(--esb-header-h) - var(--esb-adminbar-h, 0px));
}
.form-panel {
  min-height: calc(100vh - var(--esb-header-h) - var(--esb-adminbar-h, 0px));
}

/* ─── FIELDS ──────────────────────────────────────────────────────────────── */

.app-body .field { display: flex; flex-direction: column; gap: 5px; }

.app-body .field label {
  font-size: 0.75em;
  line-height: 2;
  color: var(--esb-deep-gray) !important;
}

/* Override theme dark-mode input styles with high specificity + !important */
.app-body .field input[type=text],
.app-body .field input[type=email],
.app-body .field input[type=url],
.app-body .field input[type=tel] {
  width: 100% !important;
  padding: 8px 10px !important;
  border: 1px solid var(--esb-border-strong) !important;
  border-radius: var(--esb-radius) !important;
  font-family: var(--esb-font-ui) !important;
  font-size: 15px !important;
  color: var(--esb-deep-gray) !important;
  background: #ffffff !important;
  background-color: #ffffff !important;
  box-shadow: none !important;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none !important;
  box-sizing: border-box !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}
.app-body .field input:focus {
  border-color: var(--esb-deep-blue-2) !important;
  box-shadow: 0 0 0 2px rgba(41,78,149,0.12) !important;
  background: #ffffff !important;
}
.app-body .field input::placeholder {
  font-size: 13px !important;
  font-style: italic !important;
  color: #aaa !important;
  opacity: 1 !important;
}

.field-hint { font-size: 11px; color: var(--esb-deep-gray); font-style: italic; }
.field-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ─── LOGO SELECTOR ──────────────────────────────────────────────────────── */

.logo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

.logo-option {
  border: 1px solid var(--esb-border);
  border-radius: 0;
  padding: 5px;
  cursor: pointer;
  background: var(--esb-white);
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  max-height: 95px;
}
.logo-option:hover,
.logo-option.selected { border: 1px solid var(--esb-border-selected); background: #ffffff; }
.logo-option img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }

/* ─── TOGGLE ──────────────────────────────────────────────────────────────── */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}
.toggle-label { color: var(--esb-deep-gray); font-weight: 500; }

.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
  position: absolute; inset: 0;
  background: var(--esb-border-strong);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle input:checked + .toggle-track { background: var(--esb-deep-blue-2); }
.toggle input:focus-visible + .toggle-track {
  outline: 2px solid var(--esb-deep-blue-2);
  outline-offset: 2px;
}

.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(16px); }

/* ─── ACCESSIBILITY ───────────────────────────────────────────────────────── */

.app-body :focus-visible {
  outline: 2px solid var(--esb-deep-blue-2);
  outline-offset: 2px;
  border-radius: 2px;
}
.app-body :focus:not(:focus-visible) { outline: none; }
.form-section-header:focus-visible   { outline-offset: -2px; }
.logo-option:focus-visible           { outline-offset: 1px; }

/* ─── PREVIEW PANEL ──────────────────────────────────────────────────────── */

.preview-panel {
  display: flex;
  flex-direction: column;
  position: sticky;
  overflow-y: auto;
  background-color: var(--esb-white);
  /* top and height set in ADMIN BAR OFFSET block */
}

.preview-tabs {
  display: flex;
  gap: 4px;
  background: var(--esb-deep-purple-1);
  padding: 3px;
  border-radius: var(--esb-radius);
}

.tab-btn {
  font-family: var(--esb-font-ui);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--esb-pale-purple-1);
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}
.tab-btn:hover { color: var(--esb-white); }
.tab-btn.active {
  background: var(--esb-white);
  color: var(--esb-deep-purple-1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.tab-btn.active:hover { cursor: default; }

/* ─── BOTTOM BAR ─────────────────────────────────────────────────────────── */

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 30px;
  margin-top: auto;
  border-top: 1px solid var(--esb-border);
  background: var(--esb-white);
  position: sticky;
  bottom: 0;
  z-index: 10;
}
.preview-actions { display: flex; align-items: center; gap: 10px; }

.copy-btn {
  background-color: var(--esb-deep-blue-2);
  color: #fff;
  font-family: var(--esb-font-ui);
  font-size: 0.875em;
  font-weight: 400;
  line-height: 1;
  padding: 13px 22px;
  border-radius: var(--esb-radius);
  cursor: pointer;
  border: 1.5px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: background 0.15s;
}
.copy-btn:hover  { background-color: var(--esb-deep-blue-1); }
.copy-btn.disabled {
  background-color: var(--esb-deep-gray);
  cursor: not-allowed;
  opacity: 1;
}
.copy-icon { display: inline-flex; flex-shrink: 0; }

/* ─── PREVIEW CONTENT ────────────────────────────────────────────────────── */

.preview-content {
  padding: 32px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.email-chrome {
  background: var(--esb-white);
  border: 1px solid var(--esb-border);
  border-radius: var(--esb-radius-lg);
  box-shadow: var(--esb-shadow-lg);
  overflow: hidden;
  max-width: 720px;
  line-height: 1;
}
.email-sig-area { padding: 20px 24px; }

/* Reset theme's bold link styling inside the preview so it accurately
   reflects how the signature will render in Outlook / Gmail. */
.email-chrome a,
.email-sig-area a {
  font-weight: normal !important;
}

/* ─── INSTALL VIEW ───────────────────────────────────────────────────────── */

.install-view     { display: none; padding: 32px; max-width: 680px; }
.install-view h2  { font-size: 22px; font-weight: 700; color: var(--esb-deep-gray); margin-bottom: 0; }
.install-view h3  { font-size: 22px; font-weight: 400; margin-bottom: 8px; }
.install-steps    { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.install-step     { display: flex; gap: 14px; font-size: 1em; color: var(--esb-deep-gray); line-height: 1.5; }
.install-step strong { font-weight: 600; color: var(--esb-deep-purple-1); }

.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--esb-deep-purple-2);
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: -2px;
}

/* ─── TOAST ──────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--esb-deep-gray);
  color: white;
  padding: 12px 20px;
  border-radius: var(--esb-radius);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--esb-font-ui);
  box-shadow: var(--esb-shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s;
  z-index: 200;
  pointer-events: none;
}
.toast.show  { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--esb-red); }

/* ─── MISC ───────────────────────────────────────────────────────────────── */

.req           { color: var(--esb-red); margin-left: 2px; }
.required-note { font-size: 12px; }
