/* ==========================================================================
   Self-Assessment – redesigned layout
   Enqueue after effective-practice-hub.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   Radio button functional rule (must stay, hides native input)
   -------------------------------------------------------------------------- */
.sq-radio input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* --------------------------------------------------------------------------
   Actions bar
   -------------------------------------------------------------------------- */
.sa-actions-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Shared button
   -------------------------------------------------------------------------- */
.sq-btn,
.sa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 9px 20px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--pd-blue);
  color: var(--white);
  font: 700 0.82rem/1 inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.sq-btn:hover,
.sa-btn:hover {
  background: var(--pd-purple);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(111, 45, 168, 0.2);
  color: var(--white);
}

.sq-btn--outline,
.sa-btn--outline {
  background: transparent;
  border-color: var(--pd-blue);
  color: var(--pd-blue-dark);
}

.sq-btn--outline:hover,
.sa-btn--outline:hover {
  background: var(--pd-blue);
  color: var(--white);
  box-shadow: none;
  transform: none;
}

.sq-btn--ghost {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.4);
  color: var(--white);
  font-size: 1.2rem;
}

.sq-btn--ghost:hover {
  background: rgba(255,255,255,0.32);
  box-shadow: none;
  transform: none;
  color: var(--white);
}

/* Compat for old .btn-primary Bootstrap calls */
.btn-primary,
.btn-primary:visited {
  background-color: var(--pd-blue) !important;
  border-color: var(--pd-blue) !important;
  border-radius: 999px !important;
  font-weight: 700 !important;
  color: var(--white) !important;
}

.btn-primary:hover { background-color: var(--pd-purple) !important; border-color: var(--pd-purple) !important; }

/* --------------------------------------------------------------------------
   Tabs wrapper
   -------------------------------------------------------------------------- */
