/* ═══════════════════════════════════════════════════════════════
   LOKGENIX CHAT WIDGET — WARM PAPER THEME
═══════════════════════════════════════════════════════════════ */

/* ── LAUNCHER BUTTON ── */
.chat-launcher {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 60px; height: 60px;
  background: var(--coral);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 90;
  box-shadow: 0 10px 30px rgba(255, 90, 60, 0.4), 0 2px 8px rgba(80,50,30,0.1);
  transition: all var(--t-med) var(--ease);
}
.chat-launcher::before {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px solid var(--coral);
  border-radius: 50%;
  opacity: 0.5;
  animation: launcher-pulse 2.2s var(--ease) infinite;
}
@keyframes launcher-pulse {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.4); opacity: 0; }
}
.chat-launcher:hover { transform: translateY(-3px) rotate(-8deg); box-shadow: 0 14px 40px rgba(255, 90, 60, 0.55); }
.chat-launcher svg { width: 26px; height: 26px; }
.chat-launcher-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--paper);
}
.chat-launcher.hidden { transform: scale(0); opacity: 0; pointer-events: none; }

/* ── PANEL ── */
.chat-panel {
  position: fixed;
  bottom: 24px; right: 24px;
  width: min(420px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 48px));
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(80,50,30,0.25), 0 4px 14px rgba(80,50,30,0.1);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 91;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  transition: all var(--t-med) var(--ease);
  pointer-events: none;
}
.chat-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* ── HEADER ── */
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  background: var(--ink);
  color: var(--paper);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.chat-header-info { display: flex; align-items: center; gap: 12px; }
.chat-header-avatar {
  width: 40px; height: 40px;
  border-radius: 12px;
  object-fit: cover;
  position: relative;
  flex-shrink: 0;
}
.chat-header-avatar::after {
  content: '';
  position: absolute;
  right: -2px; bottom: -2px;
  width: 12px; height: 12px;
  background: #8ce88c;
  border: 2px solid var(--ink);
  border-radius: 50%;
}
.chat-header-name { font-family: var(--f-display); font-weight: 500; font-size: 1.05rem; letter-spacing: -0.01em; }
.chat-header-status { font-family: var(--f-mono); font-size: 0.7rem; color: rgba(247,243,236,0.55); text-transform: uppercase; letter-spacing: 0.1em; }
.chat-header-actions { display: flex; gap: 4px; }
.chat-header-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: rgba(247,243,236,0.7);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast);
}
.chat-header-btn:hover { background: rgba(255,255,255,0.12); color: var(--paper); }
.chat-header-btn svg { width: 16px; height: 16px; }

/* ── INTRO ── */
.chat-intro {
  padding: 14px 18px;
  background: var(--coral-soft);
  border-bottom: 1px solid var(--border);
}
.chat-intro p {
  font-size: 0.83rem;
  color: var(--ink-2);
  line-height: 1.5;
}
.chat-intro strong { color: var(--coral-2); font-weight: 600; }

/* ── MESSAGES ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
  background: var(--paper);
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }

.msg {
  display: flex; gap: 10px;
  align-items: flex-start;
  animation: msg-in 0.4s var(--ease);
}
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
.msg.user { flex-direction: row-reverse; }
.msg-icon {
  width: 30px; height: 30px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}
.msg-icon-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--coral);
  color: #fff;
  font-family: var(--f-body);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.msg.user .msg-icon { background: var(--ink); color: var(--paper); }
.msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink);
  word-wrap: break-word;
}
.msg.user .msg-bubble {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  border-radius: 14px 14px 4px 14px;
}
.msg-time {
  font-family: var(--f-mono);
  font-size: 0.66rem;
  color: var(--ink-4);
  align-self: flex-end;
  margin: 0 4px;
}

.msg-typing {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 14px 16px;
}
.msg-typing span {
  width: 6px; height: 6px;
  background: var(--ink-3);
  border-radius: 50%;
  animation: typing 1.2s var(--ease) infinite;
}
.msg-typing span:nth-child(2) { animation-delay: 0.15s; }
.msg-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ── QUICK REPLIES ── */
.chat-quick-replies {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--paper);
  border-top: 1px solid var(--border);
}
.chat-quick-replies button {
  font-family: var(--f-mono);
  font-size: 0.74rem;
  padding: 6px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--ink-2);
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.chat-quick-replies button:hover { background: var(--coral); color: #fff; border-color: var(--coral); }

/* ── INPUT ── */
.chat-input-wrap {
  padding: 12px 16px 14px;
  background: var(--card);
  border-top: 1px solid var(--border);
}
.chat-input-row {
  display: flex; align-items: flex-end; gap: 8px;
}
.chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 0.9rem;
  resize: none;
  transition: border-color var(--t-fast);
}
.chat-input:focus { outline: none; border-color: var(--coral); }
.chat-send-btn {
  width: 40px; height: 40px;
  background: var(--coral);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--t-fast);
}
.chat-send-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-coral); }
.chat-send-btn:disabled { background: var(--ink-4); cursor: not-allowed; }
.chat-send-btn svg { width: 16px; height: 16px; }
.chat-footer {
  font-family: var(--f-mono);
  font-size: 0.66rem;
  color: var(--ink-4);
  text-align: center;
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

@media (max-width: 500px) {
  .chat-launcher { bottom: 16px; right: 16px; width: 54px; height: 54px; }
  .chat-launcher { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .chat-panel {
    bottom: 0; right: 0; left: 0;
    width: 100%;
    height: 80vh;
    height: 80dvh;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    border-radius: 24px 24px 0 0;
    transform-origin: bottom center;
  }
  .chat-header {
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    min-height: 56px;
  }
  .chat-header-btn {
    width: 36px; height: 36px;
    min-width: 36px; min-height: 36px;
  }
  .chat-input-wrap {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
}
