/* Base Styles */
:root {
  --primary-color: #2c3e50;
  --secondary-color: #3498db;
  --accent-color: #e74c3c;
  --light-bg: #f9f9f9;
  --dark-bg: #34495e;
  --border-radius: 6px;
  --box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Open Sans', 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--light-bg) !important;
  color: #333;
  line-height: 1.7;
  padding: 20px !important;
  margin: 0 auto !important;
  max-width: 1200px !important;
  width: auto !important;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Roboto', 'Segoe UI', Arial, sans-serif;
  color: var(--primary-color);
  margin-top: 1.2em;
  margin-bottom: 0.7em;
  line-height: 1.3;
}

h2 {
  font-size: 2em;
  text-align: center;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 1em;
  border-bottom: 2px solid var(--secondary-color);
  padding-bottom: 10px;
}

h3 {
  font-size: 1.5em;
  font-weight: 500;
  margin-top: 1.5em;
  text-align: center;
}

.instruction-box p, 
.vignette p,
p {
  text-align: left;
  margin-bottom: 1.2em;
}

/* Container for main content */
.jspsych-content-wrapper {
  max-width: 900px;
  margin: 0 auto;
  background: white;
  padding: 2em;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
}

/* Vignette Styling */
.vignette {
  background: white;
  border-left: 5px solid var(--secondary-color);
  padding: 1.8em;
  margin: 1.5em auto;
  max-width: 800px;
  box-shadow: var(--box-shadow);
  font-size: 1.05em;
  line-height: 1.7;
  border-radius: var(--border-radius);
  text-align: left;
}

.vignette-title {
  text-align: center;
  margin-bottom: 1em;
  font-weight: 600;
  color: var(--primary-color);
  font-size: 1.3em;
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 0.5em;
}

/* Jury Instructions */
.jury-instructions {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: var(--border-radius);
  padding: 1.5em;
  margin: 2em auto;
  max-width: 850px;
}

.jury-instructions h3 {
  text-align: center;
  margin-top: 0;
  color: var(--primary-color);
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 0.5em;
}

.instruction-box h4 {
  margin-top: 0;
  color: var(--secondary-color);
  font-weight: 600;
}

/* Button Styling */
.jspsych-btn {
  display: inline-block;
  padding: 0.8em 1.5em;
  border-radius: var(--border-radius);
  background-color: var(--secondary-color);
  color: white;
  font-weight: 500;
  font-size: 1em;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  margin: 0.5em 0.3em;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.jspsych-btn:hover, .jspsych-btn:focus {
  background-color: #2980b9;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.jspsych-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
}

/* For the Continue button */
.jspsych-btn:only-of-type {
  background-color: #27ae60;
}

.jspsych-btn:only-of-type:hover, .jspsych-btn:only-of-type:focus {
  background-color: #2ecc71;
}

/* Likert Scale Improvements */
.jspsych-survey-likert-statement {
  font-weight: 500;
  margin-bottom: 1.2em;
  font-size: 1.1em;
}

.jspsych-survey-likert-opts {
  display: flex;
  justify-content: space-between; /* Changed back to space-between for better spacing */
  margin: 1em 0 2em;
  flex-wrap: wrap;
  width: 100%;
}

.jspsych-survey-likert-opt-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 3px;
  font-size: 0.9em;
  flex: 1;
  text-align: center;
  min-width: 80px;
  padding: 0.5em 0.3em;
  border-radius: var(--border-radius);
  transition: var(--transition);
}

/* Ensure likert text is properly centered */
.jspsych-survey-likert-opt-label input[type="radio"] {
  margin: 0 auto 0.6em auto;
}

.jspsych-survey-likert-opt-label .jspsych-survey-likert-opt-text {
  width: 100%;
  text-align: center;
}

.jspsych-survey-likert-opt-label:hover {
  background: #f0f7ff;
}

/* Radio buttons and checkboxes */
input[type="radio"],
input[type="checkbox"] {
  margin-bottom: 0.6em;
  transform: scale(1.2);
  cursor: pointer;
}

/* Demographics form - match MPC matching spacing exactly */
#jspsych-survey-html-form label {
  display: block !important;
  font-weight: 500 !important;
  margin-bottom: 0.7em !important;
  text-align: left !important;
  line-height: 1.6 !important;
}

#jspsych-survey-html-form input,
#jspsych-survey-html-form select {
  display: block !important;
  width: 100% !important;
  max-width: 400px !important;
  padding: 0.8em !important;
  border: 1px solid #ced4da !important;
  border-radius: var(--border-radius) !important;
  font-family: inherit !important;
  font-size: 1em !important;
  margin-bottom: 1.5em !important;
  box-sizing: border-box !important;
}

/* Hide the <br><br> spacing since CSS handles it */
#jspsych-survey-html-form br {
  display: none !important;
}

/* Center the form elements */
#jspsych-survey-html-form {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  max-width: 700px !important;
  margin: 0 auto !important;
}

