/* Danifo design system tokens (primitives -> semantics -> recipes). Must precede all rules. */
@import "./assets/tokens/tokens.css";

/*
  Buona Fortuna Visualizer — restyled to the Danifo design system.
  Brand mark: NZT BusinessLab (maker) + Buona Fortuna (product).
  Local aliases below map the prototype's class names onto Danifo semantic
  tokens so we never hard-code brand hex in component rules.
*/
:root {
  --bf-ink: var(--text-primary);          /* navy */
  --bf-muted: var(--text-secondary);
  --bf-line: var(--border-subtle);
  --bf-line-strong: var(--border-strong);
  --bf-surface: var(--surface-default);   /* white */
  --bf-surface-2: var(--surface-elevated);/* light gray */
  --bf-navy: var(--surface-navy);
  --bf-orange: var(--action-default);
  --bf-orange-hover: var(--action-hover);
  --bf-orange-soft: rgba(244, 121, 41, 0.12);
  --bf-navy-soft: rgba(41, 37, 106, 0.06);
  --bf-radius: var(--radius-md);
  --bf-radius-sm: var(--radius-sm);
  --bf-radius-lg: var(--radius-lg);
  --bf-radius-pill: var(--radius-pill);
  --bf-shadow: 0 24px 72px rgba(41, 37, 106, 0.14);
  --bf-shadow-sm: 0 8px 22px rgba(41, 37, 106, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--bf-ink);
  background:
    radial-gradient(1100px 520px at 85% -140px, rgba(244, 121, 41, 0.08), transparent 62%),
    linear-gradient(180deg, var(--bf-surface), color-mix(in srgb, var(--bf-surface-2) 55%, white));
  background-attachment: fixed;
  font-family: var(--danifo-font-body);
  font-size: var(--ts-body);
  line-height: var(--lh-body);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(230px, 0.75fr) minmax(300px, 1.5fr) auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid var(--bf-line);
  border-radius: var(--bf-radius-lg);
  background: var(--bf-surface);
  box-shadow: var(--bf-shadow-sm);
}

.brand {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.brand-mark,
.brand-title {
  font-family: var(--danifo-font-display);
  font-weight: 900;
  font-size: clamp(22px, 2.4vw, 36px);
  line-height: 1;
  color: var(--bf-ink);
  letter-spacing: -0.01em;
}

.brand-sub {
  color: var(--bf-muted);
  font-size: 13px;
}

/* NZT BusinessLab maker mark (recreated wordmark + orange spark). */
.nzt-logo {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.nzt-spark {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--bf-orange);
}

.nzt-word {
  font-family: var(--danifo-font-body);
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bf-muted);
  white-space: nowrap;
}

.nzt-word strong {
  font-weight: 700;
  color: var(--bf-ink);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.status-pill {
  min-height: 48px;
  padding: 9px 12px;
  border: 1px solid var(--bf-line);
  border-radius: var(--bf-radius);
  background: var(--bf-surface);
}

.status-pill span {
  display: block;
  color: var(--bf-muted);
  font-size: var(--ts-eyebrow);
  font-weight: 700;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}

.status-pill strong {
  display: block;
  margin-top: 3px;
  line-height: 1.16;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(380px, 430px) minmax(0, 1fr) minmax(320px, 390px);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--bf-line);
  border-radius: var(--bf-radius-lg);
  background: var(--bf-surface);
  box-shadow: var(--bf-shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--bf-line);
}

.panel-title {
  margin: 0;
  font-family: var(--danifo-font-display);
  font-weight: 400;
  font-size: var(--ts-h3);
  line-height: var(--lh-h3);
  color: var(--bf-ink);
}

.panel-kicker {
  color: var(--bf-muted);
  font-size: var(--ts-eyebrow);
  font-weight: 700;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}

.panel-body {
  padding: 18px;
}

.section {
  margin-bottom: 22px;
}

