@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+Georgian:wght@400;500;700&display=swap");

/* ფერების პალიტრა - აქ შეცვლი და ყველგან განახლდება */
#chat-widget {
  --rose-300: #f3b6c8;
  --rose-500: #d9668d;
  --rose-700: #ad4270;
  --ink: #3d1e2b;
  --muted: #94707e;
  --bot: #fdeff3;
  --line: #f6d9e2;
  --paper: #fffafb;
  --grad: linear-gradient(135deg, var(--rose-500), var(--rose-700));
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: "Noto Sans Georgian", system-ui, sans-serif;
}

/* ============ გახსნის ანიმაცია ============
   ფანჯარა იხსნება გახსნის ღილაკიდან გაშლილი წრის სახით,
   შემდეგ შიგთავსი თანმიმდევრულად ჩნდება */
#chat-box {
  position: absolute;
  bottom: 84px;
  right: 0;
  width: 370px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--paper);
  border-radius: 28px;
  box-shadow:
    0 30px 70px -12px rgba(173, 66, 112, 0.35),
    0 8px 24px rgba(61, 30, 43, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform-origin: calc(100% - 32px) calc(100% + 52px);
  transform: translateY(10px) scale(0.85);
  clip-path: circle(26px at calc(100% - 32px) calc(100% + 52px));
  transition:
    transform 0.55s var(--ease-out),
    clip-path 0.6s var(--ease-out),
    opacity 0.25s ease;
}

#chat-box.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  clip-path: circle(200% at calc(100% - 32px) calc(100% + 52px));
}

/* შიგთავსის თანმიმდევრული გამოჩენა */
#chat-box.open #chat-header {
  animation: revealDown 0.55s 0.12s var(--ease-out) both;
}
#chat-box.open #chat-header-avatar-placeholder {
  animation: avatarPop 0.6s 0.28s var(--spring) both;
}
#chat-box.open #chat-messages {
  animation: revealUp 0.55s 0.2s var(--ease-out) both;
}
#chat-box.open #chat-input-area {
  animation: revealUp 0.55s 0.32s var(--ease-out) both;
}

@keyframes revealDown {
  from {
    opacity: 0;
    transform: translateY(-14px);
  }
}
@keyframes revealUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}
@keyframes avatarPop {
  from {
    opacity: 0;
    transform: scale(0.4) rotate(-20deg);
  }
}

/* ღილაკი ოდნავ "იჭერება" ჩათის გახსნისას */
#chat-widget:has(#chat-box.open) #chat-trigger {
  transform: scale(0.92);
}

/* ============ ჰედერი ============ */
#chat-header {
  position: relative;
  overflow: hidden;
  color: #ffffff;
  padding: 20px 18px 36px;
  display: flex;
  align-items: center;
  gap: 13px;
  background:
    radial-gradient(
      120% 150% at 0% 0%,
      rgba(255, 255, 255, 0.3),
      transparent 55%
    ),
    var(--grad);
}

/* რბილი, მინისებური ბზინვა */
#chat-header::before {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  right: -40px;
  top: -70px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.13);
  pointer-events: none;
}

#chat-header > * {
  position: relative;
  z-index: 1;
}

#chat-header-info h4 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.1px;
}

#chat-header-info span {
  font-size: 12px;
  opacity: 0.92;
}

#chat-close {
  background: rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  cursor: pointer;
  margin-left: auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    transform 0.35s var(--ease-out);
}

#chat-close:hover {
  background: rgba(255, 255, 255, 0.32);
  transform: rotate(90deg);
}

#chat-close svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ============ შეტყობინებები ============ */
#chat-messages {
  position: relative;
  flex: 1;
  margin-top: -20px;
  padding: 20px 16px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--paper);
  border-radius: 24px 24px 0 0;
  scrollbar-width: thin;
  scrollbar-color: var(--rose-300) transparent;
}

.msg {
  max-width: 82%;
  padding: 10px 15px;
  border-radius: 20px;
  font-size: 14px;
  line-height: 1.5;
  animation: msgIn 0.4s var(--ease-out);
}

@keyframes msgIn {
  from {
    transform: translateY(10px) scale(0.96);
    opacity: 0;
  }
}

.msg.bot {
  background: var(--bot);
  color: var(--ink);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  transform-origin: left bottom;
}

.msg.user {
  background: var(--grad);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  transform-origin: right bottom;
  box-shadow: 0 6px 14px -6px rgba(173, 66, 112, 0.55);
}

/* ============ Typing ანიმაცია ============
   სამი წერტილი რბილი ტალღით + ბუშტზე გამავალი ნაზი ბრწყინვა */
