.chat-widget {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  width: 360px;
  max-width: calc(100vw - 24px);
  font-size: 14px;
  margin: 0;
  pointer-events: auto;
}

.chat-widget__bar {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  background: #1f2937;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 8px 30px rgba(0,0,0,.22);
  cursor: pointer;
}

.chat-widget__bar-left,
.chat-widget__bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-widget__title-wrap {
  display: inline-flex;
  align-items: center;
}

.chat-widget__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #22c55e;
  display: inline-block;
}

.chat-widget__title {
  font-weight: 700;
}

.chat-widget__mobile-icon {
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}

.chat-widget__mobile-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

.chat-widget__badge {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dc3545;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.chat-widget__chevron {
  font-size: 12px;
  opacity: .85;
  transition: transform .2s ease;
}

.chat-widget--open .chat-widget__chevron {
  transform: rotate(180deg);
}

.chat-widget__panel {
  margin-top: 10px;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}

.chat-widget__panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(0,0,0,.08);
  background: #f8f9fa;
}

.chat-widget__panel-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.chat-widget__panel-subtitle {
  font-size: 12px;
  color: #6c757d;
  margin-top: 3px;
}

.chat-widget__close {
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: #6c757d;
  cursor: pointer;
  padding: 0;
}

.chat-widget__messages {
  height: 320px;
  overflow-y: auto;
  padding: 12px;
  background: #fff;
}

.chat-widget__message {
  padding: 10px 11px;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 12px;
  margin-bottom: 10px;
  background: #fafafa;
}

.chat-widget__message:last-child {
  margin-bottom: 0;
}

.chat-widget__message-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.chat-widget__message-user {
  font-weight: 700;
  color: #212529;
}

.chat-widget__message-role {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e9ecef;
  color: #495057;
}

.chat-widget__message-text {
  color: #212529;
  white-space: normal;
  word-break: break-word;
}

.chat-widget__message-time {
  margin-top: 7px;
  font-size: 11px;
  color: #6c757d;
}

.chat-widget__form {
  border-top: 1px solid rgba(0,0,0,.08);
  padding: 12px;
  background: #fff;
}

.chat-widget__form-footer {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-widget__loading,
.chat-widget__empty,
.chat-widget__error {
  padding: 12px;
  text-align: center;
  color: #6c757d;
}

.chat-widget__error {
  color: #b02a37;
}

@media (max-width: 576px) {
  .chat-widget {
    right: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
  }

  .chat-widget__bar {
    width: 58px;
    height: 58px;
    border-radius: 999px;
    padding: 0;
    justify-content: center;
    position: relative;
  }

  .chat-widget__dot,
  .chat-widget__title-wrap,
  .chat-widget__chevron {
    display: none;
  }

  .chat-widget__mobile-icon {
    display: inline-flex;
  }

  .chat-widget__bar-right {
    position: absolute;
    top: -4px;
    right: -4px;
    gap: 0;
  }

  .chat-widget__badge {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    font-size: 11px;
    box-shadow: 0 4px 10px rgba(0,0,0,.22);
  }

  .chat-widget__panel {
    position: fixed;
    right: 10px;
    left: 10px;
    bottom: 78px;
    margin-top: 0;
    border-radius: 16px;
    max-height: calc(100vh - 110px);
  }

  .chat-widget__messages {
    height: 300px;
    max-height: calc(100vh - 280px);
  }

  .chat-widget__form-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-widget__form-footer .btn {
    width: 100%;
  }
}