.sa-tabs-wrap {
  background: rgba(255,255,255,0.97);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Tab nav */
.sa-tabs {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 14px 14px 0;
  gap: 4px;
  background: var(--pd-grey-soft);
  border-bottom: 1px solid var(--line);
}

.sa-tab a {
  display: block;
  padding: 11px 20px;
  border-radius: 12px 12px 0 0;
  color: rgba(255,255,255,0.82);
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.sa-tab a:hover,
.sa-tab.active a {
  color: var(--white) !important;
  opacity: 1;
}

.sa-tabs li:nth-child(1) a { background-color: #47abdf; }
.sa-tabs li:nth-child(2) a { background-color: #f6a81d; }
.sa-tabs li:nth-child(3) a { background-color: #59c322; }
.sa-tabs li:nth-child(4) a { background-color: #644098; }

/* Tab content pane */
.sa-tab-content {
  border-top: 4px solid #47abdf;
  transition: border-color 0.2s ease;
  padding: 0 0 24px;
}

/* --------------------------------------------------------------------------
   Standard section header
   -------------------------------------------------------------------------- */
.sa-standard-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.sa-standard-header h2 {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-weight: 800;
  color: var(--tab-color, var(--pd-blue-dark));
  letter-spacing: -0.03em;
}

.sa-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sa-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--white);
}

.sa-legend__item--red   { background: #d94f4f; }
.sa-legend__item--amber { background: #c98b00; }
.sa-legend__item--green { background: #2e7d1a; }

.sa-legend__item::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.55);
}

/* --------------------------------------------------------------------------
   Standard question card  (.sq-card)
   Top row: number badge + text side by side
   Bottom row: rating bar full width
   -------------------------------------------------------------------------- */
.sq-card {
  display: grid;
  grid-template-columns: 100px 1fr;
  grid-template-rows: auto auto;
  grid-template-areas:
    "badge text"
    "rating rating";
  margin: 12px 20px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(63,68,72,0.07);
  transition: box-shadow 0.15s ease;
  background: var(--white);
}

.sq-card:hover {
  box-shadow: 0 10px 28px rgba(63,68,72,0.12);
}

/* Top-left: number badge */
.sq-card__badge {
  grid-area: badge;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 12px;
  background: #47abdf;
  color: var(--white);
  border: none !important;
  min-height: 0 !important;
  font-size: inherit !important;
}

.sq-card__num {
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
}

/* Top-right: standard text */
.sq-card__text {
  grid-area: text;
  padding: 18px 22px;
  background: var(--white);
  font-size: 1.2rem;
  line-height: 1.65;
  color: var(--ink);
  display: flex;
  align-items: center;
  border-left: 1px solid var(--line);
}

/* Bottom: rating bar — spans full width */
.sq-card__rating {
  grid-area: rating;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px;
  background: var(--pd-grey-soft);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

/* Radio group */
.sq-radio-group {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.sq-radio {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.sq-radio__circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(0,0,0,0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.sq-radio__circle svg {
  width: 22px;
  height: 22px;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.sq-radio--red    .sq-radio__circle { background: #f8d7d7; color: #c0392b; }
.sq-radio--amber  .sq-radio__circle { background: #fef3cd; color: #9a6a00; }
.sq-radio--green  .sq-radio__circle { background: #d4edda; color: #1a6b2a; }

.sq-radio:hover .sq-radio__circle {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Selected state */
.sq-radio input:checked ~ .sq-radio__circle {
  border-width: 3px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}

.sq-radio--red   input:checked ~ .sq-radio__circle { background: #e05252; border-color: #b03030; color: var(--white); }
.sq-radio--amber input:checked ~ .sq-radio__circle { background: #e09a1a; border-color: #9a6a00; color: var(--white); }
.sq-radio--green input:checked ~ .sq-radio__circle { background: #3a8a1a; border-color: #1a5a0a; color: var(--white); }

.sq-radio input:checked ~ .sq-radio__circle svg { opacity: 1; stroke: var(--white); }

.sq-radio__label {
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  color: var(--pd-grey);
  line-height: 1.2;
}

/* Evidence / Actions buttons */
.sq-card__btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

/* --------------------------------------------------------------------------
   Evidence / Actions expand panels
   -------------------------------------------------------------------------- */
.sq-panel {
  margin: 4px 20px 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(63,68,72,0.06);
}

.sq-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--pd-grey-soft);
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--pd-grey-dark);
}

.sq-panel__content {
  padding: 14px 18px;
  min-height: 40px;
  font-size: 1.2rem;
}

/* action_added green banner */
.action_added {
  background: var(--standard-green);
  color: var(--white);
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Modal overlay
   -------------------------------------------------------------------------- */
#overlay {
  position: fixed;
  display: none;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 9998;
}

.sa-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100vw - 32px));
  max-height: 88vh;
  background: var(--white);
  border-radius: var(--radius-lg);
  border-top: 6px solid var(--pd-blue);
  padding: 28px 28px 22px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#overlay_info {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
}

#overlay_standard_number {
  font-size: 1.2rem;
  font-weight: 900;
  margin-bottom: 6px;
}

#overlay_html_title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--pd-blue-dark);
  margin-bottom: 10px;
  line-height: 1.35;
}

#overlay_html {
  font-size: 1.2rem;
  color: var(--ink);
  line-height: 1.65;
  white-space: pre-wrap;
}

#overlay_supporting_resources {
  display: flex;
  justify-content: flex-end;
  padding: 0;
  float: none;
  margin: 0;
}

/* Close button */
#text > div[style*="position: absolute"] {
  position: absolute !important;
  right: 16px !important;
  top: 16px !important;
  left: auto !important;
}

/* Supporting resources */
#supporting_resources_button {
  background: var(--pd-blue) !important;
  border: none !important;
  border-radius: 999px !important;
  color: var(--white) !important;
  font-weight: 700 !important;
  padding: 10px 20px !important;
  min-height: 42px !important;
}

#supporting_resources_button:hover {
  background: var(--pd-purple) !important;
}

/* Modal form fields */
.sa-modal textarea,
.sa-modal input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: 1.2rem;
  resize: vertical;
  transition: border-color 0.15s ease;
  margin-bottom: 10px;
}

.sa-modal textarea:focus,
.sa-modal input[type="text"]:focus {
  outline: 4px solid rgba(0,168,232,0.18);
  border-color: var(--pd-blue);
}

.sa-modal label {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--pd-grey-dark);
  margin-bottom: 5px;
  display: block;
}

/* Saving overlay */
#overlay_saving {
  position: fixed;
  display: none;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}

#overlay_saving_text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.sa-saving-text {
  color: var(--white);
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Tables in panels
   -------------------------------------------------------------------------- */
.sq-panel__content table { width: 100%; border-collapse: collapse; }
.sq-panel__content td { padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 1.2rem; }
.sq-panel__content th { padding: 8px 10px; background: var(--pd-grey-soft); font-weight: 700; font-size: 1.2rem; text-align: left; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
  .sq-card {
    grid-template-columns: 1fr;
    grid-template-areas:
      "badge"
      "text"
      "rating";
  }

  .sq-card__text {
    border-left: none;
    border-top: 1px solid var(--line);
  }

  .sq-card__rating {
    flex-direction: column;
    align-items: flex-start;
  }

  .sa-tabs { flex-direction: column; padding: 8px 8px 0; }
  .sa-tab a { border-radius: 8px; }
  .sa-actions-bar { flex-direction: column; }
  .sq-btn, .sa-btn { width: 100%; }
}