.section:last-child {
  margin-bottom: 0;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--bf-muted);
  font-size: var(--ts-eyebrow);
  font-weight: 700;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}

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

.segmented.four {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chip,
.room-button,
.style-button {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--bf-line);
  border-radius: var(--bf-radius);
  background: var(--bf-surface);
  color: var(--bf-ink);
  font-weight: 400;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.chip:hover,
.room-button:hover,
.style-button:hover {
  transform: translateY(-1px);
  border-color: var(--bf-orange);
}

.chip.active,
.room-button.active,
.style-button.active {
  border-color: var(--bf-orange);
  background: var(--bf-orange-soft);
  color: var(--bf-ink);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--bf-orange);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

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

.api-endpoint {
  margin-top: 8px;
}

.api-model-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--bf-line);
  border-radius: var(--bf-radius);
  background: var(--bf-surface-2);
  color: var(--bf-muted);
  font-size: 12px;
}

.api-model-line span:first-child {
  color: var(--bf-ink);
  font-weight: 700;
}

.mode-badge {
  padding: 5px 9px;
  border-radius: var(--bf-radius-pill);
  background: var(--bf-navy);
  color: var(--text-on-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--bf-muted);
  font-size: 12px;
}

.field input,
.field select {
  min-height: 48px;
  width: 100%;
  border: 1px solid var(--bf-line);
  border-radius: var(--bf-radius);
  padding: 10px 12px;
  background: var(--bf-surface);
  color: var(--bf-ink);
}

.field input:focus,
.field select:focus,
.catalog-toolbar input:focus,
.catalog-toolbar select:focus {
  border-color: var(--bf-orange);
  box-shadow: 0 0 0 3px var(--bf-orange-soft);
  outline: 0;
}

.upload-zone {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px dashed var(--bf-line-strong);
  border-radius: var(--bf-radius);
  background: var(--bf-surface-2);
}

.upload-zone input {
  width: 100%;
}

.catalog-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.catalog-toolbar input,
.catalog-toolbar select {
  min-height: 48px;
  border: 1px solid var(--bf-line);
  border-radius: var(--bf-radius);
  padding: 10px 12px;
  background: var(--bf-surface);
  color: var(--bf-ink);
}

.product-list {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.product-card {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  min-height: 108px;
  border: 1px solid var(--bf-line);
  border-radius: var(--bf-radius);
  background: var(--bf-surface);
  box-shadow: var(--bf-shadow-sm);
  overflow: hidden;
}

.product-thumb {
  width: 88px;
  height: 106px;
  object-fit: cover;
}

.product-content {
  display: grid;
  gap: 8px;
  padding: 10px 10px 10px 0;
}

.product-title {
  font-weight: 700;
  line-height: 1.2;
}

.product-meta {
  color: var(--bf-muted);
  font-size: 13px;
}

.product-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.price {
  font-weight: 700;
  color: var(--bf-ink);
}

.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--bf-line);
  border-radius: var(--bf-radius);
  background: var(--bf-surface);
  overflow: hidden;
}

.qty button {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--bf-ink);
  font-size: 22px;
  line-height: 1;
}

.qty button:hover {
  color: var(--bf-orange);
}

.qty input {
  width: 58px;
  height: 38px;
  border: 0;
  border-left: 1px solid var(--bf-line);
  border-right: 1px solid var(--bf-line);
  text-align: center;
  color: var(--bf-ink);
  font-weight: 700;
}

.visual-stage {
  min-height: calc(100vh - 120px);
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  overflow: hidden;
}

.preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bf-navy);
}

.preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(1.04) contrast(1.02);
}

.preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  background: linear-gradient(180deg, rgba(41, 37, 106, 0.55), transparent 36%, rgba(41, 37, 106, 0.62));
  color: var(--text-on-dark);
}

.stage-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stage-tag {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: var(--bf-radius-pill);
  backdrop-filter: blur(10px);
  font-size: 13px;
  font-weight: 400;
}

