/* ============================================================
   WicTech — AI Chat Widget
   ============================================================ */

.wt-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 900;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  box-shadow: 0 8px 30px rgba(37, 99, 235, 0.4);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease;
}

.wt-chat-launcher:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 12px 38px rgba(14, 165, 233, 0.5);
}

.wt-chat-launcher svg { width: 26px; height: 26px; }
.wt-chat-launcher__close { display: none; }
.wt-chat-launcher.is-open .wt-chat-launcher__open { display: none; }
.wt-chat-launcher.is-open .wt-chat-launcher__close { display: block; }

.wt-chat-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #060d1a;
}

/* ---------- Panel ---------- */
.wt-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  z-index: 901;
  width: min(400px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 140px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  background: #0c1626;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.wt-chat-panel.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.wt-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.16), rgba(14, 165, 233, 0.16));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.wt-chat-header__avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  flex-shrink: 0;
}

.wt-chat-header__avatar svg { width: 20px; height: 20px; }
.wt-chat-header__text { flex: 1; min-width: 0; }

.wt-chat-header__title {
  font-family: var(--font-heading, sans-serif);
  font-weight: 600;
  font-size: 0.98rem;
  color: #fff;
}

.wt-chat-header__status {
  font-size: 0.76rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wt-chat-header__status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
}

.wt-chat-header button {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.wt-chat-header button:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.wt-chat-header button svg { width: 18px; height: 18px; display: block; }
.wt-chat-header button.is-active { color: #0ea5e9; }

/* ---------- Lead gate ---------- */
/* display:flex below would defeat the hidden attribute without this override */
.wt-lead-gate[hidden] {
  display: none !important;
}

.wt-lead-gate {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 24px 22px;
}

.wt-lead-gate h4 {
  color: #fff;
  font-size: 1.02rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.wt-lead-gate p {
  color: #94a3b8;
  font-size: 0.83rem;
  line-height: 1.55;
  margin-bottom: 8px;
}

.wt-lead-gate input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: border-color 0.2s;
}

.wt-lead-gate input:focus { outline: none; border-color: rgba(14, 165, 233, 0.55); }
.wt-lead-gate input::placeholder { color: #64748b; }
.wt-lead-gate input.wt-invalid { border-color: rgba(239, 68, 68, 0.65); }

.wt-lead-gate button {
  margin-top: 6px;
  padding: 13px 16px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  transition: opacity 0.2s, transform 0.2s;
}

.wt-lead-gate button:hover { opacity: 0.92; transform: translateY(-1px); }

.wt-lead-gate .wt-lead-note {
  font-size: 0.7rem;
  color: #64748b;
  text-align: center;
  margin: 4px 0 0;
}

/* ---------- Messages ---------- */
.wt-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
}

.wt-msg {
  max-width: 85%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: wtFadeIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes wtFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.wt-msg--bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

.wt-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.wt-msg--voice { display: flex; align-items: center; gap: 8px; }
.wt-msg audio { height: 32px; max-width: 200px; }

.wt-typing { display: flex; gap: 4px; align-items: center; padding: 4px 2px; }

.wt-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
  animation: wtBounce 1.3s infinite ease-in-out;
}

.wt-typing span:nth-child(2) { animation-delay: 0.18s; }
.wt-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes wtBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ---------- Suggestions ---------- */
.wt-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 18px 12px;
}

.wt-chip {
  font-size: 0.78rem;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  color: #7dd3fc;
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.25);
  transition: background 0.2s, color 0.2s;
}

.wt-chip:hover { background: rgba(14, 165, 233, 0.2); color: #fff; }

/* ---------- Composer ---------- */
.wt-chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(6, 13, 26, 0.5);
}

.wt-chat-composer textarea {
  flex: 1;
  resize: none;
  max-height: 110px;
  min-height: 42px;
  padding: 11px 14px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: border-color 0.2s;
}

.wt-chat-composer textarea:focus { outline: none; border-color: rgba(14, 165, 233, 0.55); }
.wt-chat-composer textarea::placeholder { color: #64748b; }

.wt-icon-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.wt-icon-btn:hover { color: #fff; border-color: rgba(14, 165, 233, 0.5); }
.wt-icon-btn svg { width: 18px; height: 18px; }
.wt-icon-btn--send { background: linear-gradient(135deg, #2563eb, #0ea5e9); color: #fff; border: none; }
.wt-icon-btn--send:disabled { opacity: 0.45; cursor: not-allowed; }

.wt-icon-btn.is-recording {
  color: #fff;
  background: #ef4444;
  border-color: #ef4444;
  animation: wtPulse 1.4s infinite;
}

@keyframes wtPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
  50%      { box-shadow: 0 0 0 9px rgba(239, 68, 68, 0); }
}

.wt-chat-note {
  padding: 0 16px 10px;
  font-size: 0.7rem;
  color: #64748b;
  text-align: center;
}

.wt-recording-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 0.8rem;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.1);
  border-top: 1px solid rgba(239, 68, 68, 0.25);
}

.wt-recording-bar.is-active { display: flex; }
.wt-recording-bar__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #ef4444; animation: wtBlink 1s infinite;
}

@keyframes wtBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.wt-recording-bar button {
  margin-left: auto;
  background: none;
  border: none;
  color: #fca5a5;
  cursor: pointer;
  font-size: 0.78rem;
  text-decoration: underline;
}

@media (max-width: 520px) {
  /* Full-screen sheet on phones — small floating panels clip messages
     and fight the on-screen keyboard */
  .wt-chat-panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }

  /* The header X closes the sheet; hide the floating launcher so it
     can't overlap the composer */
  .wt-chat-launcher.is-open { display: none; }
  .wt-chat-launcher { right: 16px; bottom: 16px; }

  .wt-msg { max-width: 92%; }
  .wt-chat-header { padding-top: max(16px, env(safe-area-inset-top)); }
  .wt-chat-composer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .wt-chat-panel, .wt-msg, .wt-chat-launcher { transition: none; animation: none; }
  .wt-typing span, .wt-icon-btn.is-recording, .wt-recording-bar__dot { animation: none; }
}
