/* Survey renderer (components/interactive/survey.tsx). The original
   injects these rules at runtime into <style id="survey-global-styles">
   from the template strings containerStyles, questionStyles,
   footerStyles, successStyles and darkModeStyles; they are copied here
   verbatim (dark mode already used .dark). Port additions follow at the
   end. */

/* ---- containerStyles ---- */
  .survey-container {
    width: 100%;
  }

  .survey-progress {
    height: 2px;
    background: hsl(var(--border));
    margin-bottom: 2rem;
    border-radius: 1px;
    overflow: hidden;
  }

  .survey-progress-fill {
    height: 100%;
    background: hsl(var(--foreground));
    transition: width 0.3s ease;
  }

  .survey-empty {
    text-align: center;
    color: hsl(var(--muted-foreground));
    padding: 4rem 2rem;
  }

/* ---- questionStyles ---- */
  .survey-questions {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }

  .survey-question {
    display: flex;
    gap: 0;
    padding: 0;
    border: 1px solid hsl(var(--border));
    transition: all 0.3s ease;
    cursor: pointer;
  }

  .survey-question.active {
    border-color: hsl(var(--foreground));
  }

  .survey-question-highlight {
    animation: highlight 0.6s ease;
  }

  @keyframes highlight {
    0%, 100% { border-color: hsl(var(--border)); }
    50% { border-color: hsl(var(--foreground)); }
  }

  .survey-question-number {
    flex-shrink: 0;
    width: 48px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 1.25rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    background: hsl(var(--muted) / 0.3);
    border-right: 1px solid hsl(var(--border));
  }

  .survey-question.active .survey-question-number {
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    border-color: hsl(var(--foreground));
  }

  .survey-question.completed .survey-question-number {
    background: hsl(var(--muted) / 0.5);
    color: hsl(var(--foreground));
  }

  .survey-question-content {
    flex: 1;
    min-width: 0;
    padding: 1.25rem;
  }

  .survey-label {
    display: block;
    font-size: 1rem;
    font-weight: 400;
    margin-bottom: 0.75rem;
    color: hsl(var(--foreground));
  }

  .survey-required {
    color: hsl(var(--destructive, 0 84% 60%));
    margin-left: 0.25rem;
  }

  .survey-description {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.75rem;
  }

  .survey-input {
    margin-bottom: 0.5rem;
  }

  .survey-error {
    color: hsl(var(--destructive, 0 84% 60%));
    font-size: 0.75rem;
    margin-top: 0.25rem;
  }

  /* Text inputs */
  .survey-text-input,
  .survey-textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    border: 1px solid hsl(var(--border));
    background: transparent;
    color: hsl(var(--foreground));
    transition: border-color 0.15s;
    border-radius: 0;
  }

  .survey-text-input:focus,
  .survey-textarea:focus {
    outline: none;
    border-color: hsl(var(--foreground));
  }

  .survey-textarea {
    resize: vertical;
    min-height: 80px;
  }

  /* Options (radio/checkbox) */
  .survey-options {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .survey-options-row {
    flex-direction: row;
    gap: 0;
  }

  .survey-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem;
    text-align: left;
    font-size: 0.875rem;
    font-family: inherit;
    border: 1px solid hsl(var(--border));
    border-bottom: none;
    background: transparent;
    color: hsl(var(--foreground));
    cursor: pointer;
    transition: background 0.15s;
  }

  .survey-options-row .survey-option {
    flex: 1;
    justify-content: center;
    border-bottom: 1px solid hsl(var(--border));
    border-right: none;
  }

  .survey-options-row .survey-option:last-child {
    border-right: 1px solid hsl(var(--border));
  }

  .survey-option:last-child {
    border-bottom: 1px solid hsl(var(--border));
  }

  .survey-option:hover {
    background: hsl(var(--muted));
  }

  .survey-option.selected {
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    border-color: hsl(var(--foreground));
  }

  .survey-option.selected + .survey-option {
    border-top-color: hsl(var(--foreground));
  }

  .survey-option-radio {
    width: 14px;
    height: 14px;
    border: 1px solid currentColor;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .survey-option.selected .survey-option-radio {
    background: currentColor;
    box-shadow: inset 0 0 0 3px hsl(var(--foreground));
  }

  .survey-option-checkbox {
    width: 14px;
    height: 14px;
    border: 1px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    flex-shrink: 0;
  }

  /* Scale */
  .survey-scale {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .survey-scale-label {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
  }

  .survey-scale-options {
    display: flex;
    flex: 1;
  }

  .survey-scale-btn {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.875rem;
    font-family: inherit;
    border: 1px solid hsl(var(--border));
    border-right: none;
    background: transparent;
    color: hsl(var(--foreground));
    cursor: pointer;
    transition: all 0.15s;
  }

  .survey-scale-btn:last-child {
    border-right: 1px solid hsl(var(--border));
  }

  .survey-scale-btn:hover {
    background: hsl(var(--muted));
  }

  .survey-scale-btn.selected {
    background: hsl(var(--foreground));
    color: hsl(var(--background));
  }

  /* Rating */
  .survey-rating {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0;
  }

  .survey-rating-btn {
    padding: 0.375rem;
    font-size: 2rem;
    background: none;
    border: none;
    color: hsl(var(--border));
    cursor: pointer;
    transition: color 0.15s, transform 0.15s;
  }

  .survey-rating-btn:hover {
    color: hsl(var(--foreground));
    transform: scale(1.1);
  }

  .survey-rating-btn.filled {
    color: hsl(var(--foreground));
  }

  /* File upload */
  .survey-file {
    position: relative;
  }

  .survey-file-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
  }

  .survey-file-label {
    display: block;
    padding: 1.5rem;
    text-align: center;
    font-size: 0.875rem;
    border: 1px dashed hsl(var(--border));
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    transition: all 0.15s;
  }

  .survey-file-label:hover {
    border-color: hsl(var(--foreground));
    color: hsl(var(--foreground));
  }

  /* Ranking */
  .survey-ranking {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .survey-ranking-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid hsl(var(--border));
    border-bottom: none;
  }

  .survey-ranking-item:last-child {
    border-bottom: 1px solid hsl(var(--border));
  }

  .survey-ranking-num {
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    width: 20px;
  }

  .survey-ranking-text {
    flex: 1;
  }

  .survey-ranking-controls {
    display: flex;
    flex-direction: column;
    gap: 1px;
  }

  .survey-ranking-controls button {
    padding: 0.125rem 0.375rem;
    font-size: 0.5rem;
    background: none;
    border: 1px solid hsl(var(--border));
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    line-height: 1;
  }

  .survey-ranking-controls button:hover:not(:disabled) {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
  }

  .survey-ranking-controls button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
  }

  /* Matrix */
  .survey-matrix {
    overflow-x: auto;
    font-size: 0.75rem;
  }

  .survey-matrix-header,
  .survey-matrix-row {
    display: flex;
  }

  .survey-matrix-cell {
    flex: 1;
    min-width: 60px;
    padding: 0.375rem;
    text-align: center;
    border: 1px solid hsl(var(--border));
    border-right: none;
    border-bottom: none;
  }

  .survey-matrix-cell:last-child {
    border-right: 1px solid hsl(var(--border));
  }

  .survey-matrix-row:last-child .survey-matrix-cell {
    border-bottom: 1px solid hsl(var(--border));
  }

  .survey-matrix-row-label {
    text-align: left;
    font-weight: 500;
    min-width: 100px;
  }

  .survey-matrix-col {
    font-weight: 500;
    color: hsl(var(--muted-foreground));
  }

  .survey-matrix-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid hsl(var(--border));
    background: transparent;
    cursor: pointer;
    font-size: 0.5rem;
    transition: all 0.15s;
  }

  .survey-matrix-btn:hover {
    border-color: hsl(var(--foreground));
  }

  .survey-matrix-btn.selected {
    background: hsl(var(--foreground));
    border-color: hsl(var(--foreground));
    color: hsl(var(--background));
  }

