/* Know Your Neuro — Pre/Post Survey Modal
   Drop in alongside kyn-survey.js. Brand-aligned with the React app. */

.kyn-survey-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  border: 0;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
  text-decoration: none;
  line-height: 1.2;
  font-family: inherit;
}
.kyn-survey-btn--pre {
  background: #5cb338;
  color: #fff;
}
.kyn-survey-btn--pre:hover { background: #4ea130; }
.kyn-survey-btn--post {
  background: #f5a623;
  color: #fff;
}
.kyn-survey-btn--post:hover { background: #e09515; }
.kyn-survey-btn:active { transform: translateY(1px); }
.kyn-survey-btn:focus-visible { outline: 3px solid #207ec8; outline-offset: 2px; }

/* Soft pulse so the post button gets noticed after pre completion */
.kyn-survey-btn--pulse {
  animation: kyn-pulse 1.6s ease-in-out 2;
}
@keyframes kyn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0); }
  50% { box-shadow: 0 0 0 14px rgba(245, 166, 35, 0.25); }
}

/* Modal */
.kyn-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 99999;
  overflow-y: auto;
  padding: 2rem 1rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.kyn-modal.kyn-modal--open { display: flex; }
.kyn-modal__panel {
  background: #fff;
  border-radius: 18px;
  max-width: 720px;
  width: 100%;
  box-shadow: 0 25px 60px -15px rgba(0,0,0,0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 4rem);
}
.kyn-modal__header {
  background: linear-gradient(135deg, #f5a623 0%, #5cb338 100%);
  color: #fff;
  padding: 1.5rem 1.75rem;
  position: relative;
}
.kyn-modal__title { margin: 0; font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.kyn-modal__subtitle { margin: 0.25rem 0 0; font-size: 0.95rem; opacity: 0.9; font-weight: 600; }
.kyn-modal__close {
  position: absolute; top: 1rem; right: 1rem;
  background: rgba(255,255,255,0.2); border: 0; color: #fff;
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
}
.kyn-modal__close:hover { background: rgba(255,255,255,0.35); }

.kyn-modal__body {
  padding: 1.5rem 1.75rem;
  overflow-y: auto;
  flex: 1;
}

.kyn-section { margin-bottom: 1.5rem; }
.kyn-section__title {
  background: #f3eafb;
  color: #4b2a78;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
}

.kyn-field { margin-bottom: 1rem; }
.kyn-field__label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  color: #1f2937;
  margin-bottom: 0.5rem;
}
.kyn-field__input,
.kyn-field__textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  box-sizing: border-box;
}
.kyn-field__textarea { min-height: 80px; resize: vertical; }
.kyn-field__input:focus,
.kyn-field__textarea:focus { outline: 0; border-color: #f5a623; box-shadow: 0 0 0 3px rgba(245,166,35,0.15); }
.kyn-field__row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.kyn-question {
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.kyn-question:last-child { border-bottom: 0; }
.kyn-question__text {
  font-size: 0.95rem;
  color: #1f2937;
  margin: 0 0 0.5rem;
  line-height: 1.4;
}
.kyn-question__text::before {
  content: counter(kyn-q) ". ";
  font-weight: 700;
  color: #6b21a8;
}
.kyn-section { counter-reset: kyn-q 0; }
.kyn-question { counter-increment: kyn-q; }

.kyn-options {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.kyn-option {
  flex: 1 1 auto;
  min-width: 80px;
  padding: 0.55rem 0.5rem;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  transition: all 0.1s;
  font-family: inherit;
  color: #4b5563;
}
.kyn-option:hover { border-color: #f5a623; }
.kyn-option--selected {
  background: #f5a623;
  border-color: #f5a623;
  color: #fff;
}

.kyn-modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.75rem;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-wrap: wrap;
}
.kyn-modal__error { color: #b91c1c; font-size: 0.9rem; flex: 1; min-width: 0; }
.kyn-modal__submit {
  background: #f5a623; color: #fff; border: 0; padding: 0.7rem 1.5rem;
  border-radius: 999px; font-weight: 700; font-size: 1rem; cursor: pointer;
  font-family: inherit;
}
.kyn-modal__submit:disabled { opacity: 0.6; cursor: wait; }
.kyn-modal__submit:hover:not(:disabled) { background: #e09515; }

/* Success state */
.kyn-modal__success {
  text-align: center;
  padding: 2rem 1.5rem;
}
.kyn-modal__success-icon {
  width: 70px; height: 70px;
  background: #5cb338;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  color: #fff;
  font-size: 2rem;
}
.kyn-modal__success-title { font-size: 1.5rem; font-weight: 800; margin: 0 0 0.5rem; color: #1f2937; }
.kyn-modal__success-text { color: #4b5563; margin: 0 0 1.5rem; line-height: 1.5; }

@media (max-width: 600px) {
  .kyn-modal { padding: 0; }
  .kyn-modal__panel { border-radius: 0; max-height: 100vh; height: 100vh; }
  .kyn-field__row { grid-template-columns: 1fr; }
  .kyn-option { min-width: 60px; font-size: 0.75rem; padding: 0.5rem 0.3rem; }
}
