/**
 * AI Health Assistant search form styling.
 * Scoped under .ai-search so it never leaks into the rest of the theme.
 */

.ai-search {
  width: 100%;
}

.ai-search .ai-search-form {
  margin: 0;
}

/* ---- Prompt box ---- */
.ai-search-box {
  background: #ffffff;
  border: 1px solid #e6ebf5;
  border-radius: 16px;
  box-shadow: 0 18px 40px -24px rgba(37, 99, 235, 0.35);
  padding: 22px 20px 18px;
  transition: box-shadow .3s ease, border-color .3s ease, transform .3s ease;
}

.ai-search-box:focus-within {
  border-color: #2563eb;
  box-shadow: 0 22px 48px -22px rgba(37, 99, 235, 0.55);
}

.ai-search-field .form-item,
.ai-search-field .form-item__field-wrapper {
  margin: 0;
}

.ai-search-input,
.ai-search textarea.ai-search-input {
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.55;
  color: #1f2a44;
  padding: 10px 6px 8px;
  min-height: 74px;
  box-shadow: none;
}

.ai-search-input::placeholder {
  color: #9aa6bf;
}

/* ---- In-field toolbar ---- */
.ai-search-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.ai-search-tools {
  display: flex;
  gap: 8px;
}

.ai-tool {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #e6ebf5;
  background: #f6f8fd;
  color: #5b6b8c;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .25s ease;
}

.ai-tool:hover {
  background: #eaf0ff;
  color: #2563eb;
  border-color: #cdddff;
  transform: translateY(-1px);
}

/* ---- Send button (round, icon over Drupal submit input) ---- */
.ai-search-submit {
  position: relative;
  width: 42px;
  height: 42px;
}

.ai-search-submit .ai-search-send {
  position: absolute;
  inset: 0;
  width: 42px;
  height: 42px;
  /* Neutralise the theme's global input styling (padding / content-box)
     that otherwise inflates this into an oversized oval and knocks the
     overlaid send icon off-centre. */
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  min-height: 0;
  line-height: 42px;
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: transparent;
  font-size: 0;
  cursor: pointer;
  box-shadow: 0 10px 18px -8px rgba(37, 99, 235, 0.8);
  transition: transform .25s ease, box-shadow .25s ease, filter .25s ease;
}

/* Send glyph: crisp inline SVG paper-plane, centred over the round button. */
.ai-search-send-ic {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 19px;
  height: 19px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.ai-search-submit:hover .ai-search-send {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 14px 22px -8px rgba(37, 99, 235, 0.9);
}

/* ---- Mode buttons ---- */
.ai-search-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.ai-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 10px;
  white-space: nowrap;
  border: 1px solid #dbe3f4;
  background: #ffffff;
  color: #3a4a6b;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .25s ease;
}

.ai-mode-btn i {
  color: #2563eb;
  font-size: 13px;
}

.ai-mode-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 10px 18px -12px rgba(37, 99, 235, 0.6);
}

.ai-mode-btn--primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-color: transparent;
  color: #fff;
}

.ai-mode-btn--primary i {
  color: #fff;
}

.ai-mode-btn--primary:hover {
  color: #fff;
  filter: brightness(1.05);
}

/* ---- Privacy note ---- */
.ai-search-privacy {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 26px 0 0;
  font-size: 13px !important;
  line-height: 1.55;
  letter-spacing: normal;
  word-spacing: normal;
  color: #7a89a8;
}

.ai-search-privacy i {
  color: #2563eb;
  font-size: 13px;
  line-height: inherit;
  position: relative;
  top: 2px;
  flex: none;
}

/* ---- Voice recording panel ---- */
.ai-voice {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid #dbe3f4;
  border-radius: 14px;
  background: linear-gradient(180deg, #f7f9ff, #f2f0ff);
}

.ai-voice-live {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-voice-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ef4444;
  flex: none;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: ai-voice-pulse 1.4s infinite;
}

@keyframes ai-voice-pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.ai-voice-label {
  font-size: 13px;
  font-weight: 600;
  color: #4257d8;
  flex: none;
}

.ai-voice-wave {
  flex: 1;
  height: 48px;
  min-width: 0;
}

.ai-voice-time {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: #5b6b8c;
  flex: none;
}

.ai-voice-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.ai-voice-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #dbe3f4;
  background: #fff;
  color: #3a4a6b;
  transition: all .2s ease;
}

.ai-voice-cancel:hover {
  border-color: #cbd5e8;
  background: #f3f5fb;
}

.ai-voice-stop {
  border-color: transparent !important;
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  color: #fff !important;
  box-shadow: 0 10px 18px -10px rgba(220, 38, 38, 0.8);
}

.ai-voice-stop:hover {
  filter: brightness(1.05);
}

.ai-voice-status {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: #4257d8;
  padding: 4px 2px;
}

.ai-voice-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #c7d2fe;
  border-top-color: #4257d8;
  border-radius: 50%;
  flex: none;
  animation: ai-voice-spin .8s linear infinite;
}

@keyframes ai-voice-spin { to { transform: rotate(360deg); } }

.ai-voice-error {
  margin-top: 8px;
  font-size: 13px;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 9px;
  padding: 9px 12px;
}

