/**
 * Survey Styles - Optimized
 * Custom styling for the multi-page survey system with full light/dark mode support
 */

/* ===================================
   CSS CUSTOM PROPERTIES
   =================================== */

:root {
  /* Primary Brand Colors */
  --survey-primary: #008AFF;
  --survey-primary-dark: #0077dd;
  --survey-success: #28a745;
  --survey-warning: #ffc107;
  --survey-danger: #dc3545;

  /* Light Mode Colors */
  --survey-bg: #ffffff;
  --survey-bg-alt: #f8f9fa;
  --survey-text: #333;
  --survey-text-muted: #666;
  --survey-text-light: #555;
  --survey-border: #dee2e6;
  --survey-border-light: #ced4da;
  --survey-shadow: rgba(0, 0, 0, 0.1);

  /* Interactive Elements */
  --survey-input-bg: #ffffff;
  --survey-input-border: #ced4da;
  --survey-input-text: #333;

  /* Spacing */
  --survey-radius: 0.5rem;
  --survey-radius-sm: 0.375rem;
}

/* Dark Mode Custom Properties */
[data-theme="dark"] {
  --survey-bg: #1a1a1a;
  --survey-bg-alt: #2d2d2d;
  --survey-text: #e0e0e0;
  --survey-text-muted: #b0b0b0;
  --survey-text-light: #b0b0b0;
  --survey-border: #404040;
  --survey-border-light: #404040;
  --survey-shadow: rgba(0, 0, 0, 0.3);
  --survey-input-bg: #2d2d2d;
  --survey-input-border: #404040;
  --survey-input-text: #e0e0e0;
  --survey-primary: #64b5f6;
  --survey-primary-dark: #90caf9;
}

/* ===================================
   LAYOUT & STRUCTURE
   =================================== */

.survey-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 2rem 1rem;
}

body.survey-active .header-section {
  display: none;
}

.survey-stage {
  animation: fadeIn 0.4s ease-in-out;
}

/* ===================================
   SURVEY HEADER
   =================================== */

