/* User portal generator, preview, progress, and history surfaces. */

body.mode-user .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

body.mode-user .sidebar,
body.mode-user .topbar,
body.mode-user .topbar-actions,
body.mode-user .eyebrow,
body.mode-user #pageSubtitle {
  display: none;
}

body.mode-user .workspace {
  grid-template-rows: minmax(0, 1fr);
}

body.mode-user .view {
  padding: 10px;
}

body.mode-user .creator-user-select {
  display: none;
}

body.mode-admin .creator-user-badge {
  display: none;
}

.creator-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: #fff;
}

.creator-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid #f2f2f2;
}

.creator-topbar div {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.creator-topbar span {
  color: #777;
  font-size: 13px;
}

.creator-user-select {
  width: 260px;
}

.creator-user-badge {
  min-height: 34px;
  padding: 8px 12px;
  border: 1px solid #f0d9de;
  border-radius: 8px;
  background: #fff8f9;
  color: var(--creator-red);
  font-size: 13px;
  font-weight: 700;
}

.creator-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.creator-layout {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: minmax(0, 920px);
  justify-content: center;
  align-content: start;
  gap: 18px;
  min-height: 0;
  overflow: auto;
  padding: 30px 28px;
  background: #fff;
}

.creator-compose,
.creator-preview {
  min-height: 0;
  overflow: visible;
  padding: 0;
}

.creator-compose {
  border: 1px solid #ebebeb;
  border-radius: 10px;
  padding: 24px 30px;
  background: linear-gradient(180deg, #fff, #fffafa);
}

.creator-preview {
  border-top: 1px solid #f0f0f0;
  padding: 18px 0 0;
  background: #fff;
}

.creator-heading span {
  color: var(--creator-red);
  font-size: 13px;
  font-weight: 700;
}

.creator-heading h2 {
  margin-top: 8px;
  max-width: 640px;
  font-size: 30px;
  line-height: 1.12;
}

.creator-form {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(300px, 1fr) 150px;
  gap: 16px;
  align-items: end;
  margin-top: 18px;
  max-width: 100%;
}

.creator-form label {
  min-width: 0;
}

.creator-primary {
  min-height: 52px;
  grid-column: auto;
  border: 0;
  border-radius: 8px;
  background: var(--creator-red);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.creator-primary:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

.creator-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.creator-preview-head strong {
  font-size: 16px;
}

.portal-tabs {
  display: flex;
  gap: 18px;
  border-bottom: 1px solid #ececec;
}

.portal-tabs button {
  min-height: 40px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0 2px;
  background: transparent;
  color: #777;
  font-weight: 700;
}

.portal-tabs button.is-active {
  border-bottom-color: var(--creator-red);
  color: var(--ink);
}

.portal-tab-panel {
  display: none;
  margin-top: 14px;
}

.portal-tab-panel.is-active {
  display: block;
}

.creator-mockup {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.creator-sample-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 12px;
  border-bottom: 1px solid #f0f0f0;
}

.creator-sample-summary strong {
  font-size: 15px;
}

.creator-sample-summary span {
  color: #666;
  font-size: 13px;
}

.creator-sample-image {
  display: block;
  width: 100%;
  max-height: 520px;
  overflow: hidden;
  border: 1px solid #eeeeee;
  border-radius: 8px;
  padding: 0;
  background: #fafafa;
  cursor: zoom-in;
}

.creator-sample-image img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  object-position: top center;
}

.sample-image-field {
  display: grid;
  gap: 10px;
}

.image-drop-zone {
  border: 1px dashed transparent;
  border-radius: 8px;
  padding: 8px;
  transition: border-color 120ms ease, background 120ms ease;
}

.image-drop-zone:focus-visible,
.image-drop-zone.is-drag-over {
  outline: none;
  border-color: #111111;
  background: #f7f7f7;
}

.upload-hint {
  color: #777;
  font-size: 12px;
  line-height: 1.5;
}

.sample-image-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sample-image-head span {
  color: #555;
  font-size: 13px;
  font-weight: 700;
}

.sample-image-head .secondary-button {
  min-height: 32px;
  padding: 0 12px;
}

.sample-image-field img,
.sample-image-empty {
  width: 100%;
  max-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}

.sample-image-field img {
  object-fit: contain;
}

.reference-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 240px));
  gap: 12px;
  align-items: start;
}

.reference-image-slot {
  max-width: 240px;
}

.reference-image-slot img,
.reference-image-slot .sample-image-empty {
  width: 100%;
  height: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}

.reference-image-slot img {
  display: block;
  object-fit: contain;
}

.reference-image-slot input {
  min-height: 34px;
  font-size: 12px;
}

.sample-image-empty {
  display: grid;
  min-height: 96px;
  place-items: center;
  color: #777;
  font-size: 13px;
}

.portal-result {
  padding: 0;
  border: 0;
  min-height: 120px;
  max-height: min(46vh, 520px);
  overflow: auto;
  background: #fff;
}

.portal-result:empty {
  display: none;
}

.result-state {
  display: grid;
  gap: 6px;
}

.result-state.is-error span {
  color: var(--danger);
}

.result-state span {
  color: var(--creator-red);
  font-size: 12px;
  font-weight: 700;
}

