@use '../variables' as v;
@use '../mixins' as m;

// ─────────────────────────────────────────────
// Campaign Wizard Layout
// ─────────────────────────────────────────────
.cw-main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

// ── Step Bar ──
.cw-stepbar {
  display: flex;
  align-items: center;
  justify-content: center;
  background: v.$white;
  border-bottom: 1px solid v.$border-color;
  padding: 0 20px;
  height: 54px;
  flex-shrink: 0;
  position: relative;
  gap: 0;
}

.cw-stepbar-back {
  position: absolute;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: v.$font-size-sm;
  color: v.$gray-500;
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid v.$border-color;
  border-radius: 6px;
  background: v.$white;
  cursor: pointer;
  transition: background v.$transition-base;

  &:hover { background: v.$gray-50; color: v.$gray-700; }
  svg { width: 14px; height: 14px; }
}

.cw-steps { display: flex; align-items: center; gap: 0; }

.cw-step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  height: 54px;
  font-size: v.$font-size-sm;
  font-weight: 500;
  color: v.$gray-400;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color v.$transition-base, border-color v.$transition-base;
  white-space: nowrap;

  svg { width: 16px; height: 16px; }

  .cw-step-check { display: none; }

  &.is-active {
    color: v.$gray-800;
    border-bottom-color: v.$info;
    font-weight: 600;
  }

  &.is-done {
    color: v.$success;

    .cw-step-check { display: inline-flex; }
    .cw-step-num   { display: none; }
  }
}

.cw-step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: v.$font-size-2xs;
  font-weight: 600;
}

.cw-step-sep {
  color: v.$gray-300;
  margin: 0 2px;
  font-size: 18px;
  line-height: 1;
  user-select: none;
}

.cw-stepbar-title {
  position: absolute;
  right: 20px;
  font-size: v.$font-size-xs;
  color: v.$gray-500;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

// ── Step Panels ──
.cw-step-panel {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;

  &[hidden] { display: none !important; }
}

// ── Step 1: Compose (Editor) ──
.cw-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: v.$white;
  border-bottom: 1px solid v.$border-color;
  padding: 0 14px;
  height: 48px;
  flex-shrink: 0;
  overflow-x: auto;
}

.cw-toolbar-left  { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.cw-toolbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.cw-tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-width: 32px;
  padding: 0 8px;
  border: 1px solid v.$border-color;
  border-radius: 6px;
  background: v.$white;
  font-size: v.$font-size-xs;
  font-weight: 500;
  color: v.$gray-700;
  cursor: pointer;
  transition: background v.$transition-base;
  white-space: nowrap;
  gap: 5px;

  svg { width: 15px; height: 15px; }

  &:hover { background: v.$gray-50; }

  &.is-active { background: #eff6ff; border-color: #bfdbfe; color: v.$info; }
}

.cw-tb-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: v.$font-size-sm;
  font-weight: 600;
  color: v.$gray-800;
  padding: 0 8px;

  svg { width: 15px; height: 15px; color: v.$gray-500; }
}

.cw-tb-sep    { width: 1px; height: 24px; background: v.$border-color; margin: 0 4px; flex-shrink: 0; }

.cw-tb-save {
  background: v.$success;
  color: v.$white;
  border-color: v.$success;

  &:hover { background: #15803d; }
}

.cw-tb-continue {
  background: v.$info;
  color: v.$white;
  border-color: v.$info;
  font-size: v.$font-size-xs;
  padding: 0 14px;

  &:hover { background: #1d4ed8; }
}

.cw-tb-merge { font-family: monospace; font-size: v.$font-size-xs; letter-spacing: -.5px; }

// ── Editor Body ──
.cw-editor-body { flex: 1; display: flex; overflow: hidden; }

// Block Palette
.cw-palette {
  width: 160px;
  flex-shrink: 0;
  background: #f8fafc;
  border-right: 1px solid v.$border-color;
  overflow-y: auto;
  padding: 12px 8px;
}

.cw-palette-title {
  font-size: 10px;
  font-weight: 700;
  color: v.$gray-400;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 0 6px 8px;
}

.cw-palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid v.$border-color;
  background: v.$white;
  margin-bottom: 6px;
  cursor: grab;
  font-size: v.$font-size-xs;
  font-weight: 500;
  color: v.$gray-700;
  transition: border-color v.$transition-base, box-shadow v.$transition-base;
  user-select: none;

  &:hover { border-color: v.$info-border; box-shadow: 0 1px 4px rgba(37, 99, 235, .1); }
  &:active { cursor: grabbing; }
  svg { width: 14px; height: 14px; color: v.$gray-500; flex-shrink: 0; }
}

.cw-palette-divider { height: 1px; background: v.$border-color; margin: 8px 0; }

.cw-palette-section {
  font-size: 10px;
  font-weight: 600;
  color: v.$gray-400;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 4px 6px;
}

// ── Canvas ──
.cw-canvas-wrap {
  flex: 1;
  overflow-y: auto;
  background: #e9ecef;
  padding: 24px;
  display: flex;
  justify-content: center;
}

.cw-email-frame {
  width: 620px;
  background: v.$white;
  min-height: 480px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, .12);
  border-radius: 4px;
  position: relative;
}

