/* ============================================
   407 LEGAL · Sofia "call me now" widget
   Floating bubble + call-request form. Uses brand tokens from styles.css.
   ============================================ */

/* Language visibility for injected markup (mirrors the global data-lang rules) */
.sofia [data-lang-en] { display: none; }
html[lang="en"] .sofia [data-lang-en] { display: inline; }
html[lang="en"] .sofia [data-lang-es] { display: none; }

/* ---------- Floating bubble ---------- */
.sofia-fab {
  position: fixed;
  right: 18px;
  bottom: 24px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px 13px 16px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--gold);
  color: var(--navy);
  font-family: var(--f-body);
  font-weight: 800;
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform 0.18s var(--ease-out), background 0.18s var(--ease-out);
}
.sofia-fab:hover { background: var(--gold-2); transform: translateY(-2px); }
.sofia-fab:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
.sofia-fab svg { width: 22px; height: 22px; flex: none; }
.sofia-fab__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #1bbf63; flex: none;
  box-shadow: 0 0 0 0 rgba(27, 191, 99, 0.6);
  animation: sofia-live-dot 1.8s ease-out infinite;
}
@keyframes sofia-live-dot {
  0% { box-shadow: 0 0 0 0 rgba(27, 191, 99, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(27, 191, 99, 0); }
  100% { box-shadow: 0 0 0 0 rgba(27, 191, 99, 0); }
}

/* Lift the bubble above the sticky mobile CTA bar so it never overlaps */
@media (max-width: 720px) {
  .sofia-fab {
    right: 14px;
    bottom: 78px;
    padding: 12px 16px;
    font-size: 14px;
  }
}

/* ---------- Inline CTA (reuses .btn) ---------- */
.btn--sofia { gap: 9px; }
.btn--sofia svg { width: 18px; height: 18px; }

/* ---------- Call panel ---------- */
.sofia-panel {
  position: fixed;
  right: 18px;
  bottom: 86px;
  z-index: 1001;
  width: min(360px, calc(100vw - 28px));
  background: var(--navy);
  color: var(--cream);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card-lg);
  border: 1px solid rgba(244, 237, 227, 0.12);
  overflow: hidden;
  font-family: var(--f-body);
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s var(--ease-out), opacity 0.22s var(--ease-out);
}
.sofia-panel.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }

@media (max-width: 720px) {
  .sofia-panel {
    right: 10px; left: 10px;
    bottom: 78px;
    width: auto;
  }
}

.sofia-panel__head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(244, 237, 227, 0.1);
}
.sofia-panel__avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: var(--gold);
  color: var(--navy);
  display: grid; place-items: center;
  font-weight: 800; font-size: 17px;
  font-family: var(--f-display);
}
.sofia-panel__id { display: flex; flex-direction: column; line-height: 1.25; }
.sofia-panel__name { font-weight: 700; font-size: 15px; color: var(--white); }
.sofia-panel__role { font-size: 12px; color: rgba(244, 237, 227, 0.66); }
.sofia-panel__close {
  margin-left: auto;
  background: none; border: none; color: rgba(244, 237, 227, 0.7);
  cursor: pointer; padding: 6px; border-radius: 8px; line-height: 0;
}
.sofia-panel__close:hover { color: var(--white); background: rgba(244, 237, 227, 0.08); }

.sofia-panel__body { padding: 16px; }

.sofia-panel__msg { font-size: 14px; color: rgba(244, 237, 227, 0.9); margin: 0 0 14px; min-height: 20px; }
.sofia-panel__timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 15px; color: var(--gold-3);
  margin: 0 0 14px;
}

.sofia-btn {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 14px 18px;
  border: none; border-radius: var(--radius);
  font-family: var(--f-body); font-weight: 800; font-size: 15px;
  cursor: pointer;
  transition: background 0.16s var(--ease-out), transform 0.16s var(--ease-out);
}
.sofia-btn svg { width: 19px; height: 19px; }
.sofia-btn--start { background: var(--gold); color: var(--navy); }
.sofia-btn--start:hover { background: var(--gold-2); }
.sofia-btn--end { background: #c0341a; color: #fff; }
.sofia-btn--end:hover { background: #a32c15; }
.sofia-btn:focus-visible { outline: 3px solid var(--gold-3); outline-offset: 2px; }

.sofia-panel__fallback {
  margin: 14px 0 0;
  font-size: 13px; line-height: 1.5;
  color: rgba(244, 237, 227, 0.82);
}
.sofia-panel__fallback a { color: var(--gold-3); font-weight: 600; }

.sofia-panel__disclosure {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid rgba(244, 237, 227, 0.1);
  font-size: 11.5px; line-height: 1.5;
  color: rgba(244, 237, 227, 0.6);
}

/* Talking pulse on the avatar while the agent speaks */
.sofia-panel.is-talking .sofia-panel__avatar {
  animation: sofia-talk 0.9s ease-in-out infinite;
}
@keyframes sofia-talk {
  0%, 100% { box-shadow: 0 0 0 0 rgba(238, 167, 47, 0.0); }
  50% { box-shadow: 0 0 0 6px rgba(238, 167, 47, 0.35); }
}

/* State-driven visibility: elements carry data-show="state1 state2" */
.sofia-panel [data-show] { display: none; }
.sofia-panel[data-state="idle"] [data-show~="idle"],
.sofia-panel[data-state="submitting"] [data-show~="submitting"],
.sofia-panel[data-state="success"] [data-show~="success"] { display: block; }

/* Form inputs */
.sofia-input {
  width: 100%;
  margin: 0 0 10px;
  padding: 13px 14px;
  border: 1px solid rgba(244, 237, 227, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(244, 237, 227, 0.06);
  color: var(--white);
  font-family: var(--f-body);
  font-size: 15px;
}
.sofia-input::placeholder { color: rgba(244, 237, 227, 0.5); }
.sofia-input:focus-visible {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(238, 167, 47, 0.25);
}
.sofia-consent-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 2px 0 12px;
  font-size: 12.5px;
  line-height: 1.45;
  color: rgba(244, 237, 227, 0.82);
  cursor: pointer;
}
.sofia-consent-row input {
  margin-top: 2px;
  width: 16px; height: 16px; flex: none;
  accent-color: var(--gold);
}
.sofia-err {
  margin: 0 0 10px;
  min-height: 0;
  font-size: 13px;
  font-weight: 600;
  color: #ffc7ba;
}
.sofia-err:empty { margin: 0; }

/* Honeypot: visually and programmatically removed; only bots will fill it. */
.sofia-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Spinner for connecting state */
.sofia-spinner {
  width: 18px; height: 18px; flex: none;
  border: 2.5px solid rgba(244, 237, 227, 0.25);
  border-top-color: var(--gold-3);
  border-radius: 50%;
  animation: sofia-spin 0.8s linear infinite;
  display: inline-block; vertical-align: middle; margin-right: 8px;
}
@keyframes sofia-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .sofia-fab__dot, .sofia-panel.is-talking .sofia-panel__avatar, .sofia-spinner { animation: none; }
  .sofia-panel, .sofia-fab { transition: none; }
}
