/* =====================================================
   OK-BOT — Floating AI Assistant
   Compact • Animated • Bottom-right
   ===================================================== */

#okbot-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: 'Inter', system-ui, sans-serif;
  --okbot-accent: #3b82f6;
  --okbot-bg: #0c1220;
  --okbot-panel: #111827;
  --okbot-border: rgba(148, 163, 184, 0.15);
}

/* Launcher button */
.okbot-launcher {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1e3a5f, #0f172a);
  border: 2px solid rgba(59, 130, 246, 0.45);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), 0 0 24px rgba(59, 130, 246, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  overflow: visible;
  padding: 0;
}

.okbot-launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5), 0 0 30px rgba(59, 130, 246, 0.35);
}

.okbot-launcher:active {
  transform: scale(0.97);
}

/* Character stage */
.okbot-char {
  width: 48px;
  height: 48px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Head */
.okbot-head {
  width: 36px;
  height: 36px;
  background: linear-gradient(160deg, #e0f2fe, #93c5fd);
  border-radius: 50%;
  position: relative;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.12);
  transition: transform 0.3s ease;
}

/* Hat */
.okbot-hat {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 12px;
  background: #1e40af;
  border-radius: 6px 6px 2px 2px;
  z-index: 2;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.okbot-hat::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: -4px;
  width: 36px;
  height: 5px;
  background: #1e3a8a;
  border-radius: 3px;
}

/* Eyes */
.okbot-eye {
  position: absolute;
  top: 12px;
  width: 7px;
  height: 8px;
  background: #0f172a;
  border-radius: 50%;
  transition: all 0.25s ease;
}

.okbot-eye.left { left: 8px; }
.okbot-eye.right { right: 8px; }

.okbot-eye::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 3px;
  height: 3px;
  background: white;
  border-radius: 50%;
}

/* Mouth */
.okbot-mouth {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 5px;
  border: 2px solid #0f172a;
  border-top: none;
  border-radius: 0 0 10px 10px;
  transition: all 0.25s ease;
}

/* Worm (hidden by default) */
.okbot-worm {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%) scale(0);
  font-size: 14px;
  opacity: 0;
  z-index: 3;
  transition: all 0.35s ease;
  pointer-events: none;
}

/* ===== Animations ===== */

/* Idle bounce */
.okbot-launcher.idle .okbot-char {
  animation: okbot-bounce 2.8s ease-in-out infinite;
}

@keyframes okbot-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Smile */
.okbot-launcher.smile .okbot-mouth {
  width: 14px;
  height: 7px;
  border-radius: 0 0 12px 12px;
  border-color: #1e40af;
}

.okbot-launcher.smile .okbot-eye {
  height: 5px;
  border-radius: 50% 50% 40% 40%;
}

/* Excited */
.okbot-launcher.excited .okbot-head {
  animation: okbot-shake 0.5s ease;
}

.okbot-launcher.excited .okbot-eye {
  height: 10px;
  width: 6px;
}

.okbot-launcher.excited .okbot-mouth {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #0f172a;
  border: none;
}

@keyframes okbot-shake {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

/* Hat lift + worm chase */
.okbot-launcher.worm .okbot-hat {
  transform: translateX(-50%) translateY(-14px) rotate(-18deg);
}

.okbot-launcher.worm .okbot-worm {
  opacity: 1;
  transform: translateX(-50%) scale(1);
  animation: okbot-worm-run 1.2s ease-in-out;
}

.okbot-launcher.worm .okbot-eye {
  height: 10px;
  top: 10px;
}

.okbot-launcher.worm .okbot-mouth {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0f172a;
  border: none;
}

@keyframes okbot-worm-run {
  0% { transform: translateX(-50%) scale(1); }
  30% { transform: translateX(8px) scale(1.1); }
  60% { transform: translateX(-20px) scale(1); }
  100% { transform: translateX(-50%) scale(1); }
}

/* Notification pulse when closed */
.okbot-launcher.has-pulse::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(59, 130, 246, 0.5);
  animation: okbot-pulse-ring 2s ease-out infinite;
  pointer-events: none;
}