.stage-caption {
  max-width: 720px;
}

.stage-caption h1 {
  margin: 0 0 8px;
  font-family: var(--danifo-font-display);
  font-weight: 900;
  font-size: clamp(32px, 4.4vw, 66px);
  line-height: 1;
  letter-spacing: -0.015em;
}

.stage-caption p {
  max-width: 620px;
  margin: 0;
  font-size: 17px;
  line-height: 1.45;
}

.generation-bar {
  padding: 14px 18px;
  border-top: 1px solid var(--bf-line);
  background: var(--bf-surface);
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: var(--bf-radius-pill);
  background: var(--bf-surface-2);
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: var(--bf-radius-pill);
  background: linear-gradient(90deg, var(--bf-orange), var(--bf-navy));
  transition: width 180ms ease;
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 18px;
}

.summary-list {
  display: grid;
  gap: 10px;
}

.summary-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--bf-line);
}

.summary-name {
  font-weight: 700;
}

.summary-meta {
  color: var(--bf-muted);
  font-size: 13px;
}

.total-box {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  padding: 16px;
  border-radius: var(--bf-radius);
  background: var(--bf-navy);
  border: 1px solid var(--bf-navy);
  color: var(--text-on-dark);
}

.total-box span {
  color: rgba(255, 255, 255, 0.7);
  font-size: var(--ts-eyebrow);
  font-weight: 700;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}

.total-box strong {
  font-family: var(--danifo-font-display);
  font-weight: 900;
  font-size: 28px;
  color: var(--text-on-dark);
}

.qr-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.qr-box {
  width: 112px;
  height: 112px;
  border: 1px solid var(--bf-line);
  border-radius: var(--bf-radius);
  background: var(--bf-surface);
  overflow: hidden;
}

.link-box {
  min-width: 0;
  color: var(--bf-muted);
  font-size: 13px;
  word-break: break-all;
}

.link-box strong {
  color: var(--bf-ink);
}

.link-box a {
  color: var(--bf-orange);
}

.lead-form {
  display: grid;
  gap: 10px;
}

.lead-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 8px;
}

.crm-log {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.crm-item {
  border: 1px solid var(--bf-line);
  border-radius: var(--bf-radius);
  padding: 10px;
  background: var(--bf-surface-2);
  font-size: 13px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow: auto;
}

.history-link {
  font-size: 12px;
  word-break: break-all;
  line-height: 1.35;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: var(--bf-radius-pill);
  background: var(--bf-surface);
  color: var(--bf-ink);
  border: 1px solid var(--bf-line);
  font-weight: 700;
  transition: transform 160ms ease, filter 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--bf-orange);
  color: var(--text-on-orange);
  border-color: var(--bf-orange);
  box-shadow: 0 12px 26px rgba(244, 121, 41, 0.28);
}

.btn.primary:hover {
  background: var(--bf-orange-hover);
  border-color: var(--bf-orange-hover);
}

.btn.accent {
  background: var(--bf-orange);
  color: var(--text-on-orange);
  border-color: var(--bf-orange);
  box-shadow: 0 12px 26px rgba(244, 121, 41, 0.28);
}

.btn.accent:hover {
  background: var(--bf-orange-hover);
  border-color: var(--bf-orange-hover);
}

.btn.brass {
  background: var(--bf-navy);
  color: var(--text-on-dark);
  border-color: var(--bf-navy);
  box-shadow: 0 12px 26px rgba(41, 37, 106, 0.24);
}

.btn.brass:hover {
  filter: brightness(1.08);
}

.btn.ghost {
  border-color: var(--bf-line-strong);
  background: var(--bf-surface);
  color: var(--bf-ink);
}

.btn.ghost:hover {
  border-color: var(--bf-orange);
  color: var(--bf-orange);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
}