/* ---- AI symptom → specialist recommendation ---- */
.ai-analyze {
  margin-top: 16px;
  border: 1px solid #dbe3f4;
  border-radius: 16px;
  background: linear-gradient(180deg, #f6f9ff, #f3f0ff);
  padding: 18px 18px 20px;
}

.ai-analyze-loading {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: #4257d8;
}

.ai-analyze-error {
  font-size: 13px;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 9px;
  padding: 9px 12px;
}

.ai-analyze-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #2563eb;
  background: #e7eefb;
  padding: 5px 11px;
  border-radius: 30px;
}

.ai-analyze-head h3 {
  font-size: 19px;
  font-weight: 800;
  color: #1f2a44;
  margin: 10px 0 0;
}

.ai-analyze-specialty {
  background: linear-gradient(135deg, #3b82f6, #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.ai-analyze-reason {
  margin: 6px 0 0 !important;
  font-size: 13.5px;
  color: #46557a;
  line-height: 1.55;
}

.ai-analyze-docs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 10px;
}

.ai-analyze-docs-head strong { font-size: 13.5px; color: #1f2a44; }

.ai-analyze-viewall {
  font-size: 12.5px;
  font-weight: 600;
  color: #2563eb;
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.ai-analyze-docs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ai-doc {
  background: #fff;
  border: 1px solid #e6ebf5;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease, box-shadow .25s ease;
}

.ai-doc:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 30px -22px rgba(37, 99, 235, .6);
}

.ai-doc-photo {
  aspect-ratio: 4 / 3;
  background: #dce6f7;
}

.ai-doc-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ai-doc-noimg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: #9db4d8;
}

.ai-doc-body { padding: 11px 12px 13px; display: flex; flex-direction: column; flex: 1; }
.ai-doc-body h4 { font-size: 14px; font-weight: 700; color: #1f2a44; margin: 0; display: flex; align-items: center; gap: 5px; }
.ai-doc-body h4 .fa-circle-check { color: #2563eb; font-size: 12px; }
.ai-doc-spec { color: #2563eb; font-size: 12px; font-weight: 600; margin-top: 2px; }
.ai-doc-loc, .ai-doc-exp { font-size: 11.5px; color: #5b6b8c; margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.ai-doc-loc .fa-location-dot { color: #ef4f8b; font-size: 11px; }
.ai-doc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: auto; padding-top: 11px; }
.ai-doc-btn {
  text-align: center;
  padding: 7px 6px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid #dbe3f4;
  color: #3a4a6b;
}
.ai-doc-btn--primary {
  border-color: transparent;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
}
.ai-doc-btn:hover { filter: brightness(1.03); }

.ai-analyze-none { font-size: 13px; color: #7a89a8; }

.ai-analyze-disclaimer {
  margin: 14px 0 0 !important;
  font-size: 11.5px;
  color: #8a97b3;
  line-height: 1.5;
}

@media (max-width: 700px) {
  .ai-analyze-docs { grid-template-columns: 1fr; }
}

/* ---- Uploaded report / X-ray analysis ---- */
.ai-report {
  margin-top: 16px;
  border: 1px solid #dbe3f4;
  border-radius: 16px;
  background: linear-gradient(180deg, #f6f9ff, #f3f0ff);
  padding: 18px;
}

.ai-report-loading {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: #4257d8;
}

.ai-report-error {
  font-size: 13px;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 9px;
  padding: 9px 12px;
  margin-bottom: 10px;
}

/* Staged (attached, not yet analyzed) preview */
.ai-report-stage {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: #fff;
  border: 1px solid #e0e7f5;
  border-radius: 12px;
}

.ai-report-stage .ai-report-thumb {
  width: 56px;
  height: 56px;
  margin: 0;
}

.ai-report-stage-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.ai-report-filename {
  font-size: 13px;
  font-weight: 600;
  color: #1f2a44;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-report-hint {
  font-size: 12px;
  color: #4257d8;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ai-report-remove {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid #e6ebf5;
  background: #f6f8fd;
  color: #5b6b8c;
  cursor: pointer;
  font-size: 13px;
}

.ai-report-remove:hover { background: #fdecef; color: #ef4f8b; border-color: #fbd5df; }

.ai-report-result { margin-top: 12px; }

.ai-report-body {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  align-items: flex-start;
}

.ai-report-thumb {
  width: 120px;
  height: 120px;
  flex: none;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid #e0e7f5;
  background: #0f172a;
}

.ai-report-text {
  font-size: 13.5px;
  line-height: 1.6;
  color: #2a3650;
  white-space: pre-wrap;
}

.ai-report-raw {
  margin-top: 12px;
  font-size: 12px;
}

.ai-report-raw summary {
  cursor: pointer;
  color: #4257d8;
  font-weight: 600;
}

.ai-report-json {
  margin: 8px 0 0;
  padding: 12px 14px;
  max-height: 280px;
  overflow: auto;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 700px) {
  .ai-report-body { flex-direction: column; }
  .ai-report-thumb { width: 100%; height: 180px; }
}

/* ---- Inline recommendation message (assistant bubble) ---- */
.ai-msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 12px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #e0e7f5;
  border-radius: 14px;
  animation: ai-msg-in .25s ease;
}

@keyframes ai-msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.ai-msg-ic {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #7c3aed);
}

.ai-msg-body { flex: 1; min-width: 0; }

.ai-msg-text {
  margin: 0 0 6px !important;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  color: #1f2a44;
}

.ai-msg-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: #2563eb;
}

.ai-msg-link:hover { color: #1d4ed8; }

/* ---- Validation / messages tweaks ---- */
.ai-search .messages {
  margin-top: 12px;
  border-radius: 10px;
}
