/* ==========================================================================
   AI Skin Analysis — Floating Chat Bubble + Conversational Widget
   Uses the site's existing brand variables (see css/style.css :root)
   ========================================================================== */

.ai-bubble-wrap {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .7em;
  font-family: 'Jost', sans-serif;
}

.ai-bubble-tooltip {
  max-width: 230px;
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--cream);
  border-radius: 16px 16px 4px 16px;
  padding: .85em 1em;
  font-size: .85rem;
  line-height: 1.4;
  box-shadow: 0 10px 30px rgba(43,43,43,.12);
  opacity: 0;
  transform: translateY(8px) scale(.97);
  transition: opacity .4s ease, transform .4s ease;
  pointer-events: none;
}
.ai-bubble-tooltip.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.ai-bubble-tooltip button.ai-tooltip-close {
  position: absolute;
  top: 4px;
  right: 7px;
  border: none;
  background: none;
  color: var(--gold-light);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.ai-bubble-tooltip strong {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: .95rem;
  margin-bottom: .2em;
  color: var(--ink-soft);
}

.ai-bubble-btn {
  display: flex;
  align-items: center;
  gap: .55em;
  background: var(--ink-soft);
  color: var(--white);
  border: none;
  border-radius: 999px;
  padding: .85em 1.3em;
  font-family: 'Jost', sans-serif;
  font-size: .88rem;
  letter-spacing: .03em;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(43,43,43,.22);
  transition: transform .25s ease, box-shadow .25s ease, background .25s ease;
}
.ai-bubble-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(43,43,43,.28);
  background: var(--gold);
}
.ai-bubble-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.ai-bubble-btn .ai-bubble-label { white-space: nowrap; }

@media (max-width: 600px) {
  .ai-bubble-wrap { right: 14px; bottom: 14px; }
  .ai-bubble-btn { padding: .8em 1em; font-size: .82rem; }
  .ai-bubble-tooltip { max-width: 190px; font-size: .8rem; }
}

/* ---------------- Overlay + Panel ---------------- */

.ai-chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43,43,43,.45);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity .25s ease;
}
.ai-chat-overlay.open { opacity: 1; }
.ai-chat-overlay[hidden] { display: none; }

.ai-chat-panel {
  background: var(--cream-light);
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(0,0,0,.3);
  transform: translateY(16px) scale(.98);
  transition: transform .3s ease;
}
.ai-chat-overlay.open .ai-chat-panel { transform: translateY(0) scale(1); }

.ai-chat-header {
  background: var(--ink-soft);
  color: var(--white);
  padding: 1em 1.3em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ai-chat-header .ai-chat-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  letter-spacing: .01em;
}
.ai-chat-header .ai-chat-title small {
  display: block;
  font-family: 'Jost', sans-serif;
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-top: .15em;
}
#ai-chat-close {
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  opacity: .85;
}
#ai-chat-close:hover { opacity: 1; }

.ai-chat-body {
  padding: 1.5em 1.4em 1.7em;
  overflow-y: auto;
  flex: 1;
  font-size: .92rem;
  line-height: 1.55;
  color: var(--ink);
}

.ai-step { animation: aiFadeIn .35s ease; }
@keyframes aiFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.ai-step p { margin: 0 0 1em; }
.ai-step h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  color: var(--ink-soft);
  margin: 0 0 .5em;
}

.ai-disclaimer-box {
  background: var(--white);
  border: 1px solid var(--cream);
  border-radius: 12px;
  padding: 1em 1.1em;
  font-size: .82rem;
  color: var(--ink);
  margin-bottom: 1.1em;
}

.ai-field {
  margin-bottom: .9em;
}
.ai-field label {
  display: block;
  font-size: .75rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: .35em;
}
.ai-field input {
  width: 100%;
  padding: .75em .9em;
  border: 1px solid var(--cream);
  border-radius: 10px;
  background: var(--white);
  font-family: 'Jost', sans-serif;
  font-size: .92rem;
  color: var(--ink);
}
.ai-field input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.ai-field-error {
  color: #a4453a;
  font-size: .76rem;
  margin-top: .3em;
  display: none;
}
.ai-field.invalid input { border-color: #a4453a; }
.ai-field.invalid .ai-field-error { display: block; }

.ai-consent-row {
  display: flex;
  align-items: flex-start;
  gap: .6em;
  margin-bottom: 1.2em;
  cursor: pointer;
  font-size: .88rem;
}
.ai-consent-row input { margin-top: .25em; width: 16px; height: 16px; accent-color: var(--gold); }

.ai-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  width: 100%;
  background: var(--ink-soft);
  color: var(--white);
  border: none;
  border-radius: 999px;
  padding: .85em 1.2em;
  font-family: 'Jost', sans-serif;
  font-size: .92rem;
  letter-spacing: .02em;
  cursor: pointer;
  transition: background .25s ease, transform .2s ease;
}
.ai-btn:hover:not(:disabled) { background: var(--gold); }
.ai-btn:disabled { background: var(--gold-light); cursor: not-allowed; opacity: .7; }
.ai-btn.ai-btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--gold-light);
}
.ai-btn.ai-btn-ghost:hover { background: var(--white); }

