/**
 * FSI Interactives Front-End Styles
 *
 * Premium front-end stylesheet for rendering worksheet-based interactives
 * inside shortcode output and LearnDash lesson content.
 *
 * This stylesheet controls:
 * - Interactive page layout
 * - PDF page card appearance
 * - Page badges and page spacing
 * - Overlay field positioning shell
 * - Fill in the Blank field appearance
 * - Multiple Choice field appearance
 * - Multi Select field appearance
 * - Drag and Drop field appearance
 * - Submit button styling
 * - Feedback area styling
 * - Responsive behaviour for tablet and mobile layouts
 *
 * Supported front-end field types:
 * - Fill in the Blank
 * - Multiple Choice
 * - Multi Select
 * - Drag and Drop
 *
 * Design goals:
 * - Keep the worksheet visually clean
 * - Let the PDF remain the primary UI surface
 * - Avoid heavy form-box styling over the worksheet
 * - Maintain responsive usability on smaller screens
 *
 * @package FSI_Interactives
 */

/* --------------------------------------------------------------------------
 * Interactive Layout
 * ----------------------------------------------------------------------- */

.fsi-interactive-stage {
  position: relative;
}

.fsi-interactive-pages {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.fsi-interactive-page {
  background: linear-gradient(180deg, #fafafa 0%, #f3f4f5 100%);
  border: 1px solid #dcdcde;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 6%);
  box-sizing: border-box;
  display: inline-block;
  margin: 0 auto;
  padding: 14px;
}

.fsi-interactive-page-header {
  margin-bottom: 10px;
}

.fsi-interactive-page-badge {
  align-items: center;
  background: #2271b1;
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 12px;
  font-weight: 600;
  height: 28px;
  justify-content: center;
  line-height: 1;
  min-width: 64px;
  padding: 0 12px;
}

.fsi-interactive-page-stage {
  background: #fff;
  display: inline-block;
  position: relative;
}

.fsi-interactive-page-canvas {
  background: #fff;
  border: 1px solid #e0e0e0;
  display: block;
  height: auto;
  max-width: none;
}

.fsi-interactive-overlay {
  left: 0;
  position: absolute;
  top: 0;
  z-index: 5;
}

/* --------------------------------------------------------------------------
 * Overlay Field Shell
 * ----------------------------------------------------------------------- */

.fsi-frontend-field {
  box-sizing: border-box;
  display: block;
  overflow: visible;
  position: absolute;
}

/* --------------------------------------------------------------------------
 * Fill in the Blank
 * ----------------------------------------------------------------------- */

.fsi-fill-blank {
  position: absolute;
}

.fsi-fill-blank input {
  background: transparent;
  border: none;
  box-shadow: none;
  color: #000;
  font-family: inherit;
  font-size: 13px;
  height: 100%;
  line-height: 20px;
  margin: 0;
  min-height: 20px;
  outline: none;
  padding: 0 2px;
  vertical-align: baseline;
  width: 100%;
}

.fsi-fill-blank input::placeholder {
  color: #999;
  font-size: 13px;
  line-height: 20px;
  opacity: 1;
}

.fsi-fill-blank input:focus {
  background: transparent;
  border: none;
  box-shadow: none;
  outline: none;
}

/* --------------------------------------------------------------------------
 * Choice Group UI
 * ----------------------------------------------------------------------- */

.fsi-choice-group {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  width: 100%;
}

.fsi-choice-option {
  align-items: center;
  background: rgb(255 255 255 / 88%);
  border-radius: 999px;
  color: #000;
  cursor: pointer;
  display: inline-flex;
  font-size: 13px;
  gap: 6px;
  line-height: 1.2;
  margin: 0;
  padding: 2px 6px;
  user-select: none;
  white-space: nowrap;
}

.fsi-choice-option input[type="radio"],
.fsi-choice-option input[type="checkbox"] {
  flex: 0 0 auto;
  margin: 0;
}

.fsi-choice-text {
  display: inline-block;
  line-height: 1.2;
}

/* --------------------------------------------------------------------------
 * Multiple Choice
 * ----------------------------------------------------------------------- */

.fsi-multiple-choice {
  position: absolute;
}

/* --------------------------------------------------------------------------
 * Multi Select
 * ----------------------------------------------------------------------- */

.fsi-multi-select {
  position: absolute;
}

/* --------------------------------------------------------------------------
 * Drag and Drop
 * ----------------------------------------------------------------------- */

.fsi-dd-source,
.fsi-dd-target {
  align-items: center;
  border-radius: 999px;
  box-sizing: border-box;
  display: inline-flex;
  font-size: 13px;
  justify-content: center;
  line-height: 1.2;
  min-height: 28px;
  padding: 4px 10px;
  text-align: center;
  user-select: none;
  white-space: nowrap;
}

.fsi-dd-source {
  background: rgb(230 126 34 / 12%);
  border: 1px solid rgb(230 126 34 / 45%);
  box-shadow: 0 1px 2px rgb(0 0 0 / 6%);
  color: #8a4b08;
  cursor: grab;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
}

.fsi-dd-source:hover {
  box-shadow: 0 2px 6px rgb(0 0 0 / 10%);
}

.fsi-dd-source:active {
  cursor: grabbing;
}

.fsi-dd-source.is-dragging {
  opacity: 0.55;
  transform: scale(0.98);
}

.fsi-dd-target {
  background: rgb(52 152 219 / 8%);
  border: 1px dashed #3498db;
  color: #1d4f73;
  min-width: 90px;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.fsi-dd-target.is-drag-over {
  background: rgb(52 152 219 / 16%);
  border-color: #2271b1;
  box-shadow: 0 0 0 2px rgb(34 113 177 / 12%);
}

.fsi-dd-target-value {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Used drag source */
.fsi-dd-source.is-used {
  background: rgb(200 200 200 / 20%);
  border-color: #bbb;
  color: #777;
  cursor: not-allowed;
  opacity: 0.4;
}

/* Filled target */
.fsi-dd-target.is-filled {
  background: rgb(52 152 219 / 12%);
  border-style: solid;
  color: #0f3d5c;
  font-weight: 600;
}

/* Clickable reset hint */
.fsi-dd-target.is-filled:hover {
  background: rgb(52 152 219 / 18%);
  cursor: pointer;
}

/* --------------------------------------------------------------------------
 * Select / Dropdown
 * ----------------------------------------------------------------------- */

.fsi-select-field {
  display: flex;
  align-items: center;
}

.fsi-select-input {
  width: 100%;
  height: 100%;
  min-height: 34px;
  border: 1px solid #c3c4c7;
  border-radius: 4px;
  background: #fff;
  padding: 4px 8px;
  font-size: 14px;
}

.fsi-select-correct .fsi-select-input {
  border-color: #2e7d32;
  background: rgba(46, 125, 50, 0.08);
}

.fsi-select-incorrect .fsi-select-input {
  border-color: #d63638;
  background: rgba(214, 54, 56, 0.08);
}

/* --------------------------------------------------------------------------
 * Actions and Feedback
 * ----------------------------------------------------------------------- */

.fsi-interactive-actions {
  margin-top: 20px;
  text-align: center;
}

.fsi-submit-answers {
  align-items: center;
  background: #2271b1;
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  font-weight: 600;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
}

.fsi-submit-answers:hover {
  background: #135e96;
}

.fsi-submit-answers:focus {
  box-shadow: 0 0 0 2px rgb(34 113 177 / 20%);
  outline: none;
}

.fsi-choice-option:hover {
  background: rgb(34 113 177 / 8%);
}

/* --------------------------------------------------------------------------
 * Submission Feedback
 * ----------------------------------------------------------------------- */

.fsi-interactive-feedback {
  font-size: 14px;
  margin-top: 14px;
  text-align: center;
}

.fsi-interactive-feedback.is-loading {
  color: #646970;
}

.fsi-interactive-feedback.is-error {
  color: #d63638;
}

.fsi-interactive-feedback.is-success {
  color: #1d2327;
}

.fsi-feedback-box {
  background: #f6f7f7;
  border: 1px solid #dcdcde;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgb(0 0 0 / 5%);
  display: inline-block;
  min-width: 220px;
  padding: 12px 16px;
  text-align: center;
}

.fsi-feedback-message {
  color: #1d2327;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.fsi-feedback-score,
.fsi-feedback-percentage {
  color: #50575e;
  font-size: 13px;
}

/* --------------------------------------------------------------------------
 * Basic Result Highlighting
 * ----------------------------------------------------------------------- */

/* Fill in the Blank feedback */
.fsi-fill-blank.fsi-blank-correct input {
  background: rgb(46 125 50 / 8%);
  box-shadow: inset 0 -2px 0 rgb(46 125 50 / 45%);
  color: #1f5f2a;
}

.fsi-fill-blank.fsi-blank-incorrect input {
  background: rgb(214 54 56 / 8%);
  box-shadow: inset 0 -2px 0 rgb(214 54 56 / 45%);
  color: #8f1d1f;
}

/* Drag & Drop feedback */
.fsi-dd-target.fsi-dd-correct {
  background: rgb(46 125 50 / 12%);
  border-color: rgb(46 125 50 / 45%);
  box-shadow: 0 0 0 1px rgb(46 125 50 / 18%);
  color: #1f5f2a;
}

.fsi-dd-target.fsi-dd-incorrect {
  background: rgb(214 54 56 / 12%);
  border-color: rgb(214 54 56 / 45%);
  box-shadow: 0 0 0 1px rgb(214 54 56 / 18%);
  color: #8f1d1f;
}

/* Option-level feedback */
.fsi-choice-option.fsi-option-correct {
  background: rgb(46 125 50 / 12%);
  color: #1f5f2a;
  outline: 1px solid rgb(46 125 50 / 25%);
}

.fsi-choice-option.fsi-option-incorrect {
  background: rgb(214 54 56 / 12%);
  color: #8f1d1f;
  outline: 1px solid rgb(214 54 56 / 22%);
}

.fsi-choice-option.fsi-option-missed {
  background: rgb(46 125 50 / 8%);
  color: #2f6f37;
  outline: 1px dashed rgb(46 125 50 / 25%);
}

/* --------------------------------------------------------------------------
 * Locked / Retest State
 * ----------------------------------------------------------------------- */

.fsi-dd-source.is-locked,
.fsi-dd-target.is-locked {
  pointer-events: none;
}

.fsi-submit-answers[data-mode="retest"] {
  background: #646970;
}

.fsi-submit-answers[data-mode="retest"]:hover {
  background: #50575e;
}

.fsi-fill-blank input:disabled,
.fsi-choice-option input:disabled {
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
 * Responsive Improvements
 * ----------------------------------------------------------------------- */

@media (width <=1200px) {
  .fsi-interactive-page {
    padding: 12px;
  }

  .fsi-interactive-page-badge {
    height: 26px;
    min-width: 60px;
    padding: 0 10px;
  }

  .fsi-interactive-actions {
    margin-top: 18px;
  }

  .fsi-submit-answers {
    min-height: 40px;
    padding: 0 16px;
  }
}

@media (width <=782px) {
  .fsi-interactive-pages {
    gap: 18px;
  }

  .fsi-choice-group {
    gap: 6px 10px;
  }

  .fsi-choice-option {
    font-size: 12px;
    line-height: 1.15;
    padding: 2px 4px;
  }

  .fsi-interactive-page {
    border-radius: 10px;
    box-sizing: border-box;
    max-width: 100%;
    padding: 10px;
    width: 100%;
  }

  .fsi-interactive-page-header {
    margin-bottom: 8px;
  }

  .fsi-interactive-page-badge {
    font-size: 11px;
    height: 24px;
    min-width: 56px;
    padding: 0 8px;
  }

  .fsi-interactive-page-stage {
    max-width: 100%;
    overflow: auto visible;
    -webkit-overflow-scrolling: touch;
  }

  .fsi-interactive-page-canvas {
    max-width: none;
  }

  .fsi-fill-blank input,
  .fsi-fill-blank input::placeholder,
  .fsi-choice-option,
  .fsi-dd-source,
  .fsi-dd-target {
    font-size: 12px;
    line-height: 18px;
  }

  .fsi-fill-blank input {
    min-height: 18px;
  }

  .fsi-dd-source,
  .fsi-dd-target {
    font-size: 12px;
    min-height: 24px;
    padding: 3px 8px;
  }

  .fsi-dd-target {
    min-width: 72px;
  }

  .fsi-interactive-actions {
    margin-top: 16px;
  }

  .fsi-submit-answers {
    font-size: 13px;
    min-height: 40px;
    padding: 0 14px;
    width: 100%;
  }

  .fsi-interactive-feedback {
    font-size: 13px;
    margin-top: 12px;
  }
}

@media (width <=480px) {
  .fsi-interactive-page {
    border-radius: 8px;
    padding: 8px;
  }

  .fsi-interactive-page-badge {
    font-size: 10px;
    height: 22px;
    min-width: 52px;
  }

  .fsi-fill-blank input,
  .fsi-fill-blank input::placeholder,
  .fsi-choice-option,
  .fsi-dd-source,
  .fsi-dd-target {
    font-size: 11px;
    line-height: 16px;
  }

  .fsi-fill-blank input {
    min-height: 16px;
  }

  .fsi-choice-group {
    gap: 4px 8px;
  }

  .fsi-dd-source,
  .fsi-dd-target {
    font-size: 11px;
    min-height: 22px;
    padding: 2px 6px;
  }

  .fsi-dd-target {
    min-width: 64px;
  }

  .fsi-submit-answers {
    font-size: 13px;
    min-height: 38px;
  }
}