.survey-header {
  margin-bottom: 1rem;
  margin-top: -1rem;
  text-align: center;
  padding: 1rem 0;
  background: linear-gradient(135deg, #008AFF 0%, #0077dd 100%);
  color: white;
  border-radius: var(--survey-radius);
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

[data-theme="dark"] .survey-header {
  background: linear-gradient(135deg, #1565c0 0%, #0d47a1 100%);
}

.survey-header h1,
.survey-header h2,
.survey-header #survey-title-main {
  color: white;
  margin: 0;
  margin-bottom: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.survey-description {
  font-size: 1.1rem;
  color: var(--survey-text-muted);
  margin-bottom: 0;
}

/* ===================================
   PROGRESS BAR
   =================================== */

.survey-progress {
  margin-bottom: 2rem;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.survey-progress .progress {
  height: 25px;
  border-radius: var(--survey-radius);
  background-color: #e9ecef;
}

[data-theme="dark"] .survey-progress .progress {
  background-color: var(--survey-border);
}

.survey-progress .progress-bar {
  background-color: var(--survey-success);
  transition: width 0.3s ease;
  font-weight: 600;
}

.progress-text {
  text-align: center;
  margin-top: 0.5rem;
  color: var(--survey-text-muted);
  font-weight: 500;
}

/* ===================================
   SURVEY CONTENT & SECTIONS
   =================================== */

.survey-content {
  background-color: var(--survey-bg);
  padding: 2rem;
  border-radius: var(--survey-radius);
  box-shadow: 0 2px 8px var(--survey-shadow);
  margin-bottom: 2rem;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.section-title {
  font-size: 1.75rem;
  color: var(--survey-text);
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--survey-primary);
}

.section-subtitle {
  font-size: 1.1rem;
  color: var(--survey-text-muted);
  font-weight: 500;
  margin-top: 0.5rem;
}

/* ===================================
   CODE ENTRY SECTION
   =================================== */

.code-entry-section {
  background: var(--survey-bg);
  padding: 2rem;
  border-radius: var(--survey-radius);
  border: 2px solid var(--survey-border);
  margin-top: 1.5rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.code-entry-section h3 {
  color: var(--survey-text);
  margin-bottom: 0.75rem;
}

.code-instructions {
  color: var(--survey-text-muted);
  margin-bottom: 1.5rem;
}

.code-input-group {
  margin-bottom: 1rem;
}

.code-entry-section .form-label {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.code-entry-section .form-control {
  font-size: 1.1rem;
  padding: 0.75rem;
  border: 2px solid var(--survey-input-border);
  border-radius: var(--survey-radius-sm);
  background-color: var(--survey-input-bg);
  color: var(--survey-input-text);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.code-entry-section .form-control:focus {
  border-color: var(--survey-primary);
  box-shadow: 0 0 0 0.2rem rgba(0, 138, 255, 0.25);
}

[data-theme="dark"] .code-entry-section .form-control:focus {
  box-shadow: 0 0 0 0.2rem rgba(100, 181, 246, 0.25);
}

.code-entry-section .form-control::placeholder {
  color: #808080;
}

.code-entry-section .form-text {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

[data-theme="dark"] .form-text.text-muted {
  color: #808080 !important;
}

/* ===================================
   RESEARCH CONSENT SECTION
   =================================== */

.research-consent {
  background-color: var(--survey-bg-alt);
  border-left: 4px solid var(--survey-primary);
  padding: 2rem;
  margin-bottom: 2rem;
  border-radius: var(--survey-radius);
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

#consent-content-container {
  background: var(--survey-bg);
  padding: 1.5rem;
  border-radius: var(--survey-radius-sm);
  margin-bottom: 1.5rem;
  line-height: 1.8;
}

#consent-content-container h1 {
  font-size: 1.75rem;
  color: var(--survey-text);
  margin-bottom: 1rem;
}

#consent-content-container h2 {
  font-size: 1.5rem;
  color: var(--survey-primary);
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}

#consent-content-container h3 {
  color: var(--survey-text);
}

#consent-content-container p,
#consent-content-container li {
  color: var(--survey-text-muted);
}

#consent-content-container ul {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

#consent-content-container strong {
  font-weight: 600;
}

.consent-checkbox-container {
  background: #fff3cd;
  border: 2px solid var(--survey-warning);
  border-radius: var(--survey-radius);
  padding: 1.25rem;
  margin-top: 1.5rem;
}

[data-theme="dark"] .consent-checkbox-container {
  background: #3a3a1a;
}

.consent-checkbox-label {
  display: flex;
  align-items: flex-start;
  cursor: pointer;
  margin: 0;
}

.consent-checkbox-label input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin-right: 12px;
  margin-top: 2px;
  cursor: pointer;
  flex-shrink: 0;
}

.consent-checkbox-label .checkbox-text {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--survey-text);
}

/* ===================================
   SURVEY INTRO & DISCLAIMER
   =================================== */

.survey-intro h2,
.survey-intro h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--survey-text);
}

.survey-intro p {
  margin-bottom: 0.5rem;
  color: var(--survey-text-light);
}

.disclaimer-content {
  margin: 1.5rem 0;
  padding: 1rem;
  background-color: var(--survey-bg);
  border-radius: var(--survey-radius-sm);
  border: 1px solid var(--survey-border);
}

/* ===================================
   BUTTONS
   =================================== */

#start-survey-btn {
  padding: 0.875rem 2.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  background-color: var(--survey-primary);
  border-color: var(--survey-primary);
  transition: all 0.2s ease;
}

#start-survey-btn:hover:not(:disabled) {
  background-color: var(--survey-primary-dark);
  border-color: var(--survey-primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 138, 255, 0.3);
}

