.chat-widget {
  position: fixed;
  right: 22px;
  bottom: 25px;
  z-index: 99999;
  font-family: "Manrope", "Helvetica Neue", sans-serif;
  --chat-primary: var(--primary-color, #f7a600);
  --chat-ink: #1b1a17;
  --chat-muted: #6e6a63;
  --chat-bg: #fbfaf7;
  --chat-surface: #ffffff;
  --chat-border: rgba(231, 225, 216, 0.9);
  --chat-radius: 18px;
  --chat-shadow: 0 26px 60px rgba(18, 16, 10, 0.18);
  --chat-bubble: #f0ede7;
  --chat-bubble-user: #fff3d6;
  --chat-bubble-agent: #e9f1ff;
  --chat-focus: 0 0 0 3px rgba(18, 16, 10, 0.18);
}

.chat-widget * {
  box-sizing: border-box;
}

.chat-widget .chat-bubble {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: none;
  background: var(--chat-primary);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(20, 20, 20, 0.18);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.chat-widget .chat-bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(20, 20, 20, 0.22);
}

.chat-widget .chat-bubble svg {
  width: 25px;
  height: 25px;
  fill: #fff;
}

@media (max-width: 768px) {
  .chat-widget .chat-bubble {
    width: 40px;
    height: 40px;
  }
  .chat-widget .chat-bubble svg {
    width: 22px;
    height: 22px;
  }
}

.chat-widget .chat-window {
  position: fixed;
  right: 22px;
  bottom: 80px;
  width: 420px;
  max-height: 640px;
  background: var(--chat-surface);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  border: 1px solid var(--chat-border);
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  pointer-events: none;
}
.chat-widget .chat-window.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.chat-widget .chat-header {
  padding: 16px 18px;
  background: linear-gradient(135deg, #fff3db 0%, #fff 60%);
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-widget .chat-quick {
  padding: 14px 18px 6px;
  background: var(--chat-surface);
  border-bottom: 1px solid var(--chat-border);
}

.chat-widget .chat-quick-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--chat-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.chat-widget .chat-quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-widget .chat-quick-btn {
  border: 1px solid var(--chat-border);
  background: #fff;
  color: var(--chat-ink);
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.chat-widget .chat-quick-btn:hover {
  border-color: rgba(20, 20, 20, 0.22);
  transform: translateY(-1px);
}

.chat-widget .chat-quick-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--chat-muted);
}

.chat-widget .chat-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--chat-ink);
}

.chat-widget .chat-subtitle {
  font-size: 12.5px;
  color: var(--chat-muted);
}

.chat-widget .chat-close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--chat-muted);
}

.chat-widget .chat-messages {
  padding: 18px;
  overflow-y: auto;
  background: var(--chat-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 342px;
  scrollbar-gutter: stable;
}
.chat-widget .chat-typing {
  padding: 18px;
}

.chat-widget .chat-rating {
  padding: 14px 18px 6px;
  background: var(--chat-surface);
  border-top: 1px dashed var(--chat-border);
}

.chat-widget .chat-rating-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--chat-ink);
}

.chat-widget .chat-rating-subtitle {
  margin-top: 2px;
  font-size: 12px;
  color: var(--chat-muted);
}

.chat-widget .chat-rating-stars {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.chat-widget .chat-rating-star {
  border: 1px solid var(--chat-border);
  background: #fff;
  color: #d3c6b5;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.chat-widget .chat-rating-star.active {
  color: #ffb020;
  border-color: rgba(255, 176, 32, 0.5);
}

.chat-widget .chat-rating-star:hover {
  transform: translateY(-1px);
}

.chat-widget .chat-rating-text {
  width: 100%;
  margin-top: 10px;
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
}

.chat-widget .chat-rating-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.chat-widget .chat-rating-submit {
  border: none;
  background: var(--chat-primary);
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

.chat-widget .chat-rating-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-widget .chat-rating-thanks {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--chat-muted);
}

.chat-widget .chat-msg {
  display: flex;
}

.chat-widget .chat-msg.user {
  justify-content: flex-end;
}

.chat-widget .chat-msg.bot,
.chat-widget .chat-msg.agent {
  justify-content: flex-start;
}

.chat-widget .bubble {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  background: var(--chat-bubble);
  color: var(--chat-ink);
  box-shadow: 0 8px 18px rgba(18, 16, 10, 0.06);
  position: relative;
}

.chat-widget .bubble.user {
  background: var(--chat-bubble-user);
}

.chat-widget .bubble.agent {
  background: var(--chat-bubble-agent);
  color: #1f6feb;
}

.chat-widget .bubble-label {
  display: block;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--chat-muted);
  margin: 0 0 6px;
}
.chat-widget .bubble.bubble-media .bubble-label {
  display: block;
  margin: 0 0 6px;
}
.chat-widget .chat-msg.user .bubble-label {
  display: none;
}
.chat-widget .bubble-text {
  display: block;
}

.chat-widget .chat-input {
  display: flex;
  border-top: 1px solid var(--chat-border);
  padding: 10px 12px;
  gap: 8px;
  align-items: center;
  background: var(--chat-surface);
}

.chat-widget .icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--chat-border);
  background: #fff;
  color: var(--chat-muted);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}
.chat-widget .icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 16px rgba(18, 16, 10, 0.12);
}
.chat-widget .icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.chat-widget .chat-input input {
  flex: 1;
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
  height: 42px;
}

.chat-widget .chat-input input:focus {
  outline: none;
}

.chat-widget .chat-input button {
  border: none;
  background: var(--chat-primary);
  color: #fff;
  padding: 0 12px;
  font-weight: 600;
  cursor: pointer;
}

.chat-widget .chat-bubble:focus-visible,
.chat-widget .chat-quick-btn:focus-visible,
.chat-widget .chat-close:focus-visible,
.chat-widget .chat-rating-star:focus-visible,
.chat-widget .chat-rating-submit:focus-visible,
.chat-widget .icon-btn:focus-visible,
.chat-widget .send-btn:focus-visible {
  outline: none;
  box-shadow: var(--chat-focus);
}
.chat-widget .send-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  border-radius: 10px;
}
.chat-widget .send-btn svg {
  width: 16px;
  height: 16px;
  stroke: #fff;
}

.chat-widget .typing-bubble {
  display: inline-flex;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.08);
  margin-left: 6px;
}

.chat-widget .typing-bubble span {
  width: 6px;
  height: 6px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  animation: typingBlink 1.4s infinite both;
}

.chat-widget .typing-bubble span:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-widget .typing-bubble span:nth-child(3) {
  animation-delay: 0.4s;
}

.chat-widget .chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chat-widget .chat-attachments img {
  width: 150px;
  max-width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--chat-border);
  box-shadow: 0 8px 18px rgba(18, 16, 10, 0.08);
  cursor: pointer;
}
.chat-widget-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  padding: 20px;
}
.chat-widget-lightbox.show {
  display: flex;
}
.chat-widget-lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

@keyframes typingBlink {
  0% {
    opacity: 0.2;
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0.2;
  }
}

@media (max-width: 640px) {
  .chat-widget .chat-window {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 75px;
    max-height: calc(100vh - 140px);
  }
  .chat-widget .chat-bubble {
    right: 12px;
  }
  .chat-widget .chat-typing,
  .chat-widget .chat-messages {
    padding: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-widget *,
  .chat-widget *::before,
  .chat-widget *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