@keyframes okbot-pulse-ring {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* Badge */
.okbot-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #0c1220;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
}

/* ===== Chat Panel ===== */
.okbot-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: min(340px, calc(100vw - 32px));
  height: min(460px, calc(100vh - 120px));
  background: var(--okbot-panel);
  border: 1px solid var(--okbot-border);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.okbot-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.okbot-panel-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, #1e3a5f, #0f172a);
  border-bottom: 1px solid var(--okbot-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.okbot-panel-header .okbot-char {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.okbot-panel-header .okbot-head {
  width: 30px;
  height: 30px;
}

.okbot-panel-header .okbot-hat {
  top: -8px;
  width: 22px;
  height: 10px;
}

.okbot-panel-header .okbot-hat::after {
  width: 28px;
  left: -3px;
  height: 4px;
}

.okbot-panel-header .okbot-eye {
  top: 10px;
  width: 5px;
  height: 6px;
}

.okbot-panel-header .okbot-eye.left { left: 6px; }
.okbot-panel-header .okbot-eye.right { right: 6px; }

.okbot-panel-header .okbot-mouth {
  bottom: 6px;
  width: 10px;
  height: 4px;
}

.okbot-panel-title {
  flex: 1;
  min-width: 0;
}

.okbot-panel-title strong {
  display: block;
  font-size: 0.95rem;
  color: #f1f5f9;
  font-weight: 600;
}

.okbot-panel-title span {
  font-size: 0.7rem;
  color: #34d399;
  display: flex;
  align-items: center;
  gap: 4px;
}

.okbot-panel-title span::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #34d399;
  border-radius: 50%;
  animation: okbot-online 1.5s ease infinite;
}

@keyframes okbot-online {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.okbot-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.okbot-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
}

/* Messages */
.okbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.okbot-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  animation: okbot-msg-in 0.3s ease;
}

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

.okbot-msg.bot {
  align-self: flex-start;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

.okbot-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  border-bottom-right-radius: 4px;
}

.okbot-msg a {
  color: #60a5fa;
  text-decoration: underline;
}

.okbot-typing {
  align-self: flex-start;
  padding: 12px 16px;
  background: rgba(59, 130, 246, 0.08);
  border-radius: 14px;
  display: flex;
  gap: 4px;
}

.okbot-typing span {
  width: 6px;
  height: 6px;
  background: #60a5fa;
  border-radius: 50%;
  animation: okbot-dot 1.2s ease infinite;
}

.okbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.okbot-typing span:nth-child(3) { animation-delay: 0.3s; }

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

/* Quick replies */
.okbot-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
}

.okbot-quick button {
  padding: 7px 12px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 100px;
  color: #93c5fd;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.okbot-quick button:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: #3b82f6;
  color: #e0f2fe;
}

/* Input */
.okbot-input-area {
  padding: 12px 14px;
  border-top: 1px solid var(--okbot-border);
  display: flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.okbot-input-area input {
  flex: 1;
  padding: 11px 14px;
  background: #0c1220;
  border: 1px solid var(--okbot-border);
  border-radius: 12px;
  color: #f1f5f9;
  font-size: 0.9rem;
  outline: none;
  min-height: 44px;
}

.okbot-input-area input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.okbot-input-area input::placeholder {
  color: #64748b;
}

.okbot-send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: all 0.2s;
}

.okbot-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

/* Mobile tweaks */
@media (max-width: 400px) {
  #okbot-root {
    bottom: 16px;
    right: 12px;
  }
  
  .okbot-launcher {
    width: 58px;
    height: 58px;
  }
  
  .okbot-panel {
    bottom: 70px;
    width: calc(100vw - 24px);
    right: -4px;
  }
}

/* Hide default back-top if overlapping - optional */
@media (max-width: 480px) {
  .back-top {
    bottom: 90px !important;
    right: 16px !important;
  }
}
