/* Al Hiba Marketing Connection API — Interactive UI/UX Testing Workbench Styles
 * Built strictly on hba-tokens.css variables + brand-icons-mobile-ui motion choreography
 */

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  font-family: var(--hba-font-family-sans);
  font-size: var(--hba-type-size-body);
  line-height: var(--hba-type-leading-body);
  background-color: var(--hba-surface-page);
  color: var(--hba-text-primary);
  -webkit-font-smoothing: antialiased;
}

.ltr-num {
  unicode-bidi: isolate;
  direction: ltr;
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

.app-shell, .workbench-shell {
  max-width: var(--hba-size-content-max);
  margin: 0 auto;
  padding: var(--hba-space-3);
  display: flex;
  flex-direction: column;
  gap: var(--hba-space-3);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hba-space-3);
  flex-wrap: wrap;
  background: var(--hba-surface-raised);
  border: var(--hba-border-thin) solid var(--hba-line-decorative);
  border-radius: var(--hba-radius-card);
  padding: 12px 16px;
  box-shadow: var(--hba-elevation-card);
}
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--hba-action-primary); color: var(--hba-action-on-primary);
  font-weight: 800; font-size: 13px; letter-spacing: 0.04em;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand-titles h1 { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.25; }
.brand-titles p { margin: 2px 0 0; font-size: 12px; color: var(--hba-text-muted); }

/* Headerless Ultra-Compact Dynamic Island Micro-Strip */
.micro-strip-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hba-space-2);
  flex-wrap: wrap;
  background: var(--hba-surface-alt);
  border: var(--hba-border-thin) solid var(--hba-line-decorative);
  border-radius: var(--hba-radius-card);
  padding: var(--hba-space-2) var(--hba-space-3);
}

.micro-island {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}
.micro-island::-webkit-scrollbar {
  display: none;
}

.micro-pill {
  min-height: var(--hba-size-touch);
  padding: 0 12px;
  border-radius: var(--hba-radius-control);
  border: var(--hba-border-thin) solid var(--hba-line-control);
  background: var(--hba-surface-raised);
  color: var(--hba-text-primary);
  font-size: var(--hba-type-size-small);
  font-weight: var(--hba-font-weight-bold);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--hba-duration-fast) cubic-bezier(0.34, 1.56, 0.64, 1);
}
.micro-pill:active {
  transform: scale(0.96);
}
.micro-pill[data-active="true"] {
  background: var(--hba-surface-selected);
  border-color: var(--hba-action-primary);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--hba-status-success);
  flex-shrink: 0;
}
.status-dot.danger {
  background: var(--hba-status-danger);
}
.status-dot.warning {
  background: var(--hba-status-warning);
}

.mitosis-drawer {
  background: var(--hba-surface-raised);
  border: var(--hba-border-thin) solid var(--hba-line-decorative);
  border-radius: var(--hba-radius-card);
  padding: var(--hba-space-2) var(--hba-space-3);
  font-size: var(--hba-type-size-small);
  display: none;
  flex-wrap: wrap;
  gap: var(--hba-space-2);
  align-items: center;
}
.mitosis-drawer.open {
  display: flex;
}

/* Primary Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: var(--hba-space-2);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.nav-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  min-height: var(--hba-size-touch);
  padding: 0 14px;
  border-radius: var(--hba-radius-control);
  border: var(--hba-border-thin) solid var(--hba-line-control);
  background: var(--hba-surface-raised);
  color: var(--hba-text-primary);
  font-family: inherit;
  font-size: var(--hba-type-size-small);
  font-weight: var(--hba-font-weight-bold);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.tab-btn.active {
  background: var(--hba-action-primary);
  color: var(--hba-action-on-primary);
  border-color: var(--hba-action-primary);
}

/* Anti-Spinner Living Progress Bar & Equalizer */
.progress-banner {
  background: var(--hba-surface-raised);
  border: var(--hba-border-thin) solid var(--hba-line-control);
  border-radius: var(--hba-radius-card);
  padding: var(--hba-space-3);
  display: flex;
  flex-direction: column;
  gap: var(--hba-space-2);
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hba-space-2);
  flex-wrap: wrap;
  font-size: var(--hba-type-size-small);
  font-weight: var(--hba-font-weight-bold);
}

.equalizer {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 14px;
}
.eq-bar {
  width: 3px;
  background: var(--hba-action-primary);
  border-radius: 2px;
  animation: eqBounce 0.8s ease-in-out infinite alternate;
}
.eq-bar:nth-child(1) { height: 6px; animation-delay: 0ms; }
.eq-bar:nth-child(2) { height: 13px; animation-delay: 180ms; }
.eq-bar:nth-child(3) { height: 9px; animation-delay: 340ms; }

@keyframes eqBounce {
  0% { transform: scaleY(0.45); }
  100% { transform: scaleY(1); }
}

.stage-track {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.stage-segment {
  height: 8px;
  border-radius: 4px;
  background: var(--hba-surface-alt);
  border: var(--hba-border-thin) solid var(--hba-line-decorative);
  overflow: hidden;
  position: relative;
}
.stage-segment.done {
  background: var(--hba-status-success);
  border-color: var(--hba-status-success);
}
.stage-segment.active {
  background: linear-gradient(90deg, var(--hba-action-primary) 0%, var(--hba-brand-accent) 50%, var(--hba-action-primary) 100%);
  background-size: 200% 100%;
  animation: shimmerSweep 1.2s linear infinite;
}
@keyframes shimmerSweep {
  0% { background-position: 200% 0; }
  100% { background-position: 0 0; }
}

/* Status Banner (Word + Icon + Edge per Brand rules) */
.status-banner {
  padding: var(--hba-space-2) var(--hba-space-3);
  border-radius: var(--hba-radius-control);
  border: var(--hba-border-thin) solid var(--hba-line-control);
  font-size: var(--hba-type-size-small);
  font-weight: var(--hba-font-weight-bold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hba-space-2);
  flex-wrap: wrap;
}
.status-banner.success {
  background: var(--hba-status-success-soft);
  color: var(--hba-status-success);
}
.status-banner.danger {
  background: var(--hba-status-danger-soft);
  color: var(--hba-status-danger);
}
.status-banner.info {
  background: var(--hba-status-info-soft);
  color: var(--hba-status-info);
}

/* Cards & Apple HIG Squircles */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: var(--hba-space-3);
}