.tiny {
  color: var(--bf-muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 20;
  max-width: min(520px, calc(100vw - 28px));
  transform: translateX(-50%) translateY(20px);
  padding: 14px 18px;
  border-radius: var(--bf-radius-pill);
  background: var(--bf-navy);
  color: var(--text-on-dark);
  font-weight: 400;
  box-shadow: var(--bf-shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.client-page {
  min-height: 100vh;
  background: var(--bf-surface);
}

.client-hero {
  min-height: 76vh;
  display: grid;
  align-items: end;
  padding: 28px;
  background-position: center;
  background-size: cover;
  color: var(--text-on-dark);
  position: relative;
}

.client-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(41, 37, 106, 0.32), rgba(41, 37, 106, 0.78));
}

.client-hero-content {
  position: relative;
  max-width: 980px;
  display: grid;
  gap: 14px;
}

.client-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--danifo-font-body);
  font-weight: 700;
  font-size: var(--ts-eyebrow);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-on-dark);
}

.client-eyebrow .nzt-spark {
  width: 14px;
  height: 14px;
}

/* NZT mark sits on the dark hero — force the wordmark to read on navy. */
.client-eyebrow .nzt-word,
.client-eyebrow .nzt-word strong {
  color: var(--text-on-dark);
}

.client-hero h1 {
  margin: 0;
  font-family: var(--danifo-font-display);
  font-weight: 900;
  font-size: clamp(40px, 6.4vw, 92px);
  line-height: 1;
  letter-spacing: -0.02em;
}

.client-hero p {
  max-width: 640px;
  margin: 0;
  font-size: 20px;
  line-height: 1.45;
}

.client-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  padding: 28px;
}

.client-section {
  border-top: 1px solid var(--bf-line);
  padding-top: 18px;
}

.client-section h2 {
  margin: 0 0 14px;
  font-family: var(--danifo-font-display);
  font-weight: 400;
  font-size: var(--ts-h2);
  line-height: var(--lh-h2);
  color: var(--bf-ink);
}

.client-products {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.client-product {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--bf-line);
  border-radius: var(--bf-radius);
  background: var(--bf-surface);
  overflow: hidden;
}

.client-product img {
  width: 82px;
  height: 100%;
  min-height: 96px;
  object-fit: cover;
}

.client-product div {
  padding: 10px 10px 10px 0;
}

.client-aside {
  align-self: start;
  border: 1px solid var(--bf-line);
  border-radius: var(--bf-radius-lg);
  padding: 20px;
  background: var(--bf-surface);
  box-shadow: var(--bf-shadow-sm);
}

.client-aside p {
  color: var(--bf-muted);
  font-size: 14px;
  line-height: 1.5;
}

/* Client page maker footer (Danifo running-foot pattern, forked locally). */
.client-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 18px 28px 28px;
  border-top: 1px solid var(--bf-line);
  color: var(--bf-muted);
  font-size: 12px;
}

.empty {
  min-height: 130px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--bf-line-strong);
  border-radius: var(--bf-radius);
  color: var(--bf-muted);
  text-align: center;
  padding: 18px;
}

@media (max-width: 1220px) {
  .layout {
    grid-template-columns: 380px minmax(0, 1fr);
  }

  .summary-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 920px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .layout,
  .client-content {
    grid-template-columns: 1fr;
  }

  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-actions,
  .result-actions {
    grid-template-columns: 1fr;
    display: grid;
  }


  .client-products {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .field-grid,
  .api-grid,
  .segmented,
  .segmented.four,
  .lead-grid,
  .qr-row {
    grid-template-columns: 1fr;
  }

  .qr-box {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .product-card {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .product-thumb {
    width: 76px;
  }

  .stage-caption h1 {
    font-size: 34px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .top-actions,
  .config-panel,
  .catalog-toolbar,
  .lead-form,
  .result-actions,
  .upload-zone {
    display: none !important;
  }

  .app-shell,
  .layout {
    display: block;
    padding: 0;
  }

  .panel {
    box-shadow: none;
    border: 0;
  }
}
