/* TOKO Chat Widget — Agente Gecko */
:root {
  --toko-green: #1CBA61;
  --toko-dark: #111111;
  --toko-white: #ffffff;
  --toko-gray: #f4f5f7;
  --toko-border: #e5e7eb;
  --toko-text: #374151;
  --toko-muted: #9ca3af;
  --toko-shadow: 0 24px 64px rgba(0,0,0,0.18);
  --toko-radius: 18px;
}

/* ─── Bubble ─────────────────────────────────────────────── */
#toko-chat-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 62px;
  height: 62px;
  background: var(--toko-green);
  border-radius: 50%;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(28,186,97,0.45);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.3s;
  border: none;
  outline: none;
  padding: 0;
}
#toko-chat-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 10px 32px rgba(28,186,97,0.55);
}
#toko-chat-bubble.is-open { transform: scale(0.92); }

.toko-bubble-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(28,186,97,0.35);
  animation: tkPulse 2.2s infinite;
  pointer-events: none;
}
@keyframes tkPulse {
  0%   { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.9); opacity: 0; }
}

.toko-bubble-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 13px;
  height: 13px;
  background: #ef4444;
  border-radius: 50%;
  border: 2.5px solid #1CBA61;
  animation: tkDot 1.6s infinite;
}
.toko-bubble-dot.hidden { display: none; }
@keyframes tkDot {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.25); }
}

.toko-bubble-icon,
.toko-bubble-close {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.22s, transform 0.22s;
}
.toko-bubble-close {
  opacity: 0;
  transform: rotate(-90deg);
}
#toko-chat-bubble.is-open .toko-bubble-icon  { opacity: 0; transform: rotate(90deg); }
#toko-chat-bubble.is-open .toko-bubble-close { opacity: 1; transform: rotate(0deg); }

/* ─── Panel ──────────────────────────────────────────────── */
#toko-chat-panel {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: 380px;
  height: 570px;
  background: var(--toko-white);
  border-radius: var(--toko-radius);
  box-shadow: var(--toko-shadow);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.88) translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.38s cubic-bezier(0.34,1.56,0.64,1), opacity 0.26s ease;
  transform-origin: bottom right;
}
#toko-chat-panel.is-visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ─── Header ─────────────────────────────────────────────── */
.toko-chat-header {
  background: var(--toko-dark);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.toko-chat-avatar {
  width: 44px;
  height: 44px;
  background: var(--toko-green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}
.toko-chat-avatar::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 11px;
  height: 11px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid var(--toko-dark);
}
.toko-chat-header-info { flex: 1; min-width: 0; }
.toko-chat-header-name {
  color: #fff;
  font-size: 0.93rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}
.toko-chat-header-status {
  color: #4ade80;
  font-size: 0.72rem;
  margin: 3px 0 0;
  letter-spacing: 0.02em;
}
.toko-chat-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  padding: 5px;
  border-radius: 7px;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  line-height: 0;
}
.toko-chat-close-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.12);
}

/* Context banner */
.toko-context-banner {
  background: linear-gradient(135deg, #0f7a3d 0%, #1CBA61 100%);
  color: white;
  padding: 10px 18px;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.toko-context-banner.hidden { display: none; }

/* ─── Messages ───────────────────────────────────────────── */
.toko-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.toko-chat-messages::-webkit-scrollbar { width: 4px; }
.toko-chat-messages::-webkit-scrollbar-track { background: transparent; }
.toko-chat-messages::-webkit-scrollbar-thumb { background: var(--toko-border); border-radius: 2px; }

.toko-message {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: tkMsgIn 0.3s ease;
}
@keyframes tkMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.toko-message.user { flex-direction: row-reverse; }

.toko-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--toko-green);
}
.toko-message.user .toko-msg-avatar { background: var(--toko-dark); }

.toko-msg-bubble {
  max-width: 74%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--toko-text);
  word-break: break-word;
}
.toko-message.bot  .toko-msg-bubble { background: var(--toko-gray); border-bottom-left-radius: 5px; }
.toko-message.user .toko-msg-bubble { background: var(--toko-green); color: #fff; border-bottom-right-radius: 5px; }

.toko-msg-bubble a { color: var(--toko-green); font-weight: 600; }
.toko-message.user .toko-msg-bubble a { color: #d1fae5; }

/* Typing indicator */
.toko-typing-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: tkMsgIn 0.3s ease;
}
.toko-typing-dots {
  background: var(--toko-gray);
  padding: 13px 16px;
  border-radius: 18px;
  border-bottom-left-radius: 5px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.toko-typing-dot {
  width: 7px;
  height: 7px;
  background: var(--toko-muted);
  border-radius: 50%;
  animation: tkTyping 1.3s infinite;
}
.toko-typing-dot:nth-child(2) { animation-delay: 0.22s; }
.toko-typing-dot:nth-child(3) { animation-delay: 0.44s; }
@keyframes tkTyping {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30%          { transform: translateY(-6px); opacity: 1; }
}

/* ─── Input ──────────────────────────────────────────────── */
.toko-chat-input-area {
  padding: 12px 14px;
  border-top: 1px solid var(--toko-border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
.toko-chat-input {
  flex: 1;
  border: 1.5px solid var(--toko-border);
  border-radius: 22px;
  padding: 10px 15px;
  font-size: 0.875rem;
  outline: none;
  resize: none;
  font-family: inherit;
  color: var(--toko-text);
  background: var(--toko-gray);
  transition: border-color 0.2s, background 0.2s;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
}
.toko-chat-input:focus {
  border-color: var(--toko-green);
  background: #fff;
}
.toko-chat-input::placeholder { color: var(--toko-muted); }
.toko-chat-send {
  width: 42px;
  height: 42px;
  min-width: 42px;
  background: var(--toko-green);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  line-height: 0;
}
.toko-chat-send:hover { transform: scale(1.1); box-shadow: 0 4px 14px rgba(28,186,97,0.4); }
.toko-chat-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* Footer */
.toko-chat-footer {
  text-align: center;
  padding: 6px;
  font-size: 0.68rem;
  color: var(--toko-muted);
  background: #fff;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.toko-chat-footer strong { color: var(--toko-green); }

/* ─── Mobile ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  #toko-chat-panel {
    bottom: 0; right: 0; left: 0;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    transform: translateY(100%);
    transition: transform 0.38s cubic-bezier(0.34,1.56,0.64,1), opacity 0.26s;
  }
  #toko-chat-panel.is-visible { transform: translateY(0); opacity: 1; }
  #toko-chat-bubble { bottom: 20px; right: 20px; }
}
