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

// ─────────────────────────────────────────────
// Sequence Builder Layout
// ─────────────────────────────────────────────

// ── Top Bar ──
.sb-topbar {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  min-height: 54px;
  padding: 0 20px;
  gap: 12px;
  position: relative;
  flex-shrink: 0;

  @media (max-width: 640px) {
    height: auto;
    padding: 10px 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

.sb-topbar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;

  @media (max-width: 640px) {
    width: 100%;
  }
}

.sb-topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: v.$font-size-sm;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  flex-shrink: 0;

  &:hover { color: var(--text-primary); }
}

.sb-topbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border-color);
  flex-shrink: 0;
}

.sb-topbar-name {
  font-size: v.$font-size-base;
  font-weight: 600;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  min-width: 0;

  input {
    font-size: v.$font-size-base;
    font-weight: 600;
    color: var(--text-primary);
    border: none;
    outline: none;
    background: transparent;
    width: auto;
    max-width: 200px;

    &:focus { background: var(--bg-hover); border-radius: 4px; padding: 2px 6px; }
  }
}

.sb-topbar-status {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: v.$font-size-2xs;
  font-weight: 600;
  background: var(--warning-light);
  color: var(--warning);
  flex-shrink: 0;
  width: auto !important;
  align-self: center;
}

.sb-topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;

  @media (max-width: 640px) {
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;

    .sb-btn {
      width: 100%;
      justify-content: center;
      padding: 0 6px;
      font-size: 11px;
      white-space: nowrap;
    }
  }
}

.sb-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: v.$font-size-xs;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: background v.$transition-base;

  &:hover { background: var(--bg-hover); }
}

.sb-btn-primary {
  background: var(--info);
  color: #fff;
  border-color: var(--info);

  &:hover { background: var(--info-border); }
}

.sb-btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);

  &:hover { background: var(--success-border); }
}

// ── Main Layout ──
.sb-layout {
  display: flex;
  flex: 1;
  overflow: hidden;

  @media (max-width: 1024px) {
    flex-direction: column;
    overflow-y: auto;
    height: auto;
    flex: 1;
    min-height: 0;
  }
}

// ── Left Config Panel ──
.sb-config {
  width: 300px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sb-config-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);

  h3 { font-size: v.$font-size-sm; font-weight: 700; color: var(--text-secondary); margin: 0 0 2px; }
  p  { font-size: v.$font-size-2xs; color: var(--text-muted); margin: 0; }
}

.sb-config-body { 
  padding: 16px 20px; 
  flex: 1; 
  overflow-y: auto; 
  scrollbar-width: thin;
  
  &::-webkit-scrollbar {
    width: 4px;
  }
  &::-webkit-scrollbar-track {
    background: transparent;
  }
  &::-webkit-scrollbar-thumb {
    background: var(--border-color, #e5e7eb);
    border-radius: 4px;
  }
}

.sb-field {
  margin-bottom: 16px;

  label {
    display: block;
    font-size: v.$font-size-2xs;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 5px;
  }

  input, select, textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: v.$font-size-sm;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    background: var(--bg-surface);

    &:focus { border-color: var(--info-border); }
  }

  textarea { resize: vertical; min-height: 68px; line-height: 1.5; }
}

.sb-stat-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;

  @media (max-width: 480px) {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
}

.sb-stat {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: v.$radius;
  padding: 10px 12px;

  @media (max-width: 480px) {
    padding: 8px 4px;
    text-align: center;
  }
}

.sb-stat-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);

  @media (max-width: 480px) {
    font-size: 15px;
  }
}
.sb-stat-label { font-size: 10px; color: var(--text-muted); font-weight: 500; margin-top: 1px; }

.sb-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

.sb-tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.sb-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--info-light);
  border: 1px solid var(--info-border);
  border-radius: 20px;
  font-size: v.$font-size-2xs;
  font-weight: 500;
  color: var(--info);

  button {
    border: none;
    background: none;
    cursor: pointer;
    font-size: v.$font-size-base;
    color: var(--info-border);
    padding: 0;
    line-height: 1;
  }
}

// ── Builder Canvas ──
.sb-canvas {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-page);

  @media (max-width: 1024px) {
    padding: 20px 12px;
    flex: 0 0 auto;
    width: 100%;
    overflow: visible;
  }
}

.sb-canvas-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: max-content;
  width: auto;
  max-width: none;

  @media (max-width: 640px) {
    min-width: 100%;
    width: 100%;
  }
}

.sb-recipient-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;

  @media (max-width: 540px) {
    flex-direction: column;
    align-items: stretch;

    > * {
      width: 100% !important;
      flex: none !important;
    }
  }
}