[data-theme="dark"] #start-survey-btn:hover:not(:disabled) {
  box-shadow: 0 4px 8px rgba(100, 181, 246, 0.3);
}

#start-survey-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.survey-navigation {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.survey-navigation .btn {
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--survey-radius-sm);
  transition: all 0.2s ease;
}

.survey-navigation .btn-secondary {
  background-color: #6c757d;
  border-color: #6c757d;
}

.survey-navigation .btn-secondary:hover {
  background-color: #5a6268;
  border-color: #545b62;
}

.survey-navigation .btn-primary {
  background-color: var(--survey-primary);
  border-color: var(--survey-primary);
  margin-left: auto;
}

.survey-navigation .btn-primary:hover {
  background-color: var(--survey-primary-dark);
  border-color: var(--survey-primary-dark);
}

.survey-navigation .btn-success {
  background-color: var(--survey-success);
  border-color: var(--survey-success);
  margin-left: auto;
}

.survey-navigation .btn-success:hover {
  background-color: #218838;
  border-color: #1e7e34;
}

.survey-navigation .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===================================
   QUESTIONS
   =================================== */

.survey-question {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--survey-border);
  animation: fadeIn 0.3s ease-in-out;
}

.survey-question:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.survey-question .form-label {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--survey-text);
  margin-bottom: 0.75rem;
  display: block;
}

.survey-question .text-danger {
  color: var(--survey-danger);
}

/* Form Controls */
.survey-question .form-control,
.survey-question .form-select {
  border: 1px solid var(--survey-input-border);
  border-radius: var(--survey-radius-sm);
  padding: 0.75rem;
  font-size: 1rem;
  background-color: var(--survey-input-bg);
  color: var(--survey-input-text);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.survey-question .form-control:focus,
.survey-question .form-select:focus {
  border-color: var(--survey-primary);
  box-shadow: 0 0 0 0.2rem rgba(0, 138, 255, 0.25);
}

[data-theme="dark"] .survey-question .form-control:focus,
[data-theme="dark"] .survey-question .form-select:focus {
  box-shadow: 0 0 0 0.2rem rgba(100, 181, 246, 0.25);
}

.survey-question textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

.survey-question .form-control::placeholder {
  color: #808080;
}

/* Textarea with character counter */
.textarea-with-counter {
  position: relative;
}

.char-counter {
  font-size: 0.875rem;
  color: var(--survey-text-muted);
  margin-top: 0.25rem;
  display: block;
}

.char-counter.warning {
  color: #ff9800;
  font-weight: 500;
}

.char-counter.error {
  color: var(--survey-danger);
  font-weight: 600;
}

.question-guidance {
  font-size: 0.9rem;
  color: var(--survey-text-muted);
  font-style: italic;
  margin-top: 0.5rem;
  display: block;
}

/* Radio and Checkbox Groups */
.radio-group,
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-check {
  padding-left: 1.75rem;
}

.form-check-input {
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.125rem;
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--survey-primary);
  border-color: var(--survey-primary);
}

.form-check-label {
  font-size: 1rem;
  color: var(--survey-text-light);
  cursor: pointer;
  margin-left: 0.5rem;
}

/* ===================================
   LIKERT SCALE TABLES
   =================================== */

.likert-table-question {
  margin: 2rem 0;
}

.likert-question-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--survey-text);
  margin-bottom: 0.5rem;
}

.likert-question-hint {
  font-size: 0.95rem;
  color: var(--survey-text-muted);
  margin-bottom: 1rem;
  font-style: italic;
}

.likert-table-container {
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: var(--survey-radius);
  box-shadow: 0 2px 8px var(--survey-shadow);
  max-width: 100%;
}

.likert-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--survey-bg);
  table-layout: fixed;
}