.msg.typing {
  position: relative;
  overflow: hidden;
  background: var(--bot);
  padding: 13px 17px;
  display: flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
  align-self: flex-start;
  border: none;
  border-radius: 20px 20px 20px 6px;
  box-shadow: none;
  transform-origin: left bottom;
  animation: typingIn 0.45s var(--spring);
}

@keyframes typingIn {
  from {
    transform: translateY(8px) scale(0.6);
    opacity: 0;
  }
}

.msg.typing::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 30%,
    rgba(255, 255, 255, 0.75) 50%,
    transparent 70%
  );
  transform: translateX(-100%);
  animation: typingSheen 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes typingSheen {
  60%,
  100% {
    transform: translateX(100%);
  }
}

.typing-dots-container {
  display: flex;
  align-items: center;
  gap: 5px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--rose-500);
  border-radius: 50%;
  animation: typingWave 1.3s ease-in-out infinite;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}
.typing-dot:nth-child(2) {
  animation-delay: 0.16s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes typingWave {
  0%,
  60%,
  100% {
    transform: translateY(0) scale(0.85);
    opacity: 0.35;
  }
  30% {
    transform: translateY(-5px) scale(1.1);
    opacity: 1;
  }
}

.typing-timer {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  border-left: 1px solid var(--line);
  padding-left: 10px;
  letter-spacing: 0.3px;
}

/* ============ ინფუთი ============ */
#chat-input-area {
  padding: 12px 14px 14px;
  background: var(--paper);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
}

#chat-input {
  flex: 1;
  min-width: 0;
  padding: 12px 18px;
  border: 1.5px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  border-radius: 26px;
  outline: none;
  font: inherit;
  font-size: 14px;
  transition:
    border-color 0.2s,
    box-shadow 0.25s;
}

#chat-input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

#chat-input:focus {
  border-color: var(--rose-500);
  box-shadow: 0 0 0 4px rgba(217, 102, 141, 0.14);
}

#chat-send {
  background: var(--grad);
  border: none;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 8px 16px -6px rgba(173, 66, 112, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition:
    transform 0.3s var(--spring),
    box-shadow 0.2s;
}

#chat-send:hover {
  transform: scale(1.08) rotate(-8deg);
}

#chat-send:active {
  transform: scale(0.94);
}

#chat-send svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============ გასახსნელი ღილაკი ============ */
#chat-trigger-wrap {
  position: relative;
  display: inline-block;
}

#chat-trigger {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background:
    radial-gradient(
      90% 90% at 30% 20%,
      rgba(255, 255, 255, 0.28),
      transparent 60%
    ),
    var(--grad);
  border: none;
  cursor: pointer;
  box-shadow:
    0 14px 30px -8px rgba(173, 66, 112, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition:
    transform 0.35s var(--spring),
    box-shadow 0.25s;
}

#chat-trigger:hover {
  transform: translateY(-3px);
  box-shadow:
    0 20px 34px -8px rgba(173, 66, 112, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

#chat-trigger #unread-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  z-index: 1;
  background: #ffffff;
  color: var(--rose-700);
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 500px;
  border: 2px solid var(--rose-500);
  box-shadow: 0 3px 8px rgba(173, 66, 112, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

#unread-badge.hidden {
  display: none;
}

/* ============ სახე (თვალები და ღიმილი) ============ */
.cute-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.trigger-face .eyes,
#chat-header-avatar-placeholder .eyes {
  display: flex;
  gap: 6px;
  margin-bottom: 3px;
}

.trigger-face .eye,
#chat-header-avatar-placeholder .eye {
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  display: inline-block;
  transform-origin: center;
  animation: blink 2.6s ease-in-out infinite;
}

@keyframes blink {
  0%,
  80%,
  100% {
    transform: scaleY(1);
  }
  85% {
    transform: scaleY(0.1);
  }
  90% {
    transform: scaleY(1);
  }
  93% {
    transform: scaleY(0.1);
  }
  96% {
    transform: scaleY(1);
  }
}

.trigger-face .smile,
#chat-header-avatar-placeholder .smile {
  width: 12px;
  height: 6px;
  border-bottom: 2px solid #fff;
  border-radius: 0 0 8px 8px;
}

/* ჰედერის ავატარი + "ონლაინ" წერტილი */
#chat-header-avatar-placeholder {
  position: relative;
  width: 46px;
  height: 46px;
  flex: none;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#chat-header-avatar-placeholder::after {
  content: "";
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4cd39b;
  border: 2px solid #fff;
}

@media (prefers-reduced-motion: reduce) {
  #chat-widget *,
  #chat-widget *::after {
    animation: none !important;
    transition: none !important;
  }
  #chat-box.open {
    clip-path: none;
  }
}