.cw-canvas-dropzone {
  min-height: 48px;
  transition: background v.$transition-base;

  &.drag-over { background: #eff6ff; }
}

.cw-drop-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  color: v.$gray-400;
  font-size: v.$font-size-sm;
  border: 2px dashed v.$gray-300;
  border-radius: 6px;
  margin: 12px;
  pointer-events: none;
}

// Email Blocks
.email-block {
  position: relative;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .1s;

  &:hover { border-color: v.$info-border; }
  &.is-selected { border-color: v.$info; }

  .eb-drag-handle {
    display: none;
    position: absolute;
    left: -28px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: v.$info;
    border-radius: 4px;
    align-items: center;
    justify-content: center;
    cursor: grab;
    color: v.$white;
  }

  &.is-selected .eb-drag-handle { display: flex; }

  .eb-delete {
    display: none;
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: v.$white;
    font-size: v.$font-size-2xs;
    font-weight: 700;
    z-index: 10;
  }

  &.is-selected .eb-delete { display: flex; }
}

// Block Inner Styles
.eb-text-block {
  padding: 12px 24px;
  font-size: v.$font-size-base;
  line-height: 1.7;
  color: v.$gray-800;

  &[contenteditable]:focus { outline: none; }
}

.eb-heading-block {
  padding: 12px 24px;
  font-size: 22px;
  font-weight: 700;
  color: v.$gray-900;

  &[contenteditable]:focus { outline: none; }
}

.eb-image-block {
  padding: 12px 24px;
  text-align: center;

  img { max-width: 100%; border-radius: 4px; display: block; margin: 0 auto; }
}

.eb-image-placeholder {
  background: v.$gray-100;
  border: 2px dashed v.$gray-300;
  border-radius: 6px;
  height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: v.$gray-400;
  font-size: v.$font-size-sm;
  gap: 8px;
  cursor: pointer;

  svg { width: 32px; height: 32px; }
}

.eb-button-block {
  padding: 16px 24px;
  text-align: center;

  a {
    display: inline-block;
    padding: 12px 28px;
    background: v.$info;
    color: v.$white;
    border-radius: 6px;
    font-size: v.$font-size-base;
    font-weight: 600;
    text-decoration: none;
  }
}

.eb-divider-block {
  padding: 8px 24px;

  hr { border: none; border-top: 1px solid v.$border-color; }
}

.eb-spacer-block { height: 32px; }

.eb-2col-block { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }

.eb-2col-col {
  padding: 12px 16px;
  font-size: v.$font-size-sm;
  color: v.$gray-700;
  border: 1px dashed transparent;

  &[contenteditable]:focus { outline: none; border-color: v.$info-border; }
}

.eb-footer-block {
  padding: 16px 24px;
  background: v.$gray-50;
  border-top: 1px solid v.$border-color;
  text-align: center;
  font-size: v.$font-size-xs;
  color: v.$gray-500;
  line-height: 1.7;

  a { color: v.$info; }
}

.eb-social-block { padding: 12px 24px; text-align: center; }

.eb-social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: v.$border-color;
  margin: 0 4px;

  svg { width: 18px; height: 18px; color: v.$gray-700; }
}

// Inline Edit Toolbar
.eb-inline-toolbar {
  position: absolute;
  top: -44px;
  left: 0;
  z-index: 20;
  background: v.$gray-800;
  border-radius: 6px;
  padding: 4px 6px;
  display: none;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.email-block.is-selected .eb-inline-toolbar { display: flex; }

.eb-inline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: v.$gray-300;
  cursor: pointer;
  font-size: v.$font-size-xs;
  font-weight: 600;
  transition: background .1s;

  &:hover { background: rgba(255, 255, 255, .15); color: v.$white; }
  svg { width: 14px; height: 14px; }
}

.eb-inline-sep { width: 1px; height: 18px; background: rgba(255, 255, 255, .2); margin: 0 3px; }

