/* Healix chat + sign-in additions.
   Uses existing theme tokens from sgets-ultra-awesome-site.webflow.css. */

.healix-role-group {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.healix-role-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background-color: #fff;
  cursor: pointer;
  font-family: var(--font--primary-font);
  font-weight: 500;
  color: var(--color--neutral-04);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.healix-role-option input {
  accent-color: var(--color--neutral-04);
}

.healix-role-option:hover {
  border-color: var(--color--neutral-04);
}

.healix-role-option:has(input:checked) {
  border-color: var(--color--neutral-04);
  background-color: var(--color--theme-color-01);
}

.healix-form-error {
  color: #b42318;
  background-color: #fef3f2;
  border: 1px solid #fecdca;
  padding: 10px 14px;
  border-radius: 10px;
  font-family: var(--font--primary-font);
  font-size: 14px;
}

/* Chat page */
.healix-chat-body {
  --stage-accent: var(--color--neutral-04);
  --stage-accent-strong: var(--color--neutral-04);
  --stage-surface: #f5f7fa;
  --stage-surface-strong: #eef1f5;
  --stage-text-on-accent: var(--color--neutral-01);
  background-color: var(--color--neutral-02);
  min-height: 100vh;
  font-family: var(--font--primary-font);
  transition: background-color 0.3s ease;
}

.healix-chat-body[data-step="1"] {
  --stage-accent: #2563eb;
  --stage-accent-strong: #1d4ed8;
  --stage-surface: #eff6ff;
  --stage-surface-strong: #dbeafe;
  --stage-text-on-accent: #ffffff;
  background-color: #f3f8ff;
}

.healix-chat-body[data-step="2"] {
  --stage-accent: #7c3aed;
  --stage-accent-strong: #6d28d9;
  --stage-surface: #f5f3ff;
  --stage-surface-strong: #ede9fe;
  --stage-text-on-accent: #ffffff;
  background-color: #f7f5ff;
}

.healix-chat-body[data-step="3"] {
  --stage-accent: #16a34a;
  --stage-accent-strong: #15803d;
  --stage-surface: #f0fdf4;
  --stage-surface-strong: #dcfce7;
  --stage-text-on-accent: #ffffff;
  background-color: #f2fbf5;
}

.healix-chat-section {
  padding: 40px 0 60px;
}

.healix-chat-section .w-container {
  max-width: 960px;
}

.healix-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.healix-chat-logo img {
  height: 32px;
  display: block;
}

.healix-chat-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.healix-chat-user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: right;
}

.healix-chat-user-name {
  font-weight: 600;
  color: var(--color--neutral-04);
  font-size: 15px;
}

.healix-chat-user-role {
  font-size: 12px;
  color: var(--color--neutral-03);
  text-transform: capitalize;
}

.healix-chat-logout {
  background: transparent;
  border: 1px solid #d0d5dd;
  color: var(--color--neutral-04);
  padding: 8px 14px;
  border-radius: 100px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.healix-chat-logout:hover {
  background-color: #fff;
}

.healix-chat-card {
  background-color: #fff;
  border-radius: 24px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 4px 24px rgba(10, 10, 10, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 560px;
}

.healix-chat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid #eef0f3;
}

.healix-chat-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--color--neutral-04);
}

.healix-chat-status {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--color--neutral-03);
}

.healix-chat-status.is-active {
  color: #067647;
}

.healix-chat-status.is-ended {
  color: #b42318;
}

.healix-chat-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.healix-chat-btn {
  appearance: none;
  border: 1px solid var(--color--neutral-04);
  background-color: var(--color--neutral-04);
  color: var(--color--neutral-01);
  border-radius: 100px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.healix-chat-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.healix-chat-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.healix-chat-btn.is-danger {
  background-color: #fff;
  color: #b42318;
  border-color: #fda29b;
}

.healix-chat-btn.is-danger:hover:not(:disabled) {
  background-color: #fef3f2;
  opacity: 1;
}

.healix-chat-messages {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: #fafbfc;
  min-height: 360px;
  max-height: 60vh;
}

.healix-chat-empty {
  margin: auto;
  color: var(--color--neutral-03);
  font-size: 14px;
  text-align: center;
  padding: 24px;
}

.healix-message {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(10, 10, 10, 0.04);
}

.healix-message-meta {
  display: block;
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
}

.healix-message.is-mine {
  align-self: flex-end;
  background-color: var(--stage-accent);
  color: var(--stage-text-on-accent);
  border-bottom-right-radius: 4px;
  transition: background-color 0.3s ease;
}

.healix-message.is-theirs {
  align-self: flex-start;
  background-color: #fff;
  color: var(--color--neutral-04);
  border: 1px solid #eef0f3;
  border-bottom-left-radius: 4px;
}

.healix-chat-composer {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid #eef0f3;
  background-color: #fff;
}

.healix-chat-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 100px;
  border: 1px solid #d0d5dd;
  font-family: inherit;
  font-size: 14px;
  color: var(--color--neutral-04);
  outline: none;
  background-color: #fff;
}

