/* ══════════════════════════════════════════════════════════
   Ask Trustinera AI — Floating Chat Widget
   ══════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────── */
:root {
  --tia-chat-bg:        #0a0f1e;
  --tia-chat-surface:   #10213E;
  --tia-chat-border:    rgba(255,255,255,0.08);
  --tia-chat-indigo:    #6366F1;
  --tia-chat-purple:    #8B5CF6;
  --tia-chat-text:      #e2e8f0;
  --tia-chat-muted:     #94a3b8;
  --tia-chat-radius:    20px;
  --tia-chat-width:     400px;
  --tia-chat-height:    500px;
}

/* ── Floating Button ───────────────────────────────────── */
.tia-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99990;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--tia-chat-indigo), var(--tia-chat-purple));
  box-shadow: 0 4px 20px rgba(99,102,241,0.35), 0 0 0 0 rgba(99,102,241,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(.4,0,.2,1), box-shadow 0.25s ease;
  /* entrance: hidden until JS triggers */
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  pointer-events: none;
}

.tia-chat-fab.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.tia-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(99,102,241,0.45), 0 0 0 0 rgba(99,102,241,0.4);
}

.tia-chat-fab:focus-visible {
  outline: 2px solid var(--tia-chat-indigo);
  outline-offset: 3px;
}

/* Pulse ring on first load */
.tia-chat-fab.is-pulsing::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(99,102,241,0.5);
  animation: tia-pulse 2s ease-out 2;
}

@keyframes tia-pulse {
  0%   { transform: scale(1);   opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* FAB icon */
.tia-chat-fab svg {
  width: 26px;
  height: 26px;
  fill: #fff;
  transition: transform 0.3s ease;
}

.tia-chat-fab[aria-expanded="true"] svg {
  transform: rotate(90deg) scale(0.85);
}

/* ── Chat Panel ────────────────────────────────────────── */
.tia-chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 99991;
  width: var(--tia-chat-width);
  height: var(--tia-chat-height);
  background: var(--tia-chat-bg);
  border-radius: var(--tia-chat-radius) var(--tia-chat-radius) 12px 12px;
  border: 1px solid var(--tia-chat-border);
  box-shadow: 0 12px 48px rgba(0,0,0,0.5), 0 0 0 1px rgba(99,102,241,0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* closed state */
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(.4,0,.2,1),
              transform 0.3s cubic-bezier(.4,0,.2,1);
}

.tia-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ────────────────────────────────────────────── */
.tia-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--tia-chat-indigo), var(--tia-chat-purple));
  flex-shrink: 0;
}

.tia-chat-header__icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #fff;
  stroke-width: 1.8;
  flex-shrink: 0;
}

.tia-chat-header__title {
  flex: 1;
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1;
}

.tia-chat-close {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.tia-chat-close:hover {
  background: rgba(255,255,255,0.25);
}

.tia-chat-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.tia-chat-close svg {
  width: 14px;
  height: 14px;
  stroke: #fff;
  stroke-width: 2.5;
}

/* ── Messages Area ─────────────────────────────────────── */
.tia-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.tia-chat-messages::-webkit-scrollbar {
  width: 5px;
}

.tia-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
}

/* Message bubbles */
.tia-chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: var(--tia-chat-text);
  word-break: break-word;
  animation: tia-msg-in 0.25s ease;
}

@keyframes tia-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tia-chat-msg--ai {
  align-self: flex-start;
  background: var(--tia-chat-surface);
  border: 1px solid var(--tia-chat-border);
  border-bottom-left-radius: 4px;
}

.tia-chat-msg--user {
  align-self: flex-end;
  background: var(--tia-chat-indigo);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.tia-chat-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 10px 14px;
  align-self: flex-start;
  background: var(--tia-chat-surface);
  border: 1px solid var(--tia-chat-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  max-width: 70px;
  animation: tia-msg-in 0.25s ease;
}

.tia-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tia-chat-muted);
  animation: tia-bounce 1.4s infinite ease-in-out both;
}

.tia-chat-typing span:nth-child(1) { animation-delay: 0s; }
.tia-chat-typing span:nth-child(2) { animation-delay: 0.16s; }
.tia-chat-typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes tia-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ── Input Area ────────────────────────────────────────── */
.tia-chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--tia-chat-border);
  background: rgba(16,33,62,0.6);
  flex-shrink: 0;
}

.tia-chat-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--tia-chat-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  color: var(--tia-chat-text);
  outline: none;
  transition: border-color 0.15s ease;
  min-height: 20px;
  resize: none;
}

.tia-chat-input::placeholder {
  color: var(--tia-chat-muted);
}

.tia-chat-input:focus {
  border-color: rgba(99,102,241,0.5);
}

.tia-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--tia-chat-indigo), var(--tia-chat-purple));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.tia-chat-send:hover {
  transform: scale(1.06);
}

.tia-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.tia-chat-send:focus-visible {
  outline: 2px solid var(--tia-chat-indigo);
  outline-offset: 2px;
}

.tia-chat-send svg {
  width: 16px;
  height: 16px;
  fill: #fff;
}

/* ── Powered-by footer ─────────────────────────────────── */
.tia-chat-powered {
  text-align: center;
  padding: 6px 0 8px;
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  font-size: 10px;
  color: rgba(148,163,184,0.5);
  flex-shrink: 0;
}

/* ── Responsive: mobile full-screen ────────────────────── */
@media (max-width: 767px) {
  .tia-chat-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    bottom: 0;
    right: 0;
  }

  .tia-chat-panel.is-open {
    transform: translateY(0) scale(1);
  }

  .tia-chat-fab {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
  }

  .tia-chat-fab svg {
    width: 22px;
    height: 22px;
  }
}