// Trigger Block
.sb-trigger-block {
  background: var(--bg-surface);
  border: 2px solid var(--info);
  border-radius: v.$radius-lg;
  padding: 18px 20px;
  margin-bottom: 0;
  position: relative;
  width: 100%;
  max-width: 500px;
}

.sb-trigger-block-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--info);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;

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

.sb-trigger-title { font-size: v.$font-size-base; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.sb-trigger-desc  { font-size: v.$font-size-xs; color: var(--text-secondary); }
.sb-trigger-edit  { position: absolute; top: 14px; right: 14px; }

// Connector Line
.sb-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  position: relative;
  margin: 0;
}

.sb-connector-line { width: 2px; background: var(--border-color); flex: 1; min-height: 16px; }
.sb-connector-dot  { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }

// Delay Pill
.sb-delay-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 5px 12px 5px 8px;
  font-size: v.$font-size-xs;
  color: var(--text-primary);
  cursor: pointer;
  position: relative;
  z-index: 1;
  margin: 4px 0;
  white-space: nowrap;

  &:hover { border-color: var(--info-border); background: var(--info-light); }
  svg { width: 13px; height: 13px; color: var(--text-muted); }
}

.sb-delay-pill-val { font-weight: 600; color: var(--text-primary); }

// Email Step Card
.sb-email-step {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: v.$radius-lg;
  padding: 16px 20px;
  width: 100%;
  max-width: 500px;
  position: relative;
  transition: border-color v.$transition-base, box-shadow v.$transition-base;

  &:hover { border-color: var(--info-border); box-shadow: 0 2px 12px rgba(37, 99, 235, .08); }
  &.is-selected { border-color: var(--info); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }

  &:hover .sb-step-remove { opacity: 1; }

  // Nested condition card inside a branch column
  &.sb-nested-condition {
    border-color: var(--warning-border);
    background: var(--warning-light);
    border-style: dashed;

    &:hover { border-color: var(--warning); box-shadow: 0 2px 12px rgba(245, 158, 11, .12); }
    &.is-selected { border-color: var(--warning-border); box-shadow: 0 0 0 3px rgba(217, 119, 6, .15); }
  }

  .af-node-status-footer {
    margin-left: -20px;
    margin-right: -20px;
    margin-bottom: -16px;
    margin-top: 12px;
    border-bottom-left-radius: calc(v.$radius-lg - 1px);
    border-bottom-right-radius: calc(v.$radius-lg - 1px);
  }
}

.sb-step-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--info);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 2px;

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

.sb-step-subject {
  font-size: v.$font-size-base;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;


  input {
    font-size: v.$font-size-base;
    font-weight: 600;
    color: var(--text-primary);
    border: none;
    outline: none;
    background: transparent;
    flex: 1;
    font-family: inherit;
      padding: 0px;

    &:focus { background: var(--bg-hover); border-radius: 4px; padding: 0 4px; }
  }
}

.sb-step-meta    { font-size: v.$font-size-2xs; color: var(--text-muted); margin-bottom: 12px; }
.sb-step-actions { display: flex; gap: 8px; }

.sb-step-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: v.$font-size-2xs;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: background v.$transition-base;

  &:hover { background: var(--bg-hover); }
}

.sb-step-btn-primary {
  border-color: var(--info-border);
  background: var(--info-light);
  color: var(--info);

  &:hover { background: var(--info-light); }
}

.sb-step-remove {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: none;
  background: var(--danger-light);
  color: var(--danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity v.$transition-base;

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

// Condition Block
.sb-condition-block {
  background: var(--warning-light);
  border: 1px solid var(--warning-border);
  border-radius: v.$radius-lg;
  padding: 14px 18px;
  width: 100%;
  max-width: 500px;
  position: relative;
  transition: border-color v.$transition-base, box-shadow v.$transition-base;

  &:hover { border-color: var(--warning); box-shadow: 0 2px 12px rgba(217, 119, 6, .08); }
  &.is-selected { border-color: var(--warning-border); box-shadow: 0 0 0 3px rgba(217, 119, 6, .1); }

  &:hover .sb-step-remove { opacity: 1; }

  .af-node-status-footer {
    margin-left: -18px;
    margin-right: -18px;
    margin-bottom: -14px;
    margin-top: 12px;
    border-bottom-left-radius: calc(v.$radius-lg - 1px);
    border-bottom-right-radius: calc(v.$radius-lg - 1px);
  }
}

.sb-condition-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--warning);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sb-condition-title { font-size: v.$font-size-sm; font-weight: 600; color: var(--warning); margin-bottom: 4px; }

.sb-condition-branches { display: flex; gap: 12px; margin-top: 12px; }

.sb-branch {
  flex: 1;
  padding: 10px 12px;
  border-radius: v.$radius;
  border: 1px dashed var(--border-color);
  text-align: center;
  font-size: v.$font-size-xs;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color v.$transition-base;

  &:hover { border-color: var(--info-border); color: var(--info); }
}

.sb-branch-yes { border-color: var(--success-border); background: var(--success-light); color: var(--success); font-weight: 600; }
.sb-branch-no  { border-color: var(--danger-border); background: var(--danger-light); color: var(--danger); font-weight: 600; }

// Add Step Button
.sb-add-step {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--border-color);
  border-radius: v.$radius-md;
  background: transparent;
  font-size: v.$font-size-sm;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: all v.$transition-base;

  &:hover { border-color: var(--info); color: var(--info); background: var(--info-light); }
  svg { width: 16px; height: 16px; }
}