/* MPC matching styles */
.jspsych-survey-html-form p strong {
  display: block;
  margin-bottom: 0.7em;
  text-align: left;
  font-weight: 500;
  line-height: 1.6;
}

.jspsych-survey-html-form select {
  margin-bottom: 1.5em;
}

/* Center headings and preambles globally */
h2, h3, 
.preamble,
.jspsych-survey-text-preamble,
.jspsych-survey-html-form-preamble,
.jspsych-survey-likert-preamble,
.jspsych-survey-multi-choice-preamble {
  text-align: center;
}

/* Ensure all buttons align properly */
.jspsych-btn-container {
  display: flex;
  justify-content: center;
  margin-top: 2em;
}

/* Add extra specificity for the HTML form to ensure the preamble is centered */
.jspsych-survey-html-form > .jspsych-survey-html-form-preamble,
.jspsych-survey-html-form > div:first-child {
  text-align: center !important;
  width: 100%;
}

/* Progress bar */
#jspsych-progressbar-container {
  color: #888;
  border-bottom: 2px solid #eee;
  margin-bottom: 2em;
  padding-bottom: 0.5em;
}

#jspsych-progressbar-outer {
  height: 10px;
  border-radius: 10px;
  background-color: #eee;
  overflow: hidden;
}

#jspsych-progressbar-inner {
  height: 100%;
  background-color: var(--secondary-color);
  border-radius: 10px;
}

/* RPM (Raven's Progressive Matrices) styling */
.rpm-container {
  text-align: center;
}

.rpm-stimulus img {
  max-width: 400px;
  margin: 1em auto;
  border: 2px solid #ddd;
  border-radius: var(--border-radius);
}

.rpm-choices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1em;
  margin: 2em auto;
  max-width: 700px;
  justify-items: center;
}

.rpm-choice {
  cursor: pointer;
  border: 3px solid transparent;
  border-radius: var(--border-radius);
  transition: var(--transition);
  padding: 0.5em;
  width: 100%;
  max-width: 150px;
}

.rpm-choice img {
  max-width: 120px;
  display: block;
}

.rpm-choice:hover {
  border-color: var(--secondary-color);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  /* Remove transform to prevent layout shift */
}

.rpm-choice.selected {
  border-color: #27ae60;
  background: #e8f5e8;
  box-shadow: 0 4px 12px rgba(39, 174, 96, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  
  .jspsych-content-wrapper {
    padding: 1.5em;
  }
  
  .vignette {
    padding: 1.2em;
    font-size: 1em;
  }
  
  .instruction-box {
    padding: 0.8em 1em;
  }
  
  .jspsych-btn {
    padding: 0.7em 1.2em;
    font-size: 0.95em;
  }
  
  h2 {
    font-size: 1.8em;
  }
  
  h3 {
    font-size: 1.3em;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: more) {
  :root {
    --primary-color: #000;
    --secondary-color: #0000EE;
    --accent-color: #CC0000;
  }
  
  .instruction-box {
    border-left-width: 6px;
  }
  
  .jspsych-btn {
    border: 2px solid black;
  }
}

/* Dark mode support - REMOVED */
/* 
@media (prefers-color-scheme: dark) {
  :root {
    --light-bg: #1a1a1a;
    --primary-color: #e1e1e1;
    --secondary-color: #4da6ff;
  }
  
  body {
    background: var(--light-bg);
    color: #e1e1e1;
  }
  
  .jspsych-content-wrapper,
  .vignette,
  .instruction-box {
    background: #2d2d2d;
    color: #e1e1e1;
  }
  
  h1, h2, h3, h4 {
    color: #fff;
  }
  
  input[type="text"],
  textarea {
    background: #333;
    color: #e1e1e1;
    border-color: #555;
  }
  
  .jury-instructions {
    background: #2a2a2a;
    border-color: #444;
  }
}
*/

.instruction-box.selected {
  background: #e8f5e8;
  border-left-color: #27ae60;
  border-left-width: 6px;
  transform: translateX(5px);
  box-shadow: 0 4px 12px rgba(39, 174, 96, 0.2);
  border: 1px solid #27ae60;
}

.instruction-box {
  border-left: 4px solid var(--secondary-color);
  background: white;
  padding: 1em 1.5em;
  margin: 1.2em 0;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: var(--transition);
  border: 1px solid transparent;
  cursor: pointer;
}

.instruction-box:hover {
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.submit-disabled {
  background-color: #bbb !important;
  cursor: not-allowed !important;
}

.submit-enabled {
  background-color: #27ae60 !important;
}

.submit-enabled:hover {
  background-color: #2ecc71 !important;
}

#submit-container {
  text-align: center;
  margin-top: 2em;
}

/* Countdown timer styling */
.jspsych-countdown-timer {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 0.4em 0.8em;
  background-color: rgba(44, 62, 80, 0.8);
  color: white;
  border-radius: 20px;
  font-weight: bold;
  font-size: 0.9em;
}

/* Animation for transitions */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.jspsych-display-element {
  animation: fadeIn 0.3s ease-out;
}