/* ==========================================================================
   OM CABS — ASSISTANT WIDGET STYLES
   Sits above the site, below the inquiry modal. Fully responsive: a floating
   panel on desktop, a full-height sheet on phones (with safe-area insets so it
   clears the iPhone home indicator and notch).
   ========================================================================== */

.oa-launcher {
  position: fixed;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: calc(max(1.25rem, env(safe-area-inset-bottom)) + 3.75rem);
  z-index: 1500;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--teal-primary);
  color: #fff;
  box-shadow: 0 10px 30px -6px rgba(10, 92, 82, 0.5);
  transition: transform var(--transition), background var(--transition),
              box-shadow var(--transition);
}

.oa-launcher:hover {
  transform: translateY(-3px) scale(1.04);
  background: var(--teal-accent);
}

.oa-launcher:active { transform: scale(0.96); }

.oa-launcher svg { width: 25px; height: 25px; }

.oa-launcher-icon,
.oa-launcher-close {
  grid-area: 1 / 1;
  display: grid;
  place-items: center;
  transition: opacity var(--transition), transform var(--transition);
}

.oa-launcher-close { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.oa-launcher.is-active .oa-launcher-icon { opacity: 0; transform: rotate(90deg) scale(0.6); }
.oa-launcher.is-active .oa-launcher-close { opacity: 1; transform: rotate(0) scale(1); }

/* One-time attention ring, retired after first interaction. */
.oa-launcher-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--teal-accent);
  animation: oa-pulse 2.6s ease-out infinite;
}

.oa-launcher.is-active .oa-launcher-pulse,
.oa-launcher.oa-seen .oa-launcher-pulse { display: none; }

@keyframes oa-pulse {
  0%   { transform: scale(1);    opacity: 0.85; }
  70%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}

/* ------------------------------------------------------------------ panel */
.oa-panel {
  position: fixed;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: calc(max(1.25rem, env(safe-area-inset-bottom)) + 7.5rem);
  z-index: 1499;
  width: min(392px, calc(100vw - 2.5rem));
  height: min(560px, calc(100vh - 12rem));
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 18px;
  box-shadow: 0 26px 60px -14px rgba(15, 23, 42, 0.3);
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.24s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.oa-panel.is-open { opacity: 1; transform: none; }

.oa-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, var(--teal-primary), var(--teal-deep));
  color: #fff;
  flex-shrink: 0;
}

.oa-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  flex-shrink: 0;
}

.oa-avatar svg { width: 19px; height: 19px; }

.oa-head-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.oa-head-text strong { font-family: var(--font-heading); font-size: 0.95rem; color: #fff; }

.oa-status {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.75);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.oa-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal-light);
  flex-shrink: 0;
}

.oa-close {
  margin-left: auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  opacity: 0.8;
  flex-shrink: 0;
  transition: background var(--transition), opacity var(--transition);
}

.oa-close:hover { background: rgba(255, 255, 255, 0.16); opacity: 1; }
.oa-close svg { width: 16px; height: 16px; }

/* -------------------------------------------------------------------- log */
.oa-log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: var(--bg-surface);
  -webkit-overflow-scrolling: touch;
}

.oa-msg { display: flex; flex-direction: column; gap: 0.4rem; max-width: 88%; }
.oa-msg--bot { align-self: flex-start; }
.oa-msg--user { align-self: flex-end; align-items: flex-end; }

.oa-bubble {
  padding: 0.7rem 0.9rem;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.55;
  animation: oa-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.oa-msg--bot .oa-bubble {
  background: #fff;
  border: 1px solid var(--border-light);
  border-bottom-left-radius: 4px;
  color: var(--text-main);
  box-shadow: var(--shadow-xs);
}

.oa-msg--user .oa-bubble {
  background: var(--teal-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

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

.oa-topic {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--teal-primary);
  margin-bottom: 0.3rem;
}

.oa-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.oa-action {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--teal-border);
  background: var(--teal-tint);
  color: var(--teal-primary);
  font-size: 0.75rem;
  font-weight: 600;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.oa-action:hover {
  background: var(--teal-primary);
  color: #fff;
  transform: translateY(-1px);
}

/* typing indicator */
.oa-typing .oa-bubble { display: flex; gap: 4px; align-items: center; padding: 0.85rem 0.9rem; }

.oa-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-subtle);
  animation: oa-blink 1.3s infinite ease-in-out both;
}

.oa-dot:nth-child(2) { animation-delay: 0.16s; }
.oa-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes oa-blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40%           { opacity: 1;    transform: translateY(-3px); }
}

/* ------------------------------------------------------------ chips/input */
.oa-chips {
  display: flex;
  gap: 0.4rem;
  padding: 0 0.75rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.oa-chips::-webkit-scrollbar { display: none; }
.oa-chips:empty { display: none; }

.oa-chip {
  margin: 0.6rem 0 0;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-medium);
  background: #fff;
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.oa-chip:hover {
  border-color: var(--teal-primary);
  color: var(--teal-primary);
  background: var(--teal-tint);
}

.oa-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border-light);
  background: #fff;
  flex-shrink: 0;
}

.oa-input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.875rem; /* >=16px would be ideal but 14px + no zoom is fine here */
  color: var(--navy-deep);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.oa-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.oa-send {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--teal-primary);
  color: #fff;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}

.oa-send:hover { background: var(--teal-accent); transform: scale(1.06); }
.oa-send svg { width: 17px; height: 17px; }

/* ------------------------------------------------------- phones: full sheet */
@media (max-width: 640px) {
  .oa-panel {
    right: 0;
    left: 0;
    bottom: 0;
    top: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;               /* avoids the iOS URL-bar jump */
    max-height: none;
    border-radius: 0;
    border: none;
    transform: translateY(100%);
    transform-origin: bottom center;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .oa-panel.is-open { transform: none; }

  .oa-head { padding-top: max(0.85rem, env(safe-area-inset-top)); }

  /* Prevents iOS Safari zooming the page when the field takes focus. */
  .oa-input { font-size: 16px; }

  body.oa-locked { overflow: hidden; }
}

/* The launcher must not sit on top of the back-to-top button. */
@media (max-width: 640px) {
  .oa-launcher { width: 52px; height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .oa-launcher-pulse { animation: none; display: none; }
  .oa-bubble { animation: none; }
  .oa-dot { animation: none; opacity: 0.5; }
  .oa-panel { transition: opacity 0.01ms; }
}