/* ---- footerStyles ---- */
  .survey-footer {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid hsl(var(--border));
  }

  .survey-submit {
    width: 100%;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    border: none;
    border-radius: 0;
    cursor: pointer;
    position: relative;
    box-shadow:
      0 4px 0 0 hsl(var(--foreground) / 0.3),
      0 4px 8px -2px hsl(var(--foreground) / 0.2);
    transform: translateY(0);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
  }

  .survey-submit:hover {
    transform: translateY(-2px);
    box-shadow:
      0 6px 0 0 hsl(var(--foreground) / 0.3),
      0 6px 12px -2px hsl(var(--foreground) / 0.25);
  }

  .survey-submit:active {
    transform: translateY(2px);
    box-shadow:
      0 2px 0 0 hsl(var(--foreground) / 0.3),
      0 2px 4px -2px hsl(var(--foreground) / 0.2);
  }

  .survey-hint {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    text-align: right;
  }

  .survey-hint kbd {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    font-size: 0.625rem;
    font-family: inherit;
    background: hsl(var(--muted));
    border: 1px solid hsl(var(--border));
    border-radius: 2px;
  }

/* ---- successStyles ---- */
  .survey-success {
    text-align: center;
    padding: 4rem 2rem;
  }

  .survey-success-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1.5rem;
  }

  .survey-success h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
  }

  .survey-success p {
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
  }

