/**
 * Shared form view styles - used by both view-form (public) and create-form (builder preview).
 * Form builder adds .survey-question-actions for up/down/delete - those are builder-only.
 */

.form-card {
  background: #FFFFFF;
  width: 100%;
  border: 2px solid #282828;
  border-radius: 0;
  overflow: hidden;
}

.form-card .card-header {
  padding: 0;
  background: #FFFFFF;
  color: #000000;
  border-bottom: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

.form-card .header-content {
  padding: 2.5rem 4rem 2rem 4rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.5rem;
  background: #FFFFFF;
  text-align: left;
}

.form-card .header-content.align-center {
  align-items: center;
  text-align: center;
}

.form-card .header-content.align-right {
  align-items: flex-end;
  text-align: right;
}

.form-card .company-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.form-card .header-content.align-center .company-info {
  align-items: center;
  text-align: center;
}

.form-card .header-content.align-right .company-info {
  align-items: flex-end;
  text-align: right;
}

.form-card .company-info h2 {
  font-size: 2rem;
  font-weight: 700;
  color: #000000;
  margin: 0 0 0.5rem 0;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.form-card .company-info p {
  font-size: 0.875rem;
  color: #6B7280;
  margin: 0;
  line-height: 1.5;
  font-weight: 400;
  text-align: left;
}

.form-card .header-content.align-center .company-info p {
  text-align: center;
}

.form-card .header-content.align-right .company-info p {
  text-align: right;
}

.form-card .card-body {
  padding: 0rem 2rem 1rem 2rem;
}

.survey-section {
  padding: 0.75rem 2rem 1.5rem 2rem;
  background: #FFFFFF;
}

.survey-header {
  margin-bottom: 1.5rem;
}

.survey-title {
  font-size: 1rem;
  font-weight: 600;
  color: #000000;
  margin: 0 0 0.5rem 0;
}

.survey-subtitle {
  font-size: 0.875rem;
  color: #666666;
  margin: 0;
}

.survey-question,
.form-question {
  margin-bottom: 1.5rem;
  position: relative;
}

.survey-question:last-child,
.form-question:last-child {
  margin-bottom: 0;
}

/* 2-column row layout - minmax(0,1fr) lets columns shrink below content size */
.form-column-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

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

.form-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 2rem;
  min-width: 0;
  overflow: hidden; /* keep options/radio/dropdown from breaking out of column */
}

/* Constrain question content inside columns so they don't overflow */
.form-column .survey-question {
  min-width: 0;
  overflow: hidden;
}

.form-column .survey-options,
.form-column .survey-dropdown {
  min-width: 0;
  overflow: hidden;
}

.form-column .survey-select-input {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.form-column .survey-option {
  min-width: 0;
}

.form-column .survey-option .survey-label {
  min-width: 0;
  overflow-wrap: break-word;
}

.survey-question-error .question-text {
  color: #b91c1c;
}

/* Text module - same design as form header (company-info) */
.form-text-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

/* Shared typography for text module titles (single source of truth for view + builder) */
.form-text-title,
.survey-question-input.form-text-title {
  font-size: 1rem;
  font-weight: 600;
  color: #000000;
  margin: 0 0 0.25rem 0;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.form-text-block .form-text-paragraph,
.form-text-block p.form-text-paragraph {
  font-size: 0.875rem;
  color: #6B7280;
  margin: 0;
  line-height: 1.5;
  font-weight: 400;
}

.form-text-block textarea.form-text-paragraph {
  width: 100%;
  min-height: 80px;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  color: #6B7280;
  line-height: 1.5;
  font-family: inherit;
  resize: vertical;
}

.form-text-block textarea.form-text-paragraph:focus {
  outline: none;
}

.form-text-block textarea.form-text-paragraph::placeholder {
  color: #9ca3af;
}

.survey-question-text {
  margin-bottom: 1.5rem;
}

/* Builder: text module header layout (no sizing here, only layout tweaks if needed) */
.survey-question-text .survey-question-header-inner .form-text-title,
.survey-question-text input.form-text-title {
  margin: 0;
}

.survey-question-text .survey-question-header {
  margin-bottom: 0.5rem;
}

.survey-question-text .form-text-block textarea.form-text-paragraph {
  font-size: 0.875rem;
  color: #6B7280;
  line-height: 1.5;
  margin: 0;
}

/* Builder: title + actions in one row; input field stays full width below */
.survey-question-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 0.75rem;
}

.survey-question-header-inner {
  flex: 1;
  min-width: 0;
}

.survey-question-header-inner .survey-question-input {
  width: 100%;
  margin-bottom: 0; /* header provides spacing to field below */
}

.question-text {
  font-size: 0.875rem;
  font-weight: 500;
  color: #000000;
  margin: 0 0 0.75rem 0;
  line-height: 1.5;
}

/* Editable question title in builder (matches question-text) — obvious that you can type */
.survey-question-input {
  font-size: 0.875rem;
  font-weight: 500;
  color: #000000;
  margin: 0 0 0.75rem 0;
  line-height: 1.5;
  width: 100%;
  border: none;
  border-bottom: 1px dashed #d1d5db;
  background: transparent;
  padding: 0 0 4px 0;
  font-family: inherit;
  cursor: text;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.survey-question-input:hover {
  border-bottom-color: #9ca3af;
  background: rgba(0, 0, 0, 0.02);
}

.survey-question-input:focus {
  outline: none;
  border-bottom-style: solid;
  border-bottom-color: #000000;
  background: rgba(0, 0, 0, 0.03);
}

.survey-question-input::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

.survey-single-input {
  margin-top: 0.25rem;
}

.survey-text-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  font-family: inherit;
}

.survey-text-input:focus {
  outline: none;
  border-color: #000000;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
}

.survey-text-input::placeholder {
  color: #9CA3AF;
}

.survey-textarea-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  font-family: inherit;
  resize: vertical;
  min-height: 120px;
}

.survey-textarea-input:focus {
  outline: none;
  border-color: #000000;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
}

.survey-textarea-input::placeholder {
  color: #9CA3AF;
}

.survey-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.survey-dropdown {
  margin-top: 0.5rem;
}

.survey-select-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #D1D5DB;
  background: #FFFFFF;
  font-size: 0.875rem;
  color: #111827;
}