// ── Block Settings Panel ──
.cw-settings {
  width: 260px;
  flex-shrink: 0;
  background: v.$white;
  border-left: 1px solid v.$border-color;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.cw-settings-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid v.$border-color;
  flex-shrink: 0;
}

.cw-settings-hdr-title { font-size: v.$font-size-sm; font-weight: 700; color: v.$gray-800; }

.cw-settings-hdr-nav {
  display: flex;
  gap: 4px;

  button {
    width: 24px;
    height: 24px;
    border: 1px solid v.$border-color;
    border-radius: 4px;
    background: v.$white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: v.$gray-500;
    font-size: v.$font-size-xs;
    transition: background v.$transition-base;

    &:hover { background: v.$gray-50; }
  }
}

.cw-settings-body { flex: 1; overflow-y: auto; }

.cw-settings-block-type {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid v.$gray-100;
  font-size: v.$font-size-sm;
  font-weight: 600;
  color: v.$gray-700;

  svg { width: 16px; height: 16px; color: v.$gray-500; }
}

.cw-settings-tabs { display: flex; border-bottom: 1px solid v.$border-color; }

.cw-settings-tab {
  flex: 1;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: border-color v.$transition-base;
  color: v.$gray-400;

  svg { width: 16px; height: 16px; }

  &.is-active { border-bottom-color: v.$info; color: v.$info; }
}

.cw-settings-section { padding: 14px 16px; border-bottom: 1px solid v.$gray-100; }

.cw-settings-section-title {
  font-size: v.$font-size-2xs;
  font-weight: 700;
  color: v.$gray-700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;

  span { font-size: v.$font-size-base; color: v.$gray-400; cursor: pointer; }
}

.cw-settings-label {
  font-size: 10px;
  font-weight: 600;
  color: v.$gray-400;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}

.cw-settings-select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid v.$border-color;
  border-radius: 6px;
  font-size: v.$font-size-xs;
  color: v.$gray-700;
  font-family: inherit;
  margin-bottom: 12px;
}

.cw-settings-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid v.$border-color;
  border-radius: 6px;
  font-size: v.$font-size-xs;
  color: v.$gray-700;
  font-family: inherit;
  margin-bottom: 12px;
}

.cw-settings-4col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 28px;
  gap: 4px;
  margin-bottom: 12px;
  align-items: center;

  input {
    padding: 6px 4px;
    border: 1px solid v.$border-color;
    border-radius: 4px;
    font-size: v.$font-size-2xs;
    text-align: center;
    width: 100%;
  }

  label {
    font-size: 10px;
    color: v.$gray-400;
    text-align: center;
    display: block;
    margin-top: 2px;
  }
}

.cw-settings-link-btn {
  width: 24px;
  height: 24px;
  border: 1px solid v.$border-color;
  border-radius: 4px;
  background: v.$white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: v.$gray-500;

  svg { width: 12px; height: 12px; }
}

.cw-settings-empty {
  padding: 32px 16px;
  text-align: center;
  color: v.$gray-400;
  font-size: v.$font-size-sm;

  svg { width: 32px; height: 32px; margin: 0 auto 10px; color: v.$gray-300; display: block; }
}

// ── Steps 2–4: Scrollable Card Area ──
.cw-content-area {
  flex: 1;
  overflow-y: auto;
  background: v.$gray-100;
  padding: 32px 20px;
  max-width: 850px;
}

.cw-content-card {
  max-width: 720px;
  margin: 0 auto;
  background: v.$white;
  border: 1px solid v.$border-color;
  border-radius: v.$radius-md;
  overflow: hidden;
}

.cw-card-hdr {
  padding: 20px 24px;
  border-bottom: 1px solid v.$border-color;

  h2 { font-size: v.$font-size-lg; font-weight: 700; color: v.$gray-900; margin-bottom: 2px; }
  p  { font-size: v.$font-size-sm; color: v.$gray-500; }
}

.cw-card-body   { padding: 24px; }
.cw-card-footer {
  padding: 16px 24px;
  border-top: 1px solid v.$border-color;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

// Step 2
.cw-form-group {
  margin-bottom: 20px;
  &:last-child { margin-bottom: 0; }
}

.cw-form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;

  input[type="checkbox"] { width: 16px; height: 16px; accent-color: v.$info; flex-shrink: 0; }
}

.cw-subject-wrap {
  position: relative;

  input { padding-right: 40px; }
}

.cw-subject-dots {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: v.$gray-400;
  font-size: 16px;
  cursor: pointer;
  letter-spacing: -1px;
}

// Step 3
.cw-recipients-tabs { display: flex; gap: 6px; margin-bottom: 20px; }

