:root {
  --chat-blue: #0f6fff;
  --chat-blue-dark: #174f8a;
  --chat-bg: #ffffff;
  --chat-text: #1f2937;
  --chat-muted: #6b7a90;
  --chat-border: #d9e4f2;
  --chat-border-strong: #1f63b5;
  --chat-soft: #f4f8fd;
  --chat-radius-lg: 18px;
  --chat-shadow: 0 18px 45px rgba(15, 43, 79, 0.18);
}

.chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  display: none;
  place-items: center;
  z-index: 1040;
  padding: 0;
  transition: transform 0.18s ease;
}

.chat-launcher.is-visible {
  display: grid;
}

.chat-launcher:hover {
  transform: translateY(-2px);
}

.chat-launcher__bubble {
  width: 48px;
  height: 48px;
  background: url("/static/img/chat-bubble.svg") center / contain no-repeat;
  filter: drop-shadow(0 10px 18px rgba(0, 102, 246, 0.24));
  transform: scaleX(-1);
}

.chat-launcher .support-widget-badge {
  top: -0.25rem;
  right: -6.75rem;
}

.chat-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: min(380px, calc(100vw - 28px));
  max-height: min(620px, calc(100vh - 120px));
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: var(--chat-radius-lg);
  box-shadow: var(--chat-shadow);
  overflow: hidden;
  z-index: 1039;
  display: flex;
  flex-direction: column;
  color: var(--chat-text);
}

.chat-widget.d-none {
  display: none !important;
}

.chat-header {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}

.chat-close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--chat-border);
  border-radius: 9px;
  background: #fff;
  color: #6d7684;
  cursor: pointer;
  position: relative;
}

.chat-close:hover {
  background: #eef4fb;
}

.chat-close::before,
.chat-close::after {
  content: "";
  position: absolute;
  top: 13px;
  left: 7px;
  width: 14px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}

.chat-close::before {
  transform: rotate(45deg);
}

.chat-close::after {
  transform: rotate(-45deg);
}

.chat-body {
  min-height: 0;
  padding: 10px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

.chat-card {
  background: #fff;
  border: 1px solid rgba(217, 228, 242, 0.9);
  border-radius: 14px;
  box-shadow: 0 10px 26px rgba(22, 47, 84, 0.06);
  padding: 10px;
}

.chat-section-title {
  margin: 0 34px 7px 0;
  font-size: 13px;
  font-weight: 750;
}

.chat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.chat-pill {
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--chat-blue);
  border-radius: 999px;
  background: #fff;
  color: var(--chat-blue);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  line-height: 1;
}

.chat-pill.is-active {
  background: var(--chat-blue);
  color: #fff;
}

.chat-list-footer {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--chat-border);
}

.all-requests-link {
  width: 100%;
  min-height: 29px;
  border: 1px solid var(--chat-border);
  border-radius: 11px;
  background: var(--chat-soft);
  color: var(--chat-blue-dark);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.all-requests-link:hover {
  border-color: var(--chat-blue);
  background: #f8fbff;
}

.requests-dropdown {
  position: relative;
}

.requests-toggle {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--chat-border-strong);
  border-radius: 12px;
  background: #fbfdff;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.requests-toggle::after {
  content: "⌄";
  color: var(--chat-blue-dark);
  font-size: 15px;
  line-height: 1;
  transition: transform 0.16s ease;
}

.requests-dropdown.is-open .requests-toggle::after {
  transform: rotate(180deg);
}

.requests-toggle__main,
.chat-list-item__main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.requests-toggle__title,
.chat-list-item__title {
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.requests-toggle__meta,
.chat-list-item__meta {
  color: var(--chat-muted);
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list {
  display: none;
  gap: 7px;
  max-height: 190px;
  margin-top: 8px;
  overflow-y: auto;
}

.requests-dropdown.is-open .chat-list {
  display: grid;
}

.chat-list-item {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--chat-border);
  border-radius: 11px;
  background: #fff;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.chat-list-item:hover,
.chat-list-item.is-selected {
  border-color: var(--chat-border-strong);
  background: #fbfdff;
}

.chat-list-item__status {
  min-width: 30px;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef4fb;
  color: #47627f;
  font-size: 11px;
  font-weight: 750;
}

.chat-list-item__status:empty {
  display: none;
}

.chat-list-item.is-selected .chat-list-item__status {
  background: var(--chat-blue);
  color: #fff;
}

.event-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.chat-card:last-child {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.event-current-title {
  min-width: 0;
  margin: 0;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-link {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid #8d9bad;
  border-radius: 999px;
  background: #fff;
  color: #637184;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.event-link::after {
  content: "↗";
  font-size: 10px;
  line-height: 1;
}

.event-link:hover {
  border-color: var(--chat-blue);
  color: var(--chat-blue);
}

.messages {
  height: auto;
  min-height: 128px;
  flex: 1 1 245px;
  padding: 10px;
  border: 1px solid #e2ecf7;
  border-radius: 13px;
  background: #fbfdff;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-thumb {
  background: #c9d8eb;
  border-radius: 999px;
}

.message {
  max-width: 78%;
  padding: 8px 10px;
  border-radius: 13px;
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.message--incoming {
  align-self: flex-start;
  border-bottom-left-radius: 5px;
  background: #eef4fb;
  color: #24364a;
}

.message--outgoing {
  align-self: flex-end;
  border-bottom-right-radius: 5px;
  background: var(--chat-blue);
  color: #fff;
}

.message__time {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  line-height: 1;
  opacity: 0.72;
  text-align: right;
}

.message-attachment {
  display: grid;
  gap: 2px;
  margin-top: 6px;
  padding: 6px 7px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.72);
  color: inherit;
  text-decoration: none;
}

.message-attachment span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.message-attachment small {
  opacity: 0.75;
}

.chat-empty {
  margin: auto;
  color: var(--chat-muted);
  font-size: 12px;
  text-align: center;
}

.chat-form {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  border: 1px solid var(--chat-border);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.chat-input {
  min-width: 0;
  min-height: 44px;
  max-height: 92px;
  padding: 12px 13px;
  border: 0;
  resize: vertical;
  outline: none;
  font: inherit;
  font-size: 13px;
  color: var(--chat-text);
}

.chat-input::placeholder {
  color: #8a96a8;
}

.chat-submit {
  min-width: 92px;
  border: 0;
  background: var(--chat-blue);
  color: #fff;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  padding: 0 14px;
}

.chat-submit:hover {
  background: #075ee2;
}

.chat-submit:disabled {
  opacity: 0.65;
  cursor: wait;
}

@media (max-width: 520px) {
  .chat-widget {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 98px);
    border-radius: 16px;
  }

  .chat-launcher {
    right: 16px;
    bottom: 16px;
    width: 52px;
    height: 52px;
    min-width: 52px;
    min-height: 52px;
  }

  .chat-launcher .support-widget-badge {
    right: 0;
    top: -1.6rem;
  }

  .event-actions {
    grid-template-columns: 1fr;
  }

  .event-link {
    width: 100%;
    justify-content: center;
  }

  .chat-submit {
    min-width: 82px;
  }
}
