/*
  widget.css
  ----------
  Styling for TJ-Bot's floating chat widget.
  Brand colors sourced from TJ-Consult's tailwind config:
    orange primary  #F97316
    orange light    #FB923C
    orange dark     #EA580C
    dark bg         #111827
    dark secondary  #1F2937
    gray mid        #6B7280
    gray light      #F9FAFB
    gray border     #E5E7EB
*/

#tjbot-widget-root {
  --tjbot-orange: #F97316;
  --tjbot-orange-light: #FB923C;
  --tjbot-orange-dark: #EA580C;
  --tjbot-dark: #111827;
  --tjbot-dark-secondary: #1F2937;
  --tjbot-gray-mid: #6B7280;
  --tjbot-gray-light: #F9FAFB;
  --tjbot-gray-border: #E5E7EB;

  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

#tjbot-widget-root * {
  box-sizing: border-box;
}

/* ------------------------------------------------------------------ */
/* Floating launcher icon (robot)                                     */
/* ------------------------------------------------------------------ */

.tjbot-launcher {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--tjbot-orange-light), var(--tjbot-orange-dark));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.45), 0 0 0 0 rgba(249, 115, 22, 0.5);
  animation: tjbot-breathe 3.2s ease-in-out infinite, tjbot-glow 3.2s ease-in-out infinite;
  transition: transform 0.15s ease;
  padding: 0;
}

.tjbot-launcher:hover {
  transform: scale(1.06);
}

.tjbot-launcher:active {
  transform: scale(0.96);
}

@keyframes tjbot-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

@keyframes tjbot-glow {
  0%, 100% { box-shadow: 0 4px 14px rgba(249, 115, 22, 0.45), 0 0 0 0 rgba(249, 115, 22, 0.35); }
  50% { box-shadow: 0 4px 22px rgba(249, 115, 22, 0.65), 0 0 0 10px rgba(249, 115, 22, 0.12); }
}

.tjbot-robot-svg {
  width: 34px;
  height: 34px;
  display: block;
}

.tjbot-robot-svg .tjbot-eye {
  animation: tjbot-blink 4.5s ease-in-out infinite;
  transform-origin: center;
}

@keyframes tjbot-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.15); }
}

.tjbot-unread-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
  display: none;
}

.tjbot-unread-dot.tjbot-visible {
  display: block;
}

/* ------------------------------------------------------------------ */
/* Speech bubble teaser                                               */
/* ------------------------------------------------------------------ */

.tjbot-teaser {
  position: absolute;
  bottom: 80px;
  right: 0;
  max-width: 280px;
  background: #ffffff;
  color: var(--tjbot-dark);
  padding: 18px 24px;
  border-radius: 28px;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.tjbot-teaser::after {
  content: "";
  position: absolute;
  bottom: -6px;
  right: 22px;
  width: 14px;
  height: 14px;
  background: #ffffff;
  transform: rotate(45deg);
  box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.05);
}

.tjbot-teaser.tjbot-teaser-visible {
  opacity: 1;
  transform: translateY(0) scale(1) rotate(0deg);
  pointer-events: auto;
  animation: tjbot-teaser-bounce 0.75s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tjbot-teaser-bounce {
  0% { opacity: 0; transform: translateY(26px) scale(0.4) rotate(-6deg); }
  45% { opacity: 1; transform: translateY(-10px) scale(1.08) rotate(2deg); }
  70% { transform: translateY(3px) scale(0.98) rotate(-1deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
}

.tjbot-launcher.tjbot-launcher-attention {
  animation: tjbot-launcher-attention 0.9s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tjbot-launcher-attention {
  0% { transform: scale(1) rotate(0deg); }
  20% { transform: scale(1.22) rotate(-10deg); }
  40% { transform: scale(0.94) rotate(8deg); }
  60% { transform: scale(1.12) rotate(-5deg); }
  80% { transform: scale(0.98) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.tjbot-teaser-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: var(--tjbot-gray-mid);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

/* ------------------------------------------------------------------ */
/* Chat drawer                                                        */
/* ------------------------------------------------------------------ */

.tjbot-drawer {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 408px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform-origin: bottom right;
  transform: translateY(28px) scale(0.82);
  transition: opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1), transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.tjbot-drawer.tjbot-drawer-open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.tjbot-drawer-header {
  background: var(--tjbot-dark);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.tjbot-drawer-header .tjbot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--tjbot-orange-light), var(--tjbot-orange-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tjbot-drawer-header .tjbot-avatar svg {
  width: 20px;
  height: 20px;
}

.tjbot-drawer-title {
  flex: 1;
  min-width: 0;
}

.tjbot-drawer-title strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.tjbot-drawer-title span {
  display: block;
  font-size: 12px;
  color: #a3b0c2;
}

.tjbot-drawer-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  opacity: 0.8;
  line-height: 1;
}

.tjbot-drawer-close:hover {
  opacity: 1;
}

.tjbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--tjbot-gray-light);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tjbot-msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.tjbot-msg-bot {
  align-self: flex-start;
  background: #ffffff;
  color: var(--tjbot-dark);
  border: 1px solid var(--tjbot-gray-border);
  border-bottom-left-radius: 4px;
}

.tjbot-msg-user {
  align-self: flex-end;
  background: var(--tjbot-orange);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.tjbot-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid var(--tjbot-gray-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.tjbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tjbot-gray-mid);
  animation: tjbot-typing-bounce 1.2s infinite ease-in-out;
}

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

@keyframes tjbot-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.tjbot-input-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: #ffffff;
  border-top: 1px solid var(--tjbot-gray-border);
}

.tjbot-input-bar input {
  flex: 1;
  border: 1px solid var(--tjbot-gray-border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  min-width: 0;
}

.tjbot-input-bar input:focus {
  border-color: var(--tjbot-orange);
}

.tjbot-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--tjbot-orange);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.tjbot-send-btn:hover {
  background: var(--tjbot-orange-dark);
}

.tjbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tjbot-conn-banner {
  font-size: 12px;
  text-align: center;
  padding: 6px;
  background: #fef3c7;
  color: #92400e;
  display: none;
}

.tjbot-conn-banner.tjbot-visible {
  display: block;
}

@media (max-width: 480px) {
  #tjbot-widget-root {
    bottom: 16px;
    right: 16px;
  }

  .tjbot-drawer {
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
    bottom: 76px;
    right: -8px;
  }
}