.healix-chat-input:focus {
  border-color: var(--color--neutral-04);
}

.healix-chat-input:disabled {
  background-color: #f5f6f7;
  cursor: not-allowed;
}

.healix-chat-send {
  min-width: 100px;
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  border: none;
}

.healix-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Ensure the `hidden` attribute wins over custom display values. */
.healix-stage-bar[hidden],
.healix-stage-panel[hidden],
.healix-approve-panel[hidden],
.healix-chat-approve-btn[hidden],
.healix-stage-timer[hidden],
.healix-doctor-chip[hidden] {
  display: none !important;
}

/* Stage bar (sticky) */
.healix-stage-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: linear-gradient(180deg, var(--stage-surface-strong) 0%, var(--stage-surface) 100%);
  border-bottom: 1px solid var(--stage-surface-strong);
  cursor: pointer;
  user-select: none;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.healix-stage-bar:focus-visible {
  outline: 2px solid var(--stage-accent);
  outline-offset: -2px;
}

.healix-stage-bar-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.healix-stage-bar-text {
  min-width: 0;
}

.healix-stage-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--stage-accent);
  color: var(--stage-text-on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  transition: background-color 0.3s ease;
}

.healix-stage-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color--neutral-04);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.healix-stage-desc {
  font-size: 12px;
  color: var(--color--neutral-03);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.healix-stage-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.healix-stage-chevron {
  color: var(--stage-accent);
  transition: transform 0.25s ease;
  display: inline-flex;
}

.healix-stage-bar[aria-expanded="true"] .healix-stage-chevron {
  transform: rotate(180deg);
}

.healix-stage-timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background-color: #ffffff;
  border: 1px solid var(--stage-accent);
  color: var(--stage-accent-strong);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.healix-stage-timer.is-warning {
  background-color: #fff7ed;
  border-color: #f97316;
  color: #c2410c;
  animation: healixTimerPulse 1.2s ease-in-out infinite;
}

.healix-stage-timer.is-expired {
  background-color: #f3f4f6;
  border-color: #d1d5db;
  color: #6b7280;
  animation: none;
}

@keyframes healixTimerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  .healix-stage-timer.is-warning { animation: none; }
}

/* Stage panel */
.healix-stage-panel {
  border-bottom: 1px solid #eef0f3;
  background-color: #ffffff;
}

.healix-stage-steps {
  list-style: none;
  margin: 0;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.healix-stage-step {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #eef0f3;
  background-color: #fafbfc;
}

.healix-stage-step[data-state="current"] {
  border-color: var(--stage-accent);
  background-color: var(--stage-surface);
}

.healix-stage-step[data-state="done"] {
  border-color: #d1fae5;
  background-color: #f0fdf4;
}

.healix-stage-step-index {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background-color: #e5e7eb;
  color: var(--color--neutral-03);
}

.healix-stage-step[data-state="current"] .healix-stage-step-index {
  background-color: var(--stage-accent);
  color: var(--stage-text-on-accent);
}

.healix-stage-step[data-state="done"] .healix-stage-step-index {
  background-color: #16a34a;
  color: #ffffff;
}

.healix-stage-step-body {
  flex: 1;
  min-width: 0;
}

.healix-stage-step-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color--neutral-04);
  display: flex;
  align-items: center;
  gap: 8px;
}

.healix-stage-step-status {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background-color: #e5e7eb;
  color: var(--color--neutral-03);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.healix-stage-step[data-state="current"] .healix-stage-step-status {
  background-color: var(--stage-accent);
  color: var(--stage-text-on-accent);
}

.healix-stage-step[data-state="done"] .healix-stage-step-status {
  background-color: #16a34a;
  color: #ffffff;
}

.healix-stage-step-desc {
  font-size: 12px;
  color: var(--color--neutral-03);
  margin-top: 2px;
}

.healix-stage-step-result {
  margin-top: 8px;
  padding: 10px 12px;
  background-color: #ffffff;
  border: 1px dashed #d1d5db;
  border-radius: 10px;
  font-size: 13px;
  color: var(--color--neutral-04);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.healix-stage-step-lock {
  margin-top: 6px;
  font-size: 11px;
  color: #16a34a;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* System (stage-complete) card inside messages */
.healix-system-card {
  align-self: stretch;
  margin: 6px auto;
  max-width: 92%;
  padding: 14px 16px;
  border-radius: 14px;
  background-color: var(--stage-surface);
  border: 1px solid var(--stage-accent);
  color: var(--color--neutral-04);
  box-shadow: 0 2px 8px rgba(10, 10, 10, 0.04);
}

.healix-system-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--stage-accent-strong);
  margin-bottom: 6px;
}

.healix-system-card-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--stage-accent);
}