.cw-recipients-tab {
  padding: 7px 18px;
  border-radius: 6px;
  font-size: v.$font-size-sm;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid v.$border-color;
  background: v.$white;
  color: v.$gray-500;

  &.is-active   { background: v.$info; color: v.$white; border-color: v.$info; }
  &.is-disabled { opacity: .45; cursor: not-allowed; text-decoration: line-through; }
}

.cw-incl-card {
  border: 1px solid v.$border-color;
  border-radius: v.$radius;
  overflow: hidden;
  margin-bottom: 16px;
}

.cw-incl-card-hdr {
  padding: 14px 18px;
  background: v.$gray-50;
  border-bottom: 1px solid v.$border-color;

  h4 { font-size: v.$font-size-base; font-weight: 700; color: v.$info; margin-bottom: 2px; }
  p  { font-size: v.$font-size-xs; color: v.$gray-700; }
}

.cw-incl-table {
  width: 100%;

  th {
    font-size: v.$font-size-2xs;
    font-weight: 600;
    color: v.$gray-500;
    padding: 10px 16px;
    border-bottom: 1px solid v.$gray-100;
    text-align: left;
  }
}

.cw-incl-row {
  td {
    padding: 10px 16px;
    border-bottom: 1px solid v.$gray-50;
    vertical-align: middle;
  }

  &:last-child td { border-bottom: none; }
}

.cw-incl-select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid v.$border-color;
  border-radius: 6px;
  font-size: v.$font-size-sm;
  font-family: inherit;
}

.cw-incl-actions { display: flex; gap: 4px; }

.cw-incl-act {
  width: 28px;
  height: 28px;
  border: 1px solid v.$border-color;
  border-radius: 4px;
  background: v.$white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: v.$font-size-base;
  color: v.$gray-700;
  font-weight: 700;
}

.cw-contact-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: v.$gray-800;
  color: v.$white;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: v.$font-size-sm;
  font-weight: 600;
  margin-top: 16px;

  .num {
    background: v.$info;
    color: v.$white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: v.$font-size-xs;
    font-weight: 700;
  }
}

// Step 4: Review
.cw-review-section {
  border-bottom: 1px solid v.$gray-100;
  padding: 18px 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;

  &:last-child { border-bottom: none; }
}

.cw-review-lbl    { font-size: v.$font-size-xs; font-weight: 700; color: v.$gray-700; margin-bottom: 4px; }
.cw-review-val    { font-size: v.$font-size-sm; color: v.$gray-800; }
.cw-review-subval { font-size: v.$font-size-xs; color: v.$gray-500; margin-top: 2px; }

.cw-review-edit {
  font-size: v.$font-size-xs;
  font-weight: 500;
  color: v.$gray-500;
  border: 1px solid v.$border-color;
  border-radius: 6px;
  padding: 5px 12px;
  background: v.$white;
  cursor: pointer;
  white-space: nowrap;

  &:hover { background: v.$gray-50; }
}

.cw-email-preview {
  border: 2px dashed #d4b800;
  border-radius: 4px;
  background: v.$white;
  padding: 20px;
  min-height: 140px;
  margin: 0 24px 20px;

  p { font-size: v.$font-size-sm; color: v.$gray-700; }

  .ep-footer {
    margin-top: 24px;
    color: v.$gray-400;
    font-size: v.$font-size-xs;

    a { color: v.$info; }
  }
}

.cw-schedule-section  { border-top: 1px solid v.$border-color; padding: 20px 24px; }
.cw-schedule-title    { font-size: v.$font-size-base; font-weight: 700; color: v.$gray-700; margin-bottom: 4px; }
.cw-schedule-desc     { font-size: v.$font-size-xs; color: v.$gray-500; margin-bottom: 16px; }
.cw-schedule-divider  { height: 1px; background: v.$border-color; margin: 16px 0; }
.cw-schedule-q        { font-size: v.$font-size-sm; font-weight: 700; color: v.$gray-700; margin-bottom: 12px; }

.cw-radio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: v.$font-size-sm;
  color: v.$gray-700;
  cursor: pointer;

  input[type="radio"] { width: 16px; height: 16px; accent-color: v.$info; }
}

.cw-send-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: v.$success;
  color: v.$white;
  border: none;
  border-radius: 6px;
  padding: 11px 22px;
  font-size: v.$font-size-base;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;

  &:hover { background: #15803d; }
}

.cw-test-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: v.$white;
  color: v.$gray-700;
  border: 1px solid v.$border-color;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: v.$font-size-sm;
  cursor: pointer;

  &:hover { background: v.$gray-50; }
}
