/* Pub/Sub Workshop App Styles */

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: #f5f7f9;
}

/* Header */
.header {
  background: #002b45;
  color: white;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  height: 36px;
}

.container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
}

.app-footer {
  margin: 10px auto 20px;
  padding: 0 16px;
  max-width: 1100px;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #1f2a37;
  text-decoration: none;
  border: 1px solid #cfd4d9;
  border-radius: 6px;
  background: #ffffff;
  padding: 8px 12px;
  font-size: 13px;
}

.github-link:hover {
  background: #f5f7fa;
}

.github-icon {
  width: 16px;
  height: 16px;
}

/* Card / collapsible sections */
.card {
  background: #ffffff;
  border-radius: 6px;
  margin-bottom: 16px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

summary {
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
}

/* Smooth collapse support */
.card-body {
  overflow: hidden;
  height: auto;
  will-change: height;
}

details:not([open]) .card-body {
  height: 0;
  pointer-events: none;
}

/* Labels and help text */
label {
  font-size: 13px;
  line-height: 1.3;
  color: #333;
}

.section-desc{
  margin: 6px 0 12px;
  font-size: 13px;
  line-height: 1.35;
  color: #555;
}

/* Inputs/selects/textarea defaults */
input,
select,
textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: monospace;
  border-radius: 6px;
  border: 1px solid #cfd4d9;
  padding: 6px 8px;
  margin-bottom: 8px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #0077b6;
}

/* Form grid used in Step 1 */
.form-grid {
  display: grid;
  grid-template-columns:
    max-content minmax(260px, 1fr)
    max-content minmax(180px, 320px);
  gap: 8px 12px;
  align-items: center;
  max-width: 1000px;
}

/* Single-column form grid variant (used in Step 4 to avoid whitespace) */
.form-grid-single {
  grid-template-columns: max-content minmax(260px, 1fr);
}

.form-grid-single input,
.form-grid-single textarea,
.form-grid-single select {
  max-width: none;
}

.step1-workshop-subsection {
  max-width: 1000px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e4e7eb;
}

.step1-workshop-title {
  font-size: 13px;
  font-weight: 600;
  color: #1f2a37;
  margin-bottom: 8px;
}

.radio-inline-group {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 30px;
}

.radio-inline-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.radio-inline-option input[type="radio"] {
  width: 14px;
  height: 14px;
  margin: 0;
}

/* Responsive: stack form fields vertically on narrow screens */
@media (max-width: 820px) {
  .form-grid {
    grid-template-columns: 1fr;
    gap: 6px 0;
  }

  .form-grid label {
    margin-top: 8px;
  }

  .form-grid input,
  .form-grid textarea,
  .form-grid select {
    width: 100%;
    max-width: none;
  }
}

/* Buttons */
.ports-btn{
  font-size: 12px;
  padding: 2px 10px;
  border: 1px solid #cfd4d9;
  background: #f8f9fb;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1.4;
}

.ports-btn:hover{
  background: #eef2f6;
}

.ports-btn-primary {
  background: #0077b6;
  color: #ffffff;
  border-color: #0077b6;
}

.ports-btn-primary:hover {
  background: #006aa3;
}

.btn-danger {
  background: #c0392b;
  color: #ffffff;
  border-color: #c0392b;
}

.btn-danger:hover {
  background: #a93226;
}

/* Step 3 subscription input + button responsive row */
.sub-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  max-width: 900px;
}

.sub-input-row .sub-input {
  flex: 1 1 340px;
  min-width: 220px;
  max-width: none;
}

.sub-input-col {
  flex: 1 1 auto;
}

.sub-input-row .sub-btn {
  flex: 0 0 auto;
  margin-bottom: 8px;
}

@media (max-width: 520px) {
  .sub-input-row .sub-btn {
    width: 100%;
  }
}

/* Subscriptions table */
.subs-table {
  width: 100%;
  max-width: 1000px;
  border-collapse: collapse;
}

.subs-table th,
.subs-table td {
  text-align: left;
  vertical-align: middle;
  padding: 8px;
  border: 1px solid #e4e7eb;
  font-size: 13px;
  white-space: nowrap;
}

.subs-table td:nth-child(1) {
  white-space: normal; /* pattern can wrap */
}

.subs-table th {
  background: #f0f2f5;
  font-weight: 600;
}

/* Utility: hidden element (used for subsTable + banners) */
.is-hidden {
  display: none;
}

/* Subscription status pill */
.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #cfd4d9;
  background: #f8f9fb;
  font-size: 12px;
  font-weight: 600;
  color: #333;
}

