.chat-launcher {
  position: fixed;
  z-index: 70;
  right: 22px;
  bottom: 24px;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  background: var(--teal-deep);
  color: white;
  cursor: pointer;
  box-shadow: 0 16px 34px rgba(7, 94, 98, 0.3);
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.chat-launcher:hover,
.chat-launcher:focus-visible {
  background: var(--teal);
  box-shadow: 0 20px 40px rgba(7, 94, 98, 0.36);
  outline: none;
  transform: translateY(-3px);
}

.chat-launcher svg,
.chat-icon-button svg,
.chat-send-button svg,
.admin-chat-trigger svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.chat-launcher-badge,
.admin-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  display: grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  border: 2px solid white;
  border-radius: 999px;
  padding: 0 5px;
  background: #d83b35;
  color: white;
  font-size: 11px;
  font-weight: 900;
}

.chat-modal {
  position: fixed;
  z-index: 92;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(16, 32, 30, 0.5);
  opacity: 0;
  backdrop-filter: blur(12px);
  transition: opacity 180ms ease;
}

.chat-modal.is-visible {
  opacity: 1;
}

.chat-window {
  display: grid;
  width: min(440px, calc(100vw - 32px));
  height: min(680px, calc(100vh - 80px));
  min-height: 520px;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  border: 1px solid rgba(223, 231, 226, 0.96);
  border-radius: 8px;
  background: white;
  box-shadow: 0 30px 90px rgba(16, 32, 30, 0.32);
  transform: translateY(18px) scale(0.98);
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.chat-modal.is-visible .chat-window {
  transform: translateY(0) scale(1);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 18px;
  background: #10201e;
  color: white;
}

.chat-agent {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
}

.chat-agent-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: var(--teal);
  font-weight: 900;
}

.chat-agent strong,
.chat-agent span {
  display: block;
}

.chat-agent strong {
  font-size: 15px;
}

.chat-agent span {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.chat-close {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  cursor: pointer;
  font-size: 22px;
}

.chat-service-state {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 18px;
  border-bottom: 1px solid var(--line);
  background: #f0f6f3;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chat-service-state::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  content: "";
  box-shadow: 0 0 0 4px rgba(15, 139, 141, 0.12);
}

.chat-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  background: #f8fbf9;
  scroll-behavior: smooth;
}

.chat-message {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: end;
  margin-bottom: 14px;
}

.chat-message.is-user {
  grid-template-columns: minmax(0, 1fr) 30px;
}

.chat-message-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: #dce8e3;
  color: var(--teal-deep);
  font-size: 11px;
  font-weight: 900;
}

.chat-message.is-user .chat-message-avatar {
  grid-column: 2;
  background: var(--teal-deep);
  color: white;
}

.chat-message-content {
  min-width: 0;
}

.chat-message.is-user .chat-message-content {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
}

.chat-bubble {
  width: fit-content;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: #33413c;
  box-shadow: 0 5px 14px rgba(23, 32, 29, 0.04);
}

.chat-message.is-user .chat-bubble {
  margin-left: auto;
  border-color: var(--teal-deep);
  background: var(--teal-deep);
  color: white;
}

.chat-bubble p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.55;
}

.chat-message-time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.chat-message.is-user .chat-message-time {
  text-align: right;
}

.chat-attachment {
  display: block;
  margin-top: 8px;
  color: inherit;
  font-size: 13px;
  font-weight: 900;
  overflow-wrap: anywhere;
  text-decoration: underline;
}

.chat-attachment-image {
  display: block;
  width: min(230px, 100%);
  max-height: 190px;
  margin-top: 8px;
  border-radius: 6px;
  object-fit: cover;
}

.chat-quick-replies {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: white;
  scrollbar-width: thin;
}

.chat-quick-replies button {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid rgba(7, 94, 98, 0.2);
  border-radius: 999px;
  padding: 6px 11px;
  background: #eaf7f4;
  color: var(--teal-deep);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.chat-file-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 14px 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f0f6f3;
  color: #33413c;
  font-size: 12px;
  font-weight: 800;
}

.chat-file-preview button {
  border: 0;
  background: transparent;
  color: #b54839;
  cursor: pointer;
  font-weight: 900;
}

.chat-composer-wrap {
  position: relative;
  border-top: 1px solid var(--line);
  background: white;
}

.chat-composer {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: end;
  padding: 11px 12px;
}

.chat-icon-button,
.chat-send-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  cursor: pointer;
}

.chat-icon-button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--teal-deep);
}

.chat-send-button {
  border: 1px solid var(--teal-deep);
  background: var(--teal-deep);
  color: white;
}

.chat-send-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.chat-composer textarea {
  min-height: 38px;
  max-height: 96px;
  resize: none;
  border: 0;
  padding: 8px 6px;
  box-shadow: none;
  font-size: 14px;
}

.chat-composer textarea:focus {
  box-shadow: none;
}

.chat-emoji-panel {
  position: absolute;
  right: 54px;
  bottom: 58px;
  display: grid;
  width: 230px;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 16px 42px rgba(16, 32, 30, 0.18);
}

.chat-emoji-panel button {
  width: 31px;
  height: 31px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
}

.chat-emoji-panel button:hover {
  background: #eaf7f4;
}

.chat-widget-status {
  min-height: 20px;
  margin: 0;
  padding: 0 14px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.chat-widget-status.is-error {
  color: #b54839;
}

@media (max-width: 620px) {
  .chat-launcher {
    right: 16px;
    bottom: 18px;
    width: 54px;
    height: 54px;
  }

  .chat-modal {
    align-items: flex-end;
    padding: 0;
  }

  .chat-window {
    width: 100%;
    height: min(88vh, 760px);
    min-height: 520px;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-modal,
  .chat-window,
  .chat-launcher {
    transition: none;
  }
}
