/* ═══════════════════════════════════════════════════════════
   opti-assistant.css — Opti360 Floating Assistant Widget
   Namespace: .oa-* — no interfiere con .cw-*, .wa-float
   ═══════════════════════════════════════════════════════════ */

/* ── FAB button ─────────────────────────────────────────── */
.oa-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 5.5rem;
  z-index: 9998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1A3A5C 0%, #29A8E0 100%);
  box-shadow:
    0 4px 20px rgba(41, 168, 224, 0.45),
    0 0 0 0 rgba(41, 168, 224, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  animation: oaPulseRing 3s ease-out infinite;
  /* iOS touch fixes: eliminates 300ms delay and tap flash */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.oa-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(41, 168, 224, 0.6);
}

.oa-fab:active { transform: scale(0.95); }

.oa-fab--open {
  animation: none;
  background: linear-gradient(135deg, #0f2744 0%, #1a5a7a 100%);
}

@keyframes oaPulseRing {
  0%   { box-shadow: 0 4px 20px rgba(41,168,224,.45), 0 0 0 0 rgba(41,168,224,.35); }
  60%  { box-shadow: 0 4px 20px rgba(41,168,224,.45), 0 0 0 12px rgba(41,168,224,.0); }
  100% { box-shadow: 0 4px 20px rgba(41,168,224,.45), 0 0 0 0 rgba(41,168,224,.0); }
}

.oa-fab__icon {
  font-size: 1.3rem;
  transition: transform 0.25s, opacity 0.2s;
  line-height: 1;
}

.oa-fab__close {
  position: absolute;
  font-size: 1.2rem;
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
  transition: transform 0.25s, opacity 0.2s;
  line-height: 1;
  color: rgba(255,255,255,0.9);
}

.oa-fab--open .oa-fab__icon {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

.oa-fab--open .oa-fab__close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Notification badge */
.oa-fab__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid var(--bg-base, #040d1e);
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s;
}

.oa-fab--open .oa-fab__badge {
  transform: scale(0);
  opacity: 0;
}

/* ── Panel ──────────────────────────────────────────────── */
.oa-panel {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 9997;
  width: 380px;
  height: 560px;
  max-height: 560px;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #040d1e;
  border: 1px solid rgba(41, 168, 224, 0.2);
  box-shadow:
    0 0 0 1px rgba(41,168,224,.08),
    0 24px 64px rgba(0,0,0,.7),
    0 8px 24px rgba(0,0,0,.4);
  transform-origin: bottom right;
  transform: scale(0.85) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.34,1.56,0.64,1), opacity 0.22s ease;
}

.oa-panel--open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Panel header ───────────────────────────────────────── */
.oa-header {
  background: linear-gradient(135deg, #1A3A5C 0%, #29A8E0 100%);
  padding: 1rem 1.1rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.oa-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a5f8a 0%, #29A8E0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(41,168,224,0.30);
}

.oa-header__info { flex: 1; min-width: 0; }

.oa-header__name {
  font-weight: 700;
  font-size: 0.88rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.oa-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6EE7B7;
  flex-shrink: 0;
  animation: oaStatusPulse 2s ease-in-out infinite;
}

@keyframes oaStatusPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ── Message feed ───────────────────────────────────────── */
.oa-feed {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 0.9rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  scroll-behavior: smooth;
}

.oa-feed::-webkit-scrollbar { width: 3px; }
.oa-feed::-webkit-scrollbar-track { background: transparent; }
.oa-feed::-webkit-scrollbar-thumb {
  background: rgba(41,168,224,0.2);
  border-radius: 2px;
}

/* ── Bubbles ────────────────────────────────────────────── */
.oa-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  max-width: 90%;
  opacity: 0;
  transform: translateY(6px);
  animation: oaMsgIn 0.24s ease forwards;
}

@keyframes oaMsgIn {
  to { opacity: 1; transform: translateY(0); }
}

.oa-msg--bot  { align-self: flex-start; }
.oa-msg--user { align-self: flex-end; flex-direction: row-reverse; }

.oa-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a5f8a 0%, #29A8E0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
  box-shadow: 0 0 0 1.5px rgba(41,168,224,0.35);
}
.oa-avatar::after {
  content: 'O';
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
}

.oa-bubble {
  padding: 0.55rem 0.8rem;
  border-radius: 14px;
  font-size: 0.84rem;
  line-height: 1.55;
  font-family: inherit;
}