/* Clickable subscription suggestion pill */
.pub-sub-suggestion {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid #0071c5;
  background: #e3f2fd;
  font-size: 13px;
  font-weight: 400;
  color: #0071c5;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pub-sub-suggestion:hover {
  background: #0071c5;
  color: white;
  box-shadow: 0 2px 8px rgba(0, 113, 197, 0.3);
}

.pub-sub-suggestion.pub-sub-suggestion-highlight {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.28);
  animation: topic-level-added-pulse 1600ms ease-out 1;
}

/* Textareas and action rows */
#log {
  max-width: 1000px;
}

.message-stream {
  width: 100%;
  max-width: 1000px;
  box-sizing: border-box;
  font-family: monospace;
  font-size: 13px;
  line-height: 1.35;
  border-radius: 6px;
  border: 1px solid #cfd4d9;
  background: #ffffff;
  padding: 6px 8px;
  height: 230px;
  overflow-y: auto;
  overflow-x: hidden;
}

.message-row {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 6px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}

.message-row-odd {
  background: #f7fbff;
}

.message-row-even {
  background: #eef3f8;
}

.message-row:last-child {
  margin-bottom: 0;
}

.below-box-actions {
  margin: 6px 0 0;
  max-width: 1000px;
}

/* Subscriptions empty hint */
#subsEmptyHint {
  font-size: 13px;
  color: #555;
  margin: 6px 0 10px;
}

#subsEmptyHint.subs-empty-hint-spaced {
  margin: 18px 0 10px;
}

.pub-sub-suggestions-label {
  overflow: hidden;
  margin-top: 0;
  margin-bottom: 8px;
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  transition: max-height 260ms ease, opacity 200ms ease, transform 260ms ease;
}

.pub-sub-suggestions-label.is-visible {
  max-height: 220px;
  opacity: 1;
  transform: translateY(0);
}

.pub-sub-suggestions-label.suggestion-attention-highlight {
  border: 2px solid #f59e0b;
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.45);
  animation: suggestion-attention-pulse 1800ms ease-out 1;
}

.sub-input-row.subscription-controls-attention-highlight {
  border: 2px solid #f59e0b;
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.45);
  animation: suggestion-attention-pulse 1800ms ease-out 1;
}

.pub-sub-suggestions-title {
  font-weight: 400;
  font-size: 12px;
  display: block;
  margin-bottom: 0;
}

.pub-sub-suggestions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Inline status/help banner */
.status-banner {
  max-width: 1000px;
  border-radius: 6px;
  border: 1px solid #cfd4d9;
  padding: 10px 12px;
  margin: 0 0 10px;
  background: #f8f9fb;
}

.status-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
}

.status-hint {
  font-size: 13px;
  line-height: 1.35;
  color: #333;
}

.status-hint code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.95em;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  padding: 1px 4px;
}

.status-info {
  border-color: #b9c7d4;
  background: #f3f7fb;
}

.status-success {
  border-color: #b7dfc2;
  background: #f2fbf4;
}

.status-warn {
  border-color: #f2d59b;
  background: #fff8e7;
}

.status-error {
  border-color: #f0b4b4;
  background: #fff2f2;
}

/* Banners inside sections (Step 3/4) */
.section-status {
  margin-top: 12px;
}

.suggestion-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.action-suggestion-banner {
  border-color: #d7c3f2;
  background: #f8f2ff;
  animation: suggestion-slide-in-right 460ms ease-out;
}

.action-suggestion-banner .status-title {
  color: #4a2a7a;
}

.action-suggestion-banner .status-hint {
  color: #5d4685;
}

.action-suggestion-banner .suggestion-actions .ports-btn-primary {
  background: #6f42c1;
  border-color: #6f42c1;
}

.action-suggestion-banner .suggestion-actions .ports-btn-primary:hover {
  background: #6037ad;
}

.action-suggestion-banner.guidance-banner {
  border-color: #facc15;
  background: #fffbeb;
}

.action-suggestion-banner.guidance-banner .status-title {
  color: #854d0e;
}

.action-suggestion-banner.guidance-banner .status-hint {
  color: #713f12;
}

.action-suggestion-banner.guidance-banner .suggestion-actions .ports-btn-primary {
  background: #ca8a04;
  border-color: #ca8a04;
}

.action-suggestion-banner.guidance-banner .suggestion-actions .ports-btn-primary:hover {
  background: #a16207;
}

@keyframes suggestion-slide-in-right {
  from {
    opacity: 0;
    transform: translateX(34px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes suggestion-attention-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.45);
  }
  100% {
    box-shadow: 0 0 0 12px rgba(245, 158, 11, 0);
  }
}

/* Mobile header compaction */
@media (max-width: 500px) {
  .header {
    padding: 10px 14px;
    gap: 10px;
  }

  .logo {
    height: 28px;
  }

  .header h1 {
    margin: 0;
    font-size: 16px;
    line-height: 1.2;
  }
}