.healix-system-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.healix-system-card-body {
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Approve (doctor) button + panel */
.healix-chat-approve-btn {
  appearance: none;
  border: 1px solid var(--stage-accent);
  background-color: #ffffff;
  color: var(--stage-accent-strong);
  border-radius: 100px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.healix-chat-approve-btn:hover:not(:disabled) {
  background-color: var(--stage-surface);
}

.healix-chat-approve-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.healix-approve-panel {
  border-top: 1px solid #eef0f3;
  padding: 16px 20px;
  background-color: var(--stage-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.healix-approve-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--stage-accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.healix-approve-text {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #d0d5dd;
  background-color: #ffffff;
  font-family: inherit;
  font-size: 14px;
  color: var(--color--neutral-04);
  resize: vertical;
  min-height: 72px;
  outline: none;
}

.healix-approve-text:focus {
  border-color: var(--stage-accent);
}

.healix-approve-error {
  color: #b42318;
  font-size: 12px;
}

.healix-approve-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.healix-approve-btn {
  appearance: none;
  border: none;
  border-radius: 100px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.healix-approve-btn.is-ghost {
  background-color: transparent;
  color: var(--color--neutral-04);
  border: 1px solid #d0d5dd;
}

.healix-approve-btn.is-primary {
  background-color: var(--stage-accent);
  color: var(--stage-text-on-accent);
}

.healix-approve-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.healix-approve-btn:hover:not(:disabled) {
  opacity: 0.9;
}

/* Doctor chip (patient header) */
.healix-doctor-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 14px;
  border-radius: 14px;
  border: 1px solid var(--stage-surface-strong);
  background-color: var(--stage-surface);
  color: var(--color--neutral-04);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.healix-doctor-chip:hover {
  border-color: var(--stage-accent);
  transform: translateY(-1px);
}

.healix-doctor-chip-label {
  font-size: 10.5px;
  color: var(--color--neutral-03);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.healix-doctor-chip-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--stage-accent-strong);
}

/* Modal shell */
.healix-modal[hidden] {
  display: none !important;
}

.healix-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.healix-modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(10, 14, 20, 0.45);
  backdrop-filter: blur(2px);
  animation: healixFadeIn 0.18s ease;
}

.healix-modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background-color: #ffffff;
  border-radius: 18px;
  padding: 28px 26px 22px;
  box-shadow: 0 12px 40px rgba(10, 14, 20, 0.18);
  animation: healixPopIn 0.22s ease;
}

.healix-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  appearance: none;
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--color--neutral-03);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
}

.healix-modal-close:hover {
  background-color: #f3f4f6;
  color: var(--color--neutral-04);
}

.healix-modal-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--color--neutral-04);
}

.healix-modal-desc {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--color--neutral-03);
  line-height: 1.5;
}

.healix-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

@keyframes healixFadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes healixPopIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .healix-modal-backdrop,
  .healix-modal-card { animation: none; }
}

/* Doctor info modal */
.healix-doctor-modal {
  text-align: left;
}

.healix-doctor-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background-color: var(--stage-surface);
  color: var(--stage-accent-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.healix-doctor-info {
  margin: 14px 0 4px;
  display: grid;
  gap: 10px;
}

.healix-doctor-info > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.healix-doctor-info dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color--neutral-03);
  font-weight: 600;
}

.healix-doctor-info dd {
  margin: 0;
  font-size: 14px;
  color: var(--color--neutral-04);
  word-break: break-word;
}

/* Rating modal */
.healix-rating-stars {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0 6px;
}

.healix-rating-star {
  flex: 1;
  aspect-ratio: 1 / 1;
  appearance: none;
  border: 2px solid #e5e7eb;
  border-radius: 50%;
  background-color: #ffffff;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  color: var(--color--neutral-03);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.healix-rating-star:hover:not(:disabled) {
  border-color: var(--stage-accent);
  color: var(--stage-accent-strong);
  transform: translateY(-1px);
}

.healix-rating-star.is-selected {
  background-color: var(--stage-accent);
  border-color: var(--stage-accent);
  color: var(--stage-text-on-accent);
}

.healix-rating-star[aria-checked="true"] {
  background-color: var(--stage-accent);
  border-color: var(--stage-accent);
  color: var(--stage-text-on-accent);
}

@media (max-width: 640px) {
  .healix-chat-section {
    padding: 20px 0 40px;
  }
  .healix-chat-section .w-container {
    padding-left: 12px;
    padding-right: 12px;
  }
  .healix-chat-card-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .healix-chat-messages {
    padding: 16px;
    max-height: 55vh;
  }
  .healix-message {
    max-width: 85%;
  }
  .healix-stage-bar {
    padding: 12px 14px;
  }
  .healix-stage-desc {
    white-space: normal;
  }
  .healix-approve-panel {
    padding: 14px;
  }
  .healix-chat-composer {
    flex-wrap: wrap;
  }
  .healix-chat-approve-btn {
    width: 100%;
    order: 3;
  }
  .healix-doctor-chip {
    order: -1;
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .healix-stage-timer {
    padding: 5px 10px;
    font-size: 12px;
  }
  .healix-rating-star {
    font-size: 16px;
  }
  .healix-modal-card {
    padding: 22px 18px 18px;
  }
}