// Add Step Dropdown
.sb-add-menu {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: v.$radius;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  padding: 6px;
  display: none;
  min-width: 200px;
  position: absolute;
  z-index: 100;

  &.is-open { display: block; }
}

.sb-add-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: v.$font-size-sm;
  color: var(--text-primary);
  cursor: pointer;
  transition: background .1s;

  &:hover { background: var(--bg-hover); }
  svg { width: 16px; height: 16px; }
}

.sb-add-menu-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

// ── Right Details Panel ──
.sb-details {
  width: 280px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width .2s;

  @media (max-width: 1024px) {
    width: 100%;
    flex: 0 0 auto;
    border-left: none;
    border-top: 1px solid var(--border-color);
    max-height: none;
    overflow: visible;
  }
}

.sb-details-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;

  h4 { font-size: v.$font-size-sm; font-weight: 700; color: var(--text-primary); margin: 0; }
}

.sb-details-close {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px;

  &:hover { color: var(--text-primary); }
}

.sb-details-body    { padding: 16px 18px; overflow-y: auto; flex: 1; }
.sb-details-section { margin-bottom: 18px; }

.sb-details-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

// Progress bar on steps
.sb-step-stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.sb-step-stat-label { font-size: v.$font-size-2xs; color: var(--text-secondary); width: 60px; flex-shrink: 0; }
.sb-step-stat-bar   { flex: 1; height: 4px; background: var(--border-color); border-radius: 2px; }
.sb-step-stat-fill  { height: 100%; border-radius: 2px; background: var(--info); }
.sb-step-stat-val   { font-size: v.$font-size-2xs; font-weight: 600; color: var(--text-primary); width: 36px; text-align: right; }

// ── Visual Branches Split Layout ──
.sb-condition-split {
  display: flex;
  gap: 20px;
  width: 100%;
  margin-top: 0;
  position: relative;
  justify-content: center;

  // Horizontal crossbar at the top connecting both columns
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: calc(25% + 10px);
    right: calc(25% + 10px);
    height: 2px;
    background: var(--border-color);
    z-index: 0;
  }

  @media (max-width: 768px) {
    flex-direction: column;
    align-items: center;
    gap: 24px;
    &::before { display: none; }
  }
}

// The wrapper that holds the crossbar + columns, including the vertical drop from condition card
.sb-condition-split-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  position: relative;
}

// Short vertical line from condition card down to crossbar
.sb-split-trunk {
  width: 2px;
  height: 24px;
  background: var(--border-color);
  flex-shrink: 0;
}

// Vertical arm dropping from crossbar down into each column's top
.sb-branch-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  background: var(--bg-hover);
  border: 1.5px solid var(--border-color);
  border-radius: 14px;
  padding: 24px 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 320px;
  width: auto;

  &:hover {
    border-color: var(--info-border);
    box-shadow: 0 0 0 3px var(--active-bg);
  }

  @media (max-width: 480px) {
    min-width: 100%;
    width: 100%;
  }
}

.sb-branch-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 4px 14px;
  border-radius: 20px;
  flex-shrink: 0;

  &.is-yes {
    background: var(--success-light);
    color: var(--success);
    border: 1.5px solid var(--success-border);
  }

  &.is-no {
    background: var(--danger-light);
    color: var(--danger);
    border: 1.5px solid var(--danger-border);
  }
}

// Smaller "Add Step" button variant used inside branch columns
.sb-add-step-sm {
  padding: 8px 14px;
  font-size: 11px;
  border-width: 1.5px;
  gap: 5px;

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


// ── Node Status Footer & Tooltip ──
.af-node-status-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-page);
  border-top: 1px solid var(--border-color);
  border-bottom-left-radius: 13px;
  border-bottom-right-radius: 13px;
}

.af-status-indicators {
  display: flex;
  align-items: center;
  gap: 8px;
}

.af-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;

  &.is-processing {
    background: var(--info-light);
    color: var(--info);
    border: 1px solid var(--info-border);

    svg {
      animation: spin 1.5s linear infinite;
    }
  }

  &.is-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid var(--success-border);
  }

  &.is-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid var(--danger-border);
  }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.af-tooltip-wrapper {
  position: relative;
  display: inline-block;
}