.likert-table thead {
  background: linear-gradient(135deg, #008AFF 0%, #0077dd 100%) !important;
  background-color: #008AFF !important;
  color: white !important;
}

.likert-table thead tr {
  background: linear-gradient(135deg, #008AFF 0%, #0077dd 100%) !important;
  background-color: #008AFF !important;
}

[data-theme="dark"] .likert-table thead {
  background: linear-gradient(135deg, #1565c0 0%, #0d47a1 100%) !important;
  background-color: #1565c0 !important;
  color: white !important;
}

[data-theme="dark"] .likert-table thead tr {
  background: linear-gradient(135deg, #1565c0 0%, #0d47a1 100%) !important;
  background-color: #1565c0 !important;
}

.likert-table thead th {
  padding: 0.75rem 0.5rem !important;
  text-align: center !important;
  font-weight: 600 !important;
  font-size: 0.85rem !important;
  color: white !important;
  background: transparent !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  word-wrap: break-word !important;
  white-space: normal !important;
  line-height: 1.3 !important;
  vertical-align: middle !important;
}

.likert-table th {
  color: white !important;
}

[data-theme="dark"] .likert-table thead th {
  color: white !important;
}

.likert-table th.row-header {
  text-align: left;
  width: 25%;
  min-width: 150px;
  max-width: 250px;
  color: var(--survey-text) !important;
}

.likert-table tbody tr {
  border-bottom: 1px solid var(--survey-border);
  transition: background-color 0.2s ease;
}

.likert-table tbody tr:hover {
  background-color: var(--survey-bg-alt);
}

[data-theme="dark"] .likert-table tbody tr:hover {
  background-color: #3a3a3a;
}

.likert-table tbody tr:last-child {
  border-bottom: none;
}

.likert-table td.row-label {
  padding: 0.75rem 0.5rem;
  font-weight: 500;
  color: var(--survey-text);
  background: var(--survey-bg-alt);
  border-right: 2px solid var(--survey-border);
  vertical-align: middle;
  font-size: 0.95rem;
  word-wrap: break-word;
}

.likert-table td.row-label strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
}

.likert-table td.row-label .row-description {
  font-size: 0.85rem;
  color: var(--survey-text-muted);
  font-weight: normal;
  display: block;
  margin-top: 0.25rem;
  line-height: 1.4;
}

.likert-table td.radio-cell {
  text-align: center;
  padding: 0.75rem 0.25rem;
  border: 1px solid var(--survey-border);
  background: var(--survey-bg);
}

.likert-table td.radio-cell input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  margin: 0;
}

.likert-table td.radio-cell input[type="radio"]:checked {
  accent-color: var(--survey-primary);
}

/* ===================================
   MESSAGES & ALERTS
   =================================== */

.survey-message {
  margin-top: 2rem;
  padding: 1rem 1.5rem;
  border-radius: var(--survey-radius-sm);
  font-size: 1rem;
}

.survey-message.alert-danger {
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

.survey-message.alert-success {
  background-color: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
}

/* ===================================
   THANK YOU PAGE
   =================================== */

.thank-you-content {
  padding: 3rem 2rem;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.success-icon {
  display: inline-block;
  animation: scaleIn 0.5s ease-in-out;
}

.thank-you-content h3 {
  color: var(--survey-text);
  font-size: 1.75rem;
  margin-bottom: 1rem;
}

.thank-you-content p {
  font-size: 1.1rem;
  color: var(--survey-text-muted);
  line-height: 1.6;
}

.thank-you-content .btn-primary {
  margin-top: 1rem;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  background-color: var(--survey-primary);
  border-color: var(--survey-primary);
}

.thank-you-content .btn-primary:hover {
  background-color: var(--survey-primary-dark);
  border-color: var(--survey-primary-dark);
}

/* Appendix Content Styling */
.appendix-content {
  padding: 2rem;
  background: var(--survey-bg-alt);
  border-radius: var(--survey-radius);
  margin: 1rem 0;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.appendix-content h1 {
  font-size: 1.75rem;
  color: var(--survey-text);
  margin-bottom: 1rem;
}

.appendix-content h2 {
  font-size: 1.5rem;
  color: var(--survey-primary);
  margin-top: 2rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--survey-primary);
  padding-bottom: 0.5rem;
}

.appendix-content h3 {
  font-size: 1.25rem;
  color: var(--survey-text);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.appendix-content h4 {
  font-size: 1.1rem;
  color: var(--survey-text-light);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.appendix-content ol,
.appendix-content ul {
  margin-left: 2rem;
  line-height: 1.8;
  margin-bottom: 1.5rem;
}

.appendix-content p,
.appendix-content li {
  line-height: 1.8;
  margin-bottom: 1rem;
  color: var(--survey-text-muted);
}

.appendix-content hr {
  margin: 2rem 0;
  border-top: 2px solid var(--survey-border);
}

/* ===================================
   ANIMATIONS
   =================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}

@keyframes ellipsis {
  0%, 20% { content: "."; }
  40% { content: ".."; }
  60%, 100% { content: "..."; }
}

.survey-navigation .btn:disabled::after {
  content: "...";
  animation: ellipsis 1.5s infinite;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

/* Tablet and Small Laptop Optimization */
@media (max-width: 1200px) {
  .likert-table thead th {
    font-size: 0.75rem !important;
    padding: 0.6rem 0.3rem !important;
  }

  .likert-table td.row-label {
    font-size: 0.9rem;
    padding: 0.6rem 0.4rem;
  }

  .likert-table td.row-label strong {
    font-size: 0.9rem;
  }

  .likert-table td.row-label .row-description {
    font-size: 0.8rem;
  }

  .likert-table td.radio-cell {
    padding: 0.6rem 0.2rem;
  }

  .likert-table th.row-header {
    width: 20%;
    min-width: 120px;
  }
}

@media (max-width: 768px) {
  .survey-container {
    padding: 1rem 0;
  }

  .survey-content {
    padding: 1.5rem;
  }

  .section-title {
    font-size: 1.5rem;
  }

  .survey-navigation {
    flex-direction: column;
  }

  .survey-navigation .btn {
    width: 100%;
    margin-left: 0 !important;
  }

  .survey-navigation .btn-primary,
  .survey-navigation .btn-success {
    order: -1;
  }

  /* Likert Table Mobile Responsive: Convert to Stacked Cards */
  .likert-table-container {
    overflow-x: visible;
    box-shadow: none;
  }

  .likert-table {
    display: block;
    min-width: auto;
    border: none;
    background: transparent;
  }

  .likert-table thead {
    display: none;
  }

  .likert-table tbody {
    display: block;
  }

  .likert-table tbody tr {
    display: block;
    margin-bottom: 1.5rem;
    border: 2px solid var(--survey-border);
    border-radius: var(--survey-radius);
    background: var(--survey-bg);
    box-shadow: 0 2px 4px var(--survey-shadow);
    overflow: hidden;
  }

  .likert-table td {
    display: block;
    width: 100% !important;
    border: none !important;
  }

  .likert-table td.row-label {
    padding: 1rem;
    background: var(--survey-primary) !important;
    color: white !important;
    border-radius: 0;
    margin-bottom: 0.75rem;
  }

  .likert-table td.row-label strong {
    color: white !important;
    font-size: 1.05rem;
  }

  .likert-table td.row-label .row-description {
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 0.9rem;
  }

  .likert-table td.radio-cell {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #f0f0f0 !important;
  }

  .likert-table td.radio-cell:last-child {
    border-bottom: none !important;
  }

  .likert-table td.radio-cell::before {
    content: attr(data-label);
    font-weight: 500;
    color: var(--survey-text);
    flex: 1;
  }

  .likert-table td.radio-cell input[type="radio"] {
    flex-shrink: 0;
    margin-left: 1rem;
  }
}