/* Compact style toggle in Step 4: keep radios on a single row */
#step4Card .style-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

#step4Card .style-toggle label,
#step4Card .delivery-toggle label {
  margin: 0;
  font-size: 13px;
}

#step4Card .step4-top-row,
#step4Card .step4-adv-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#step4Card .section-desc-tight {
  margin: 0;
}

#step4Card .style-toggle-offset {
  margin-left: 12px;
}

#step4Card .toggle-group-title,
#step4Card .topic-builder-title {
  font-weight: 600;
}

#step4Card .radio-option-spaced {
  margin-right: 6px;
}

#step4Card .form-grid-top-gap {
  margin-top: 10px;
}

#step4Card .topic-builder-grid {
  margin-top: 10px;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

#step4Card .topic-builder-grid input[type="text"] {
  width: calc(100% + 1ch);
  max-width: calc(100% + 1ch);
}

#step4Card .topic-builder-grid input.topic-level-added-highlight {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.28);
  animation: topic-level-added-pulse 1600ms ease-out 1;
}

#step4Card .topic-builder-clear-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#step4Card .topic-taxonomy-hints {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.4;
  color: #4b5563;
}

#step4Card .taxonomy-change-banner {
  margin-top: 8px;
  background: #f3f4f6;
  border-color: #d1d5db;
}

#step4Card .taxonomy-change-banner .status-title,
#step4Card .taxonomy-change-banner .status-hint {
  color: #374151;
}

#step4Card .taxonomy-change-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#step4Card .taxonomy-change-close {
  border: 1px solid #cfd4d9;
  background: #ffffff;
  color: #4b5563;
  border-radius: 4px;
  cursor: pointer;
  width: 22px;
  height: 22px;
  line-height: 18px;
  padding: 0;
}

#step4Card .style-toggle input[type="radio"],
#step4Card .delivery-toggle input[type="radio"] {
  width: 14px;
  height: 14px;
  vertical-align: middle;
}

/* Step 4 specific narrow-screen stacking at 520px */
@media (max-width: 520px) {
  .pub-sub-suggestions-label {
    transition: max-height 180ms ease, opacity 150ms ease, transform 180ms ease;
  }

  .action-suggestion-banner {
    animation: suggestion-slide-in-right 260ms ease-out;
  }

  #step4Card #topicBuilderSection {
    transition: max-height 220ms ease, opacity 170ms ease;
  }

  /* Stack the style toggle vertically */
  #step4Card .style-toggle {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-top: 8px;
    gap: 6px;
  }

  #step4Card .style-toggle label {
    display: flex;
    align-items: center;
    margin-right: 0;
    margin-bottom: 0;
    gap: 6px;
  }

  /* Stack the topic taxonomy builder grid from 7 columns to single column */
  #step4Card .topic-builder-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  #step4Card .topic-builder-grid > div {
    width: 100%;
  }

#step4Card .topic-builder-grid input[type="text"] {
    width: 100%;
    max-width: 100%;
  }

  /* Stack form-grid-single (topic builder and payload area) into single column */
  #step4Card .form-grid-single {
    grid-template-columns: 1fr;
    gap: 6px 0;
  }

  #step4Card .form-grid-single label {
    margin-top: 8px;
  }

  #step4Card .form-grid-single input,
  #step4Card .form-grid-single textarea {
    width: 100%;
    max-width: none;
  }

  /* Keep delivery toggle inline but ensure label alignment */
  #step4Card .delivery-toggle label {
    display: flex;
    align-items: center;
    gap: 6px;
  }
}

@keyframes topic-level-added-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.44);
  }
  100% {
    box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
  }
}

/* Compact delivery mode toggle in Advanced panel */
#step4Card .delivery-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

/* Advanced panel visual separation and spacing */
#step4Card #advancedOptions,
#step4Card #basicOptions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e9eef2;
}

#step4Card #advancedOptions > div:first-child,
#step4Card #basicOptions > .form-grid {
  margin-bottom: 10px;
}

#step4Card #topicBuilderSection {
  overflow: hidden;
  max-height: 900px;
  opacity: 1;
  background: #f4f9ff;
  border: 1px solid #d7e6f5;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  transition: max-height 300ms ease, opacity 220ms ease;
}

#step4Card #topicBuilderSection.is-collapsed {
  max-height: 0;
  opacity: 0;
}

@media (max-width: 520px) {
  #step4Card #topicBuilderSection {
    max-height: 1600px;
  }
}

#step4Card #advancedOptions > #topicBuilderSection.is-collapsed {
  margin-bottom: 0;
}

#step4Card #advancedOptions .topic-field-divider {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e9eef2;
}

/* Add spacing before Publish button to separate from advanced controls */
#publish {
  margin-top: 14px;
}