.af-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;

  &:hover {
    color: var(--active-text);
    transform: scale(1.05);
  }
}

.af-tooltip-panel {
  position: absolute;
  bottom: 125%;
  right: 0;
  width: 300px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #ffffff;
  padding: 12px;
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  z-index: 100;
  text-align: left;
  pointer-events: auto;

  &::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 12px;
    border-width: 6px;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
  }
}

.af-tooltip-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;

  &:hover {
    background: #334155;
    color: #ffffff;
  }
}

.af-tooltip-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.af-tooltip-stats {
  display: flex;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 10px;

  .stat-item {
    padding: 1px 6px;
    border-radius: 3px;

    &.is-success {
      background: #064e3b;
      color: #34d399;
    }

    &.is-processing {
      background: #0c4a6e;
      color: #38bdf8;
    }

    &.is-error {
      background: #7f1d1d;
      color: #f87171;
    }
  }
}

.af-tooltip-logs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
  padding-right: 6px;

  &::-webkit-scrollbar {
    width: 6px;
  }
  &::-webkit-scrollbar-track {
    background: #1e293b;
    border-radius: 3px;
  }
  &::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
    &:hover {
      background: #64748b;
    }
  }
}

.af-tooltip-log-item {
  border-bottom: 1px solid #334155;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-left: 3px solid transparent;
  padding-left: 8px;
  
  &.is-success, &.is-node_success, &.is-sent {
    border-left-color: #22c55e;
  }
  &.is-error, &.is-node_error, &.is-bounced {
    border-left-color: #ef4444;
  }
  &.is-spam {
    border-left-color: #f97316;
  }
  &.is-open {
    border-left-color: #3b82f6;
  }
  &.is-click {
    border-left-color: #a855f7;
  }
  
  &:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
  }
  
  .log-header {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    
    .log-email {
      color: #e2e8f0;
    }
    
    .log-time {
      color: #64748b;
      font-size: 10px;
    }
  }
  
  .log-body {
    font-size: 11px;
    color: #94a3b8;
  }
}

.sb-diagnostics-label {
  margin-top: 20px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  color: #3b82f6;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sb-diagnostics-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.sb-diagnostics-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sb-diagnostics-title {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sb-diagnostics-value {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sb-diagnostics-conn {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.sb-diagnostics-warning {
  background: rgba(249, 171, 0, 0.1);
  border: 1px solid rgba(249, 171, 0, 0.3);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  gap: 6px;
  align-items: flex-start;
  color: var(--text-primary);
  
  .warning-icon {
    color: #f9ab00;
    flex-shrink: 0;
    margin-top: 2px;
  }
  
  .warning-text {
    font-size: 11px;
    line-height: 1.4;
  }
  
  code {
    display: block;
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    padding: 4px 6px;
    border-radius: 4px;
    margin-top: 4px;
    font-family: monospace;
    color: #3b82f6;
    font-weight: bold;
  }
}

.sb-diagnostics-list {
  max-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sb-diagnostics-item {
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  
  .item-info {
    min-width: 0;
    flex: 1;
    margin-right: 8px;
  }
  
  .item-email {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }
  
  .item-desc {
    font-size: 10px;
    color: var(--text-muted);
  }
  
  .item-time {
    font-size: 11px;
    color: #34d399;
    font-weight: 600;
    flex-shrink: 0;
  }
}

.sb-diagnostics-empty {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0;
}

.sb-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;

  &.is-open {
    opacity: 1;
    pointer-events: auto;
  }
}

.sb-modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 600px;
  max-width: 95%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);

  &.is-open {
    transform: scale(1);
  }
}

.sb-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;

  .modal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.15s ease, color 0.15s ease;

    &:hover {
      background: var(--bg-hover);
      color: var(--text-primary);
    }
  }
}

.sb-modal-body {
  padding: 24px;
  max-height: 70vh;
  overflow-y: auto;
  scrollbar-width: thin;
  
  &::-webkit-scrollbar {
    width: 6px;
  }
  &::-webkit-scrollbar-track {
    background: transparent;
  }
  &::-webkit-scrollbar-thumb {
    background: var(--border-color, #e5e7eb);
    border-radius: 4px;
  }
}

.sb-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  background: var(--bg-surface);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}

/* Production-level Diagnostics list stylings */
.sb-diag-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sb-diag-step-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-surface);
  margin-bottom: 8px;
  transition: all 0.2s ease;

  &:hover {
    border-color: var(--text-muted);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
  }
}

.sb-diag-badge-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sb-diag-queue-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-surface);
  margin-bottom: 8px;
}