.oa-msg--bot .oa-bubble {
  background: #0d1f38;
  color: #eef4ff;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(41,168,224,0.12);
}

.oa-msg--user .oa-bubble {
  background: linear-gradient(135deg, #2470A9 0%, #29A8E0 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(41,168,224,0.3);
}

/* ── Typing indicator ───────────────────────────────────── */
.oa-typing {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  align-self: flex-start;
  opacity: 0;
  animation: oaMsgIn 0.2s ease forwards;
}

.oa-typing .oa-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.6rem 0.8rem;
}

.oa-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4DC8F0;
  animation: oaDot 1.1s ease-in-out infinite;
}
.oa-dot:nth-child(2) { animation-delay: 0.18s; }
.oa-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes oaDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ── Options area ───────────────────────────────────────── */
.oa-options {
  margin-top: auto;
  flex-shrink: 0;
  padding: 0.6rem 0.9rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-top: 1px solid rgba(41,168,224,0.1);
  background: #081626;
}

.oa-opt-btn {
  width: 100%;
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(41,168,224,0.22);
  background: rgba(41,168,224,0.05);
  color: #85DAFA;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.17s, border-color 0.17s, color 0.17s, transform 0.1s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.oa-opt-btn:hover {
  background: rgba(41,168,224,0.14);
  border-color: rgba(41,168,224,0.45);
  color: #fff;
}

.oa-opt-btn:active { transform: scale(0.98); }

.oa-opt-btn__icon {
  font-size: 0.95rem;
  flex-shrink: 0;
}

/* ── Pay button (primary CTA) ────────────────────────────── */
.oa-opt-btn--primary {
  background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  box-shadow: 0 3px 14px rgba(99, 102, 241, 0.4);
  text-decoration: none;
  justify-content: center;
}
.oa-opt-btn--primary:hover {
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.55);
  transform: translateY(-1px);
}

/* ── Ghost button (tertiary) ─────────────────────────────── */
.oa-opt-btn--ghost {
  opacity: 0.65;
  font-size: 0.82rem;
  padding: 0.4rem 0.9rem;
}
.oa-opt-btn--ghost:hover {
  opacity: 1;
}

/* ── Follow-up link inside bubble ───────────────────────── */
.oa-bubble a {
  color: #85DAFA;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.oa-bubble a:hover { color: #fff; }

/* ── Inline input row (advisor flow) ───────────────────── */
.oa-input-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.oa-text-input {
  flex: 1;
  border: 1px solid rgba(41,168,224,0.25);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  font-family: inherit;
  color: #eef4ff;
  background: #0d1f38;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  min-width: 0;
}

.oa-text-input::placeholder { color: rgba(255,255,255,0.28); }

.oa-text-input:focus {
  border-color: rgba(41,168,224,0.55);
  box-shadow: 0 0 0 3px rgba(41,168,224,0.1);
}

.oa-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2470A9 0%, #29A8E0 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.17s, transform 0.1s;
}

.oa-send-btn:hover  { opacity: 0.85; }
.oa-send-btn:active { transform: scale(0.9); }
.oa-send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Powered by footer ──────────────────────────────────── */
.oa-footer {
  text-align: center;
  padding: 0.4rem 0.9rem 0.6rem;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.2);
  background: #081626;
  border-top: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}

/* ── Hide WhatsApp FAB — assistant is the primary CTA ───── */
.wa-float { display: none !important; }

/* ── Reposition Opti360 FAB to standard bottom-right ────── */
.oa-fab { right: 1.5rem; }

/* ── Mobile: compact FAB · tall panel · correct scroll ───── */
@media (max-width: 768px) {
  /* FAB: bottom-right corner, compact */
  .oa-fab {
    bottom: 1.25rem;
    right: 1.25rem;
    width: 50px;
    height: 50px;
  }

  /* Panel: nearly full height, edge-to-edge, proper scroll */
  .oa-panel {
    bottom: 4.75rem;
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    height: calc(90vh - 4.75rem);
    max-height: calc(90vh - 4.75rem);
    border-radius: 16px;
  }
}

@media (max-width: 430px) {
  .oa-fab {
    bottom: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
  }
  .oa-panel {
    bottom: 4.5rem;
    right: 0.5rem;
    left: 0.5rem;
    height: calc(90vh - 4.5rem);
    max-height: calc(90vh - 4.5rem);
  }
}