.result-state p {
  color: #666;
  line-height: 1.55;
}

.result-state .result-hint {
  color: #9f1239;
  font-size: 13px;
}

.result-ready-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.result-ready-head strong {
  min-width: 0;
  font-size: 16px;
  line-height: 1.35;
}

.result-ready-head span {
  flex: 0 0 auto;
  color: var(--creator-red);
  font-size: 12px;
  font-weight: 700;
}

.result-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.result-steps span {
  padding: 8px 0;
  border-bottom: 2px solid #f0f0f0;
  color: #555;
  font-size: 12px;
  text-align: center;
}

.result-steps span.is-active {
  border-bottom-color: #111;
  color: #111;
  font-weight: 700;
}

.portal-task-progress {
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #ffe5ea;
}

.portal-task-progress span {
  display: block;
  height: 100%;
  min-width: 8px;
  border-radius: inherit;
  background: var(--creator-red);
  transition: width 220ms ease;
}

.portal-progress-meta {
  margin-top: 12px;
  color: #555;
  font-size: 12px;
}

.portal-history {
  display: grid;
  max-height: min(40vh, 440px);
  overflow: auto;
  border: 1px solid #eeeeee;
  border-radius: 8px;
  background: #fff;
}

body.mode-user.portal-current-active .portal-result,
body.mode-user.portal-history-active .portal-history {
  max-height: min(40vh, 440px);
}

.portal-task-table-head,
.portal-task-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(190px, 0.9fr) minmax(72px, 0.36fr) minmax(110px, 0.45fr) minmax(150px, 0.65fr) 112px;
  min-width: 860px;
}

.portal-task-table-head {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid #eeeeee;
  background: #fafafa;
  color: #666;
  font-size: 12px;
  font-weight: 700;
}

.portal-task-table-head span {
  padding: 10px;
  border-right: 1px solid #eeeeee;
}

.portal-task-table-head span:last-child {
  border-right: 0;
}

.portal-task-row {
  border-bottom: 1px solid #eeeeee;
}

.portal-task-row:last-child {
  border-bottom: 0;
}

.portal-task-row:hover {
  background: #fafafa;
}

.portal-task-row-main {
  grid-column: 1 / 6;
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(190px, 0.9fr) minmax(72px, 0.36fr) minmax(110px, 0.45fr) minmax(150px, 0.65fr);
  align-items: center;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.portal-task-row-main > span,
.portal-task-row-actions {
  min-height: 52px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 9px 10px;
  border-right: 1px solid #eeeeee;
  color: #555;
  font-size: 12px;
}

.portal-task-row-main > span {
  overflow: hidden;
}

.portal-task-row-main > span:not(.task-title-cell) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-task-row-main:hover .task-title-cell strong {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.portal-task-row-actions {
  border-right: 0;
  justify-items: start;
}

.portal-task-row-actions button {
  position: relative;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  background: #fff;
  color: #333;
  font-size: 13px;
  font-weight: 700;
}

.portal-task-row-actions .trash-action {
  border-color: #fecaca;
  color: #dc2626;
  font-size: 0;
}

.portal-task-row-actions .trash-action::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 10px;
  width: 10px;
  height: 12px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 1px 1px 3px 3px;
}

.portal-task-row-actions .trash-action::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 7px;
  width: 12px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 3px -3px 0 -1px currentColor;
}

.portal-task-row-actions button + button {
  margin-top: 4px;
}

.portal-task-row .task-progress {
  width: 84px;
}

.portal-history-empty {
  padding: 12px;
  border: 1px dashed #e8c3ca;
  border-radius: 8px;
  color: #777;
  font-size: 13px;
}

@media (max-width: 1180px) {
  .creator-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: auto;
    justify-content: stretch;
    background: #fff;
  }

  .creator-compose {
    border-right: 1px solid #f2f2f2;
    border-bottom: 1px solid #f2f2f2;
  }

  .creator-compose,
  .creator-preview {
    overflow: visible;
  }

  .creator-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .creator-layout {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-rows: auto;
    align-content: start;
  }
}

@media (max-width: 720px) {
  .creator-topbar {
    display: grid;
  }

  .creator-user-select {
    width: 100%;
  }

  .creator-compose,
  .creator-preview {
    padding: 18px;
  }

  .creator-heading h2 {
    max-width: 100%;
    font-size: 28px;
  }

  .portal-tabs {
    width: 100%;
    gap: 12px;
  }

  .portal-tabs button {
    flex: 1 1 0;
    padding: 0;
  }

  .creator-sample-summary {
    display: grid;
  }

  .portal-task-table-head {
    display: none;
  }

  .portal-task-row {
    grid-template-columns: minmax(0, 1fr) auto;
    min-width: 0;
  }

  .portal-task-row-main {
    grid-column: auto;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .portal-task-row-main > span,
  .portal-task-row-actions {
    min-height: 48px;
    border-right: 0;
    padding: 10px;
  }

  .portal-task-row-main > span:nth-child(2),
  .portal-task-row-main > span:nth-child(4),
  .portal-task-row-main > span:nth-child(5) {
    display: none;
  }

  .portal-task-row-actions {
    min-width: 74px;
  }
}