/* ---- darkModeStyles ---- */
  .dark .survey-question.active .survey-question-number {
    background: hsl(0 0% 85%);
    color: hsl(var(--background));
    border-color: hsl(0 0% 85%);
  }

  .dark .survey-option.selected {
    background: hsl(0 0% 85%);
    color: hsl(var(--background));
    border-color: hsl(0 0% 85%);
  }

  .dark .survey-option.selected + .survey-option {
    border-top-color: hsl(0 0% 85%);
  }

  .dark .survey-scale-btn.selected {
    background: hsl(0 0% 85%);
    color: hsl(var(--background));
  }

  .dark .survey-rating-btn.filled {
    color: hsl(0 0% 85%);
  }

  .dark .survey-rating-btn:hover {
    color: hsl(0 0% 85%);
  }

  .dark .survey-matrix-btn.selected {
    background: hsl(0 0% 85%);
    border-color: hsl(0 0% 85%);
    color: hsl(var(--background));
  }

  .dark .survey-submit {
    background: hsl(0 0% 85%);
    color: hsl(var(--background));
    box-shadow:
      0 4px 0 0 hsl(0 0% 60%),
      0 4px 8px -2px hsl(0 0% 0% / 0.3);
  }

  .dark .survey-submit:hover {
    box-shadow:
      0 6px 0 0 hsl(0 0% 60%),
      0 6px 12px -2px hsl(0 0% 0% / 0.35);
  }

  .dark .survey-submit:active {
    box-shadow:
      0 2px 0 0 hsl(0 0% 60%),
      0 2px 4px -2px hsl(0 0% 0% / 0.3);
  }

  .dark .survey-success-icon {
    background: hsl(0 0% 85%);
  }

  .dark .survey-text-input:focus,
  .dark .survey-textarea:focus {
    border-color: hsl(0 0% 70%);
  }

  .dark .survey-question.active {
    border-color: hsl(0 0% 70%);
  }

  .dark .survey-file-label:hover {
    border-color: hsl(0 0% 70%);
    color: hsl(0 0% 85%);
  }

  .dark .survey-option:hover {
    background: hsl(0 0% 15%);
  }

  .dark .survey-scale-btn:hover {
    background: hsl(0 0% 15%);
  }

  .dark .survey-ranking-controls button:hover:not(:disabled) {
    background: hsl(0 0% 15%);
  }

  .dark .survey-matrix-btn:hover {
    border-color: hsl(0 0% 70%);
  }

/* ---- port additions ---- */

/* Conditional questions stay in the DOM, hidden. */
.survey-questions[hidden],
.survey-question[hidden],
.survey-footer[hidden] {
  display: none;
}

/* surveys/page.tsx and surveys/[slug]/client.tsx:
   container max-w-[672px] mx-auto px-4 py-8 */
.survey-page {
  width: 100%;
  max-width: 672px;
  margin-left: auto;
  margin-right: auto;
  padding: 2rem 1rem;
}

/* text-xs text-muted-foreground mt-4 mb-6 */
.survey-est {
  font-size: .75rem;
  line-height: 1rem;
  color: hsl(var(--muted-foreground));
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

/* mt-8 */
.survey-body {
  margin-top: 2rem;
}

/* aria-live: mt-4 min-h-5 text-sm */
.survey-status {
  margin-top: 1rem;
  min-height: 1.25rem;
  font-size: .875rem;
  line-height: 1.25rem;
}
.survey-status-busy {
  color: hsl(var(--muted-foreground));
}
.survey-status-error {
  color: rgb(220 38 38);
}
.dark .survey-status-error {
  color: rgb(248 113 113);
}

/* LiveClock: mt-16 wrapper, text-sm text-muted-foreground mt-12 */
.survey-clock-wrap {
  margin-top: 4rem;
}
.survey-clock {
  font-size: .875rem;
  line-height: 1.25rem;
  color: hsl(var(--muted-foreground));
  margin-top: 3rem;
}

/* ---- /surveys index (surveys/client.tsx) ---- */

/* mt-8 */
.surveys-list {
  margin-top: 2rem;
}
.surveys-empty {
  text-align: center;
  padding-top: 2.5rem;
  padding-bottom: 2.5rem;
  color: hsl(var(--muted-foreground));
}
/* w-full text-sm border border-border overflow-hidden shadow-sm */
.surveys-table {
  width: 100%;
  font-size: .875rem;
  line-height: 1.25rem;
  border-width: 1px;
  border-color: hsl(var(--border));
  overflow: hidden;
  box-shadow: 0 0 #0000, 0 0 #0000, 0 1px 2px 0 #0000000d;
}
/* border-b border-border bg-muted/50 text-foreground */
.surveys-head {
  border-bottom-width: 1px;
  border-color: hsl(var(--border));
  background-color: hsl(var(--muted) / .5);
  color: hsl(var(--foreground));
}
/* py-2 text-left font-medium px-3 */
.surveys-head th {
  padding: .5rem .75rem;
  text-align: left;
  font-weight: 500;
}
/* relative border-b border-border hover:bg-secondary/50 transition-colors
   cursor-pointer, bg-transparent / bg-muted/5 alternating */
.surveys-row {
  position: relative;
  border-bottom-width: 1px;
  border-color: hsl(var(--border));
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
  transition-duration: .15s;
  transition-timing-function: cubic-bezier(.4, 0, .2, 1);
  cursor: pointer;
  background-color: #0000;
}
.surveys-row.odd {
  background-color: hsl(var(--muted) / .05);
}
.surveys-row:hover {
  background-color: hsl(var(--secondary) / .5);
}
/* py-2 px-3 */
.surveys-row td {
  padding: .5rem .75rem;
}
.surveys-title {
  font-weight: 500;
}
/* text-foreground no-underline after:absolute after:inset-0 after:z-10 */
.surveys-title a {
  color: hsl(var(--foreground));
  text-decoration-line: none;
}
.surveys-title a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 10;
}