.ai-upload-zone {
  border: 1.5px dashed var(--gold-light);
  border-radius: 14px;
  padding: 1.6em 1em;
  text-align: center;
  background: var(--white);
  margin-bottom: 1em;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.ai-upload-zone:hover { border-color: var(--gold); background: #fbf8f4; }
.ai-upload-zone svg { width: 34px; height: 34px; color: var(--gold); margin-bottom: .5em; }
.ai-upload-zone .ai-upload-hint { font-size: .78rem; color: var(--gold-light); margin-top: .3em; }

.ai-upload-actions {
  display: flex;
  gap: .6em;
  margin-bottom: .6em;
}
.ai-upload-actions .ai-btn { font-size: .82rem; padding: .7em 1em; }

.ai-upload-hint {
  font-size: .76rem;
  color: var(--gold-light);
  margin: 0 0 1em;
  line-height: 1.4;
}

/* Visually hidden (not display:none) — display:none file inputs are unreliable
   for triggering the native camera prompt on some mobile browsers. */
#ai-selfie-input, #ai-selfie-input-camera {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.ai-camera-live {
  margin-bottom: 1em;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--cream);
  background: #000;
}
.ai-camera-live video {
  width: 100%;
  max-height: 320px;
  display: block;
  object-fit: cover;
  transform: scaleX(-1); /* mirror the front camera preview */
}
.ai-camera-actions {
  display: flex;
  gap: .6em;
  padding: .7em;
  background: var(--white);
}
.ai-camera-actions .ai-btn { flex: 1; font-size: .82rem; padding: .7em 1em; }

.ai-preview-wrap {
  position: relative;
  margin-bottom: 1.1em;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--cream);
}
.ai-preview-wrap img { width: 100%; display: block; max-height: 320px; object-fit: cover; }

/* Mobile only: fixed 4:5 portrait box for both the live camera preview and
   the captured-photo preview, so they always match each other exactly and
   there's no leftover black gap below the video (which happened because the
   old max-height cap didn't reserve a definite box height on phones).
   Desktop is untouched above.

   The ratio goes on the <video> itself, NOT on .ai-camera-live — that outer
   box also wraps the Capture/Cancel button row below the video, so forcing
   IT to 4:5 with the video at height:100% left no room for the buttons and
   overflow:hidden clipped them off-screen (Capture became unreachable). */
@media (max-width: 600px) {
  .ai-camera-live video {
    aspect-ratio: 4 / 5;
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: cover;
  }
  .ai-preview-wrap {
    aspect-ratio: 4 / 5;
  }
  .ai-preview-wrap img {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
  }
}
.ai-preview-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(43,43,43,.65);
  color: var(--white);
  border: none;
  border-radius: 999px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: .9rem;
}

.ai-loading {
  text-align: center;
  padding: 1.6em 0;
}
.ai-spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 1em;
  border: 3px solid var(--cream);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: aiSpin .9s linear infinite;
}
@keyframes aiSpin { to { transform: rotate(360deg); } }
.ai-loading p { color: var(--gold); font-size: .85rem; }

.ai-result-section {
  margin-bottom: 1em;
}
.ai-result-section h4 {
  font-family: 'Jost', sans-serif;
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 .35em;
}
.ai-result-section p { margin: 0; font-size: .9rem; }

.ai-result-summary {
  background: var(--white);
  border: 1px solid var(--cream);
  border-radius: 12px;
  padding: 1.1em 1.2em;
  margin: 1.1em 0;
  font-size: .9rem;
}

.ai-treatment-match {
  background: var(--white);
  border: 1px solid var(--gold-light);
  border-radius: 14px;
  padding: 1.2em 1.3em;
  margin: 1.2em 0 1.4em;
}
.ai-treatment-match h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  color: var(--ink-soft);
  margin: 0 0 .7em;
}
.ai-treatment-match h4 {
  font-family: 'Jost', sans-serif;
  font-size: .76rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 .3em;
}
.ai-treatment-match p { margin: 0; font-size: .9rem; }
.ai-treatment-primary { margin-bottom: 1em; }
.ai-treatment-label {
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: .2em;
}
.ai-treatment-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  color: var(--ink-soft);
}
.ai-treatment-why { margin-bottom: 1em; }
.ai-treatment-secondary { margin-bottom: 1em; }
.ai-treatment-secondary ul { list-style: none; margin: 0; padding: 0; }
.ai-treatment-secondary li {
  font-size: .88rem;
  padding: .55em 0;
  border-top: 1px solid var(--cream);
}
.ai-treatment-secondary li:first-child { border-top: none; padding-top: 0; }
.ai-treatment-secondary li strong { color: var(--ink-soft); }
.ai-treatment-next p { font-size: .9rem; }

.ai-error-box {
  background: #fbeceb;
  border: 1px solid #e3b6b1;
  color: #7a2b22;
  border-radius: 10px;
  padding: .9em 1em;
  font-size: .82rem;
  margin-bottom: 1em;
}

.ai-progress-dots {
  display: flex;
  gap: .35em;
  justify-content: center;
  margin-bottom: 1.2em;
}
.ai-progress-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cream);
}
.ai-progress-dots span.active { background: var(--gold); }