.survey-select-input:focus {
  outline: none;
  border-color: #000000;
}

.survey-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.survey-radio {
  width: 16px;
  height: 16px;
  border: 2px solid #CCCCCC;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}

.survey-radio.selected {
  border-color: #000000;
}

.survey-radio.selected::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: #000000;
  border-radius: 50%;
}

.survey-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid #D1D5DB;
  border-radius: 3px;
  position: relative;
  flex-shrink: 0;
  background: #FFFFFF;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.02);
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.survey-checkbox.selected {
  border-color: #000000;
  background: #000000;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.survey-checkbox.selected::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 4px;
  height: 8px;
  border: solid #FFFFFF;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.survey-label {
  font-size: 0.875rem;
  color: #333333;
  cursor: pointer;
}

.survey-submit-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #E0E0E0;
}

.survey-submit-section.align-left {
  text-align: left;
}

.survey-submit-section.align-center {
  text-align: center;
}

.survey-submit-section.align-right {
  text-align: right;
}

.survey-verification-wrap {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #E0E0E0;
}
.survey-verification-intro {
  font-size: 0.875rem;
  color: #6B7280;
  margin: 0 0 0.5rem 0;
  font-weight: 500;
}
.survey-verification-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
}
.survey-verification-input {
  display: block;
  width: 100%;
  max-width: 12rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid #E0E0E0;
  border-radius: 4px;
  background: #fff;
}
.survey-verification-input:focus {
  outline: none;
  border-color: #000;
}
.survey-verification-error {
  display: block;
  font-size: 0.8125rem;
  color: #ef4444;
  margin-top: 0.25rem;
}

.form-note-align-left {
  text-align: left;
  margin-left: 0;
  margin-right: auto;
}

.form-note-align-center {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

.form-note-align-right {
  text-align: right;
  margin-left: auto;
  margin-right: 0;
}

.survey-submit-btn {
  background: #000000;
  color: #FFFFFF;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.survey-submit-btn:hover {
  background: #333333;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.survey-submit-btn:active {
  transform: translateY(0);
}

.survey-submit-btn:disabled {
  background: #CCCCCC;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Builder-only: floating toolbar (Required + up/down/delete) pops up on module hover */
.survey-question-toolbar {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.survey-question:hover .survey-question-toolbar {
  opacity: 1;
  pointer-events: auto;
}

.survey-question-toolbar .survey-required-label {
  padding-right: 6px;
  border-right: 1px solid #e5e7eb;
}

.survey-question-toolbar .survey-question-actions {
  display: flex;
}

.survey-question-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  margin-right: 4px;
  margin-left: -2px;
  color: #9ca3af;
  cursor: grab;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}

.survey-question-drag-handle:hover {
  color: #6b7280;
  background: rgba(0, 0, 0, 0.04);
}

.survey-question-drag-handle:active {
  cursor: grabbing;
}

.survey-question.survey-question-dragging {
  opacity: 0.6;
  pointer-events: none;
}

.survey-required-label {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: #666;
  cursor: pointer;
  white-space: nowrap;
}

.survey-required-checkbox {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
}

/* Builder-only: up/down/delete controls on survey questions (in header row, don't shrink) */
.survey-question-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.survey-question-actions .survey-arrow-btn,
.survey-question-actions .remove-survey-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #fff;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.survey-question-actions .survey-arrow-btn:hover:not(:disabled),
.survey-question-actions .remove-survey-btn:hover {
  background: #f5f5f5;
  border-color: #ccc;
  color: #000;
}

.survey-question-actions .remove-survey-btn:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.survey-question-actions .survey-arrow-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  color: #bbb;
}

.survey-question-actions svg {
  width: 12px;
  height: 12px;
}

.survey-question-actions .remove-survey-btn svg {
  width: 14px;
  height: 14px;
}

@media (max-width: 640px) {
  .form-card .card-header {
    padding: 0;
    flex-direction: column;
    text-align: center;
  }
  .form-card .header-content {
    padding: 1.5rem 1.5rem 2rem 1.5rem;
  }
  .form-card .card-body {
    padding: 0rem 0 1.5rem 0;
  }
  .survey-section {
    padding: 1.5rem 1.5rem;
  }
}