.channel-card {
  background: var(--hba-surface-raised);
  border: var(--hba-border-thin) solid var(--hba-line-decorative);
  border-radius: var(--hba-radius-card);
  box-shadow: var(--hba-elevation-card);
  overflow: hidden;
}

.card-header-btn {
  width: 100%;
  min-height: 64px;
  padding: var(--hba-space-3);
  background: transparent;
  border: none;
  color: inherit;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hba-space-2);
  cursor: pointer;
  text-align: start;
}

.brand-squircle {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--hba-surface-alt);
  border: var(--hba-border-thin) solid var(--hba-line-decorative);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-squircle img {
  width: 24px;
  height: 24px;
  pointer-events: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* CSS Grid 0fr -> 1fr Spring Accordion */
.accordion-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 260ms cubic-bezier(0.22, 1, 0.36, 1);
}
.accordion-wrap.open {
  grid-template-rows: 1fr;
}
.accordion-inner {
  overflow: hidden;
}
.accordion-content {
  padding: 0 var(--hba-space-3) var(--hba-space-3);
  border-top: var(--hba-border-thin) solid var(--hba-line-decorative);
  display: flex;
  flex-direction: column;
  gap: var(--hba-space-2);
}

.bento-2x2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--hba-space-2);
  margin-top: var(--hba-space-2);
}
.bento-cell {
  background: var(--hba-surface-alt);
  border: var(--hba-border-thin) solid var(--hba-line-decorative);
  border-radius: var(--hba-radius-control);
  padding: var(--hba-space-2);
  font-size: var(--hba-type-size-small);
}
.bento-label {
  color: var(--hba-text-muted);
  font-size: 12px;
  display: block;
}

/* Form Controls & Buttons (>=44px touch target, 16px input font) */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--hba-space-2);
}

.btn {
  min-height: var(--hba-size-touch);
  padding: 0 14px;
  border-radius: var(--hba-radius-control);
  font-family: inherit;
  font-size: var(--hba-type-size-small);
  font-weight: var(--hba-font-weight-bold);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: var(--hba-border-thin) solid var(--hba-action-secondary-border);
  background: var(--hba-surface-raised);
  color: var(--hba-action-secondary-text);
}
.btn.primary {
  background: var(--hba-action-primary);
  color: var(--hba-action-on-primary);
  border-color: var(--hba-action-primary);
}
.btn.danger {
  background: var(--hba-action-danger);
  color: var(--hba-action-on-danger);
  border-color: var(--hba-action-danger);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: var(--hba-space-3);
}
.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field-group label {
  font-size: var(--hba-type-size-small);
  font-weight: var(--hba-font-weight-bold);
}
.field-input, .field-select, .field-textarea {
  min-height: var(--hba-size-touch);
  padding: 8px 12px;
  font-family: inherit;
  font-size: var(--hba-type-size-input);
  border-radius: var(--hba-radius-control);
  border: var(--hba-border-thin) solid var(--hba-line-control);
  background: var(--hba-surface-page);
  color: var(--hba-text-primary);
  width: 100%;
}
.field-textarea {
  min-height: 84px;
  resize: vertical;
}

.json-viewer {
  background: var(--hba-surface-alt);
  border: var(--hba-border-thin) solid var(--hba-line-decorative);
  border-radius: var(--hba-radius-control);
  padding: var(--hba-space-3);
  font-family: monospace;
  font-size: 12px;
  overflow-x: auto;
  max-height: 320px;
  white-space: pre-wrap;
  word-break: break-word;
  direction: ltr;
  text-align: left;
}

:root[data-contrast="high"] .btn,
:root[data-contrast="high"] .tab-btn,
:root[data-contrast="high"] .micro-pill,
:root[data-contrast="high"] .field-input,
:root[data-contrast="high"] .field-select {
  min-height: var(--hba-size-touch-worker);
  border-width: var(--hba-border-thick);
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

/* Visual Data Bars, Inline Brand Chips, Score Rings & Visual Timelines */
.inline-brand-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px;
  border-radius: 99px; font-size: 11px; font-weight: 600;
  background: var(--hba-surface-alt); border: 1px solid var(--hba-line-decorative);
}
.inline-brand-chip img { pointer-events: none; user-select: none; }
.metric-bar-track {
  width: 100%; height: 7px; border-radius: 99px;
  background: var(--hba-line-decorative); overflow: hidden; margin-top: 5px;
}
.metric-bar-fill {
  height: 100%; border-radius: 99px; background: var(--hba-brand-primary);
  transition: width 380ms cubic-bezier(0.22, 1, 0.36, 1);
}
.metric-bar-fill.emerald { background: #16A34A; }
.metric-bar-fill.amber { background: #D97706; }
.metric-bar-fill.cobalt { background: #0284C7; }
.score-ring-wrap { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.visual-timeline-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 5px 0;
  border-bottom: 1px dashed var(--hba-line-decorative); font-size: 12px;
}
.visual-timeline-item:last-child { border-bottom: none; }
