/* ============================================================
   THRIVE INTERVENTION ENGINE — Modal CSS
   v1.0 — intervention-engine.css
   ============================================================ */
/* --- Modal overlay --- */
#interventionModal.modal-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
  overflow: auto;
}
/* --- Modal content box --- */
.intv-modal-content {
  position: relative;
  background: #141530;
  border: 1px solid rgba(108,99,255,0.45);
  border-radius: 22px;
  box-shadow:
    0 0 0 1px rgba(108,99,255,0.20),
    0 0 24px rgba(108,99,255,0.22),
    0 0 60px rgba(108,99,255,0.10),
    0 24px 80px rgba(0,0,0,0.65);
  animation: intvSlideIn 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
  max-height: 92vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(108,99,255,0.3) transparent;
  display: flex;
  flex-direction: column;
}
.intv-modal-content::-webkit-scrollbar { width: 4px; }
.intv-modal-content::-webkit-scrollbar-track { background: transparent; }
.intv-modal-content::-webkit-scrollbar-thumb { background: rgba(108,99,255,0.3); border-radius: 2px; }
@keyframes intvSlideIn {
  from { opacity:0; transform:translateY(24px) scale(0.96); }
  to   { opacity:1; transform:translateY(0) scale(1); }
}
/* --- Header --- */
.intv-header {
  padding: 24px 24px 18px;
  background: linear-gradient(135deg, rgba(108,99,255,0.12) 0%, rgba(0,200,170,0.06) 100%);
  border-bottom: 1px solid rgba(108,99,255,0.18);
}
.intv-header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.intv-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: #6C63FF;
  background: rgba(108,99,255,0.12);
  border: 1px solid rgba(108,99,255,0.3);
  border-radius: 20px;
  padding: 3px 10px;
  display: inline-block;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.intv-title {
  font-size: 22px;
  font-weight: 700;
  color: #F0F0FF;
  margin: 0 0 4px;
  line-height: 1.2;
}
.intv-desc {
  font-size: 13px;
  color: #9395B0;
  margin: 0;
  line-height: 1.4;
}
.intv-close-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: #9395B0;
  border-radius: 50%;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.intv-close-btn:hover {
  background: rgba(230,57,70,0.15);
  border-color: rgba(230,57,70,0.4);
  color: #E63946;
}
/* --- Visual zone --- */
.intv-visual-zone {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 24px 20px;
  background: rgba(11,12,30,0.5);
  position: relative;
  overflow: hidden;
}
/* ---- Breathing Circle ---- */
.intv-breathe-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.intv-breathe-circle {
  width: 130px; height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(108,99,255,0.55) 0%, rgba(108,99,255,0.08) 70%);
  border: 2px solid rgba(108,99,255,0.6);
  box-shadow: 0 0 30px rgba(108,99,255,0.35), 0 0 60px rgba(108,99,255,0.15);
  transition: transform 0.1s ease;
}
.intv-breathe-circle.inhale {
  animation: breatheInhale 4s ease-in-out forwards;
}
.intv-breathe-circle.hold {
  animation: breatheHold 2s linear forwards;
}
.intv-breathe-circle.exhale {
  animation: breatheExhale 6s ease-in-out forwards;
}
@keyframes breatheInhale {
  from { transform: scale(0.75); box-shadow: 0 0 20px rgba(108,99,255,0.25); }
  to   { transform: scale(1.3);  box-shadow: 0 0 50px rgba(108,99,255,0.55), 0 0 80px rgba(108,99,255,0.20); }
}
@keyframes breatheHold {
  from { transform: scale(1.3); }
  to   { transform: scale(1.3); }
}
@keyframes breatheExhale {
  from { transform: scale(1.3); box-shadow: 0 0 50px rgba(108,99,255,0.55); }
  to   { transform: scale(0.75); box-shadow: 0 0 20px rgba(108,99,255,0.20); }
}
.intv-breathe-label {
  font-size: 15px;
  font-weight: 600;
  color: #B8B5FF;
  letter-spacing: 0.5px;
  min-height: 24px;
  text-align: center;
}
/* ---- Wave animation ---- */
.intv-wave-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}
.intv-wave-svg-wrap {
  width: 100%; max-width: 340px; height: 100px; overflow: hidden;
}
.intv-wave-svg-wrap svg { width: 100%; height: 100%; }
.intv-wave-text {
  font-size: 13px;
  color: #9395B0;
  text-align: center;
  max-width: 260px;
  line-height: 1.5;
}
/* ---- Checklist ---- */
.intv-checklist {
  list-style: none;
  margin: 0; padding: 0;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.intv-check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(108,99,255,0.06);
  border: 1px solid rgba(108,99,255,0.15);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  color: #9395B0;
  font-size: 13px;
  line-height: 1.4;
}
.intv-check-item:hover {
  background: rgba(108,99,255,0.12);
  border-color: rgba(108,99,255,0.3);
}
.intv-check-item.checked {
  background: rgba(0,200,170,0.08);
  border-color: rgba(0,200,170,0.35);
  color: #F0F0FF;
}
.intv-check-icon {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(108,99,255,0.45);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  transition: all 0.2s;
  color: transparent;
}
.intv-check-item.checked .intv-check-icon {
  background: rgba(0,200,170,0.25);
  border-color: #00c8aa;
  color: #00c8aa;
}
/* ---- Journal ---- */
.intv-journal-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.intv-journal-prompt {
  font-size: 14px;
  color: #B8B5FF;
  font-weight: 500;
  margin-bottom: 4px;
}
.intv-journal-input {
  width: 100%;
  background: rgba(11,12,30,0.7);
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: 10px;
  color: #F0F0FF;
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  resize: none;
  min-height: 70px;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.intv-journal-input:focus {
  outline: none;
  border-color: rgba(108,99,255,0.55);
  box-shadow: 0 0 0 2px rgba(108,99,255,0.12);
}
.intv-journal-ai-response {
  background: rgba(0,200,170,0.06);
  border: 1px solid rgba(0,200,170,0.2);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: #9395B0;
  line-height: 1.6;
  min-height: 48px;
  display: none;
}
.intv-journal-ai-response.visible { display: block; }
.intv-journal-ai-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #00c8aa;
  margin-bottom: 6px;
  text-transform: uppercase;
}
/* ---- CBT Reframe ---- */
.intv-cbt-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.intv-cbt-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #9395B0;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.intv-cbt-input {
  width: 100%;
  background: rgba(11,12,30,0.7);
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: 10px;
  color: #F0F0FF;
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  resize: none;
  min-height: 56px;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.intv-cbt-input:focus {
  outline: none;
  border-color: rgba(108,99,255,0.55);
  box-shadow: 0 0 0 2px rgba(108,99,255,0.12);
}
.intv-cbt-reframe {
  background: linear-gradient(135deg, rgba(108,99,255,0.08), rgba(0,200,170,0.06));
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: #B8B5FF;
  line-height: 1.6;
  display: none;
}
.intv-cbt-reframe.visible { display: block; }
/* ---- Future Self ---- */
.intv-future-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 380px;
  text-align: center;
}
.intv-future-icon {
  font-size: 48px;
  animation: floatIcon 3s ease-in-out infinite;
}
@keyframes floatIcon {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.intv-future-message {
  background: linear-gradient(135deg, rgba(108,99,255,0.1), rgba(0,200,170,0.06));
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: 14px;
  padding: 18px 20px;
  font-size: 15px;
  color: #D0CFFF;
  line-height: 1.7;
  font-style: italic;
}
/* ---- Gratitude ---- */
.intv-gratitude-wrap {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.intv-gratitude-input {
  width: 100%;
  background: rgba(11,12,30,0.7);
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: 10px;
  color: #F0F0FF;
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  resize: none;
  min-height: 50px;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.intv-gratitude-input:focus {
  outline: none;
  border-color: rgba(108,99,255,0.55);
  box-shadow: 0 0 0 2px rgba(108,99,255,0.12);
}
.intv-gratitude-response {
  background: rgba(245,158,11,0.06);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: #FCD34D;
  line-height: 1.6;
  display: none;
}
.intv-gratitude-response.visible { display: block; }
/* ---- Walk steps ---- */
.intv-walk-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 380px;
}
.intv-walk-step {
  width: 100%;
  padding: 12px 16px;
  background: rgba(108,99,255,0.06);
  border: 1px solid rgba(108,99,255,0.18);
  border-radius: 12px;
  color: #9395B0;
  font-size: 13px;
  line-height: 1.5;
  transition: all 0.4s;
  text-align: center;
}
.intv-walk-step.active {
  background: rgba(108,99,255,0.14);
  border-color: rgba(108,99,255,0.45);
  color: #F0F0FF;
  font-weight: 600;
  box-shadow: 0 0 16px rgba(108,99,255,0.18);
}
/* --- Timer bar --- */
.intv-timer-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 16px 28px;
  border-top: 1px solid rgba(108,99,255,0.12);
  background: rgba(11,12,30,0.3);
}
.intv-timer-ring-wrap {
  position: relative;
  flex-shrink: 0;
}
.intv-timer-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-size: 16px;
  font-weight: 700;
  color: #F0F0FF;
  font-variant-numeric: tabular-nums;
}
.intv-timer-status {
  font-size: 13px;
  color: #9395B0;
  line-height: 1.4;
  text-align: center;
}
/* --- Step instructions --- */
.intv-steps-zone {
  padding: 14px 28px 10px;
  border-top: 1px solid rgba(108,99,255,0.10);
}
.intv-step-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #6C63FF;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.intv-step-text {
  font-size: 14px;
  color: #D0CFFF;
  font-weight: 500;
  min-height: 22px;
  transition: opacity 0.3s;
}
.intv-step-dots {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.intv-step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(108,99,255,0.2);
  transition: all 0.3s;
}
.intv-step-dot.active {
  background: #6C63FF;
  box-shadow: 0 0 6px rgba(108,99,255,0.6);
}
.intv-step-dot.done { background: rgba(0,200,170,0.5); }
/* --- Voice bar --- */
.intv-voice-bar {
  padding: 10px 24px;
  background: rgba(0,200,170,0.04);
  border-top: 1px solid rgba(0,200,170,0.12);
}
.intv-voice-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}
.intv-voice-wave {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 20px;
}
.intv-voice-wave span {
  width: 3px;
  border-radius: 2px;
  background: #00c8aa;
  animation: voiceWave 0.8s ease-in-out infinite;
}
.intv-voice-wave span:nth-child(1) { height: 8px;  animation-delay: 0s; }
.intv-voice-wave span:nth-child(2) { height: 14px; animation-delay: 0.1s; }
.intv-voice-wave span:nth-child(3) { height: 18px; animation-delay: 0.2s; }
.intv-voice-wave span:nth-child(4) { height: 12px; animation-delay: 0.15s; }
.intv-voice-wave span:nth-child(5) { height: 6px;  animation-delay: 0.05s; }
@keyframes voiceWave {
  0%,100% { opacity: 0.4; transform: scaleY(0.7); }
  50%      { opacity: 1;   transform: scaleY(1.2); }
}
.intv-voice-wave.muted span { animation: none; opacity: 0.2; }
.intv-voice-label { font-size: 12px; color: #00c8aa; flex: 1; }
.intv-voice-btn {
  background: none;
  border: 1px solid rgba(0,200,170,0.25);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
  color: #00c8aa;
  transition: all 0.2s;
}
.intv-voice-btn:hover { background: rgba(0,200,170,0.1); border-color: rgba(0,200,170,0.45); }
/* --- Completion zone --- */
.intv-completion-zone {
  padding: 24px 28px;
  text-align: center;
  border-top: 1px solid rgba(108,99,255,0.12);
}
.intv-completion-title {
  font-size: 18px;
  font-weight: 700;
  color: #F0F0FF;
  margin-bottom: 8px;
}
.intv-completion-sub {
  font-size: 13px;
  color: #9395B0;
  margin: 0 0 18px;
}
.intv-urge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.intv-urge-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #00c8aa 0%, #6C63FF 50%, #E63946 100%);
  cursor: pointer;
  outline: none;
}
.intv-urge-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #6C63FF;
  border: 2px solid #F0F0FF;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(108,99,255,0.5);
}
.intv-urge-label { font-size: 12px; font-weight: 700; color: #9395B0; min-width: 16px; }
.intv-urge-label.high { color: #E63946; }
.intv-urge-label.low  { color: #00c8aa; }
.intv-urge-value {
  font-size: 32px;
  font-weight: 700;
  color: #F0F0FF;
  margin-bottom: 18px;
}
.intv-completion-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
}
/* --- Escalation zone --- */
.intv-escalation-zone {
  padding: 24px 28px;
  border-top: 1px solid rgba(230,57,70,0.25);
  background: rgba(230,57,70,0.04);
  text-align: center;
}
.intv-esc-icon { font-size: 32px; margin-bottom: 10px; }
.intv-esc-title { font-size: 17px; font-weight: 700; color: #F0F0FF; margin-bottom: 6px; }
.intv-esc-sub { font-size: 13px; color: #9395B0; margin: 0 0 18px; }
.intv-esc-options { display: flex; flex-direction: column; gap: 10px; }
.intv-esc-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid;
  text-align: left;
  transition: all 0.2s;
  background: transparent;
  width: 100%;
}
.intv-esc-btn strong { display: block; font-size: 14px; color: #F0F0FF; }
.intv-esc-btn small  { display: block; font-size: 12px; color: #9395B0; margin-top: 2px; }
.intv-esc-btn.peer   { border-color: rgba(108,99,255,0.35); }
.intv-esc-btn.staff  { border-color: rgba(0,200,170,0.35); }
.intv-esc-btn.crisis { border-color: rgba(230,57,70,0.45); background: rgba(230,57,70,0.06); }
.intv-esc-btn.peer:hover   { background: rgba(108,99,255,0.1); border-color: rgba(108,99,255,0.6); }
.intv-esc-btn.staff:hover  { background: rgba(0,200,170,0.08); border-color: rgba(0,200,170,0.55); }
.intv-esc-btn.crisis:hover { background: rgba(230,57,70,0.12); border-color: rgba(230,57,70,0.65); }
.intv-esc-icon-sm { font-size: 22px; flex-shrink: 0; }
/* --- Action bar --- */
.intv-action-bar {
  display: flex;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid rgba(108,99,255,0.12);
  background: rgba(11,12,30,0.2);
  flex-wrap: wrap;
  margin-top: auto;
  position: sticky;
  bottom: 0;
  z-index: 2;
}

/* Ensure the action bar is always reachable on short screens */
@media (max-height: 760px) {
  .intv-modal-content { max-height: 96vh; }
  .intv-visual-zone { min-height: 140px; padding: 20px 18px 14px; }
  .intv-header { padding: 18px 18px 14px; }
  .intv-steps-zone { padding: 10px 18px 6px; }
  .intv-completion-zone { padding: 16px 18px; }
  .intv-action-bar { padding: 12px 18px 14px; }
}
.intv-btn-start, .intv-btn-pause, .intv-btn-complete {
  flex: 1;
  padding: 12px 18px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  transition: all 0.2s;
  min-height: 46px;
}
.intv-btn-start {
  background: linear-gradient(135deg, #6C63FF, #00c8aa);
  color: #fff;
  box-shadow: 0 4px 18px rgba(108,99,255,0.4);
}
.intv-btn-start:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(108,99,255,0.55); }
.intv-btn-pause {
  background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.35);
  color: #F59E0B;
}
.intv-btn-pause:hover { background: rgba(245,158,11,0.2); }
.intv-btn-complete {
  background: rgba(0,200,170,0.12);
  border: 1px solid rgba(0,200,170,0.4);
  color: #00c8aa;
}
.intv-btn-complete:hover { background: rgba(0,200,170,0.2); }
.intv-btn-primary {
  padding: 12px 24px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  background: linear-gradient(135deg, #6C63FF, #00c8aa);
  color: #fff;
  box-shadow: 0 4px 18px rgba(108,99,255,0.35);
  transition: all 0.2s;
  min-height: 44px;
}
.intv-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(108,99,255,0.5); }
.intv-btn-secondary {
  padding: 12px 24px;
  border-radius: 50px;
  border: 1px solid rgba(108,99,255,0.3);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  color: #9395B0;
  transition: all 0.2s;
  min-height: 44px;
}
.intv-btn-secondary:hover { background: rgba(108,99,255,0.08); border-color: rgba(108,99,255,0.5); color: #B8B5FF; }
.intv-hidden { display: none !important; }

/* Ensure the modal overlay lays out correctly when JS sets display:flex */
#interventionModal[style*="flex"] {
  align-items: center;
  justify-content: center;
}
/* --- Support item hover (Right Now panel) --- */
.support-item[data-intv-wired] { transition: all 0.22s ease; cursor: pointer; }
.support-item[data-intv-wired]:hover {
  background: rgba(108,99,255,0.1) !important;
  border-color: rgba(108,99,255,0.45) !important;
  transform: translateX(3px);
}
.support-item[data-intv-wired]:focus { outline: 2px solid rgba(108,99,255,0.5); outline-offset: 2px; }
/* --- Responsive --- */
@media (max-width: 600px) {
  .intv-modal-content { border-radius: 18px; }
  .intv-header { padding: 18px 16px 14px; }
  .intv-title { font-size: 18px; }
  .intv-visual-zone { min-height: 180px; padding: 20px 16px 16px; }
  .intv-action-bar { padding: 12px 16px 16px; }
  .intv-timer-bar { padding: 12px 16px; }
  .intv-steps-zone { padding: 12px 16px 8px; }
  .intv-completion-zone { padding: 18px 16px; }
  .intv-escalation-zone { padding: 18px 16px; }
  .intv-completion-btns { flex-direction: column; }
  .intv-breathe-circle { width: 100px; height: 100px; }
}
