/* Floating chat launcher */
#js-init-chat-icon {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--brand-cyan) 50%, transparent);
  background: var(--gradient-main);
  color: #fff;
  box-shadow: var(--shadow-glow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 1045;
  cursor: pointer;
  transition: var(--transition-fast);
}

#js-init-chat-icon:hover {
  transform: translateY(-3px);
}

#js-init-chat-icon #js-chat-min-icon {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: inherit;
}

#js-init-chat-icon .icon {
  width: 22px;
  height: 22px;
}

#js-init-chat-icon.has-message {
  border-color: transparent;
  background: linear-gradient(135deg, var(--danger), #ff8b8b);
  box-shadow: 0 20px 34px color-mix(in srgb, var(--danger) 40%, transparent);
}

body.chat-panel-open #js-init-chat-icon {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

/* Chat panel shell */
#js-rise-chat-wrapper.rise-chat-wrapper:not(.rise-cart-wrapper) {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: min(410px, calc(100vw - 26px));
  height: min(76vh, 690px);
  min-height: 430px;
  max-height: min(76vh, 690px);
  border-radius: var(--radius-card);
  border: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface-light) 97%, transparent);
  box-shadow: var(--shadow-section);
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
  overflow-y: hidden !important;
  overflow-x: hidden !important;
  -ms-overflow-style: none;
  scrollbar-width: none;
  z-index: 1044;
}

#js-rise-chat-wrapper.rise-chat-wrapper:not(.rise-cart-wrapper)::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

#js-rise-chat-wrapper.hide {
  display: none !important;
}

#js-rise-chat-wrapper .rise-chat-header.box {
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface-muted) 92%, transparent);
  box-shadow: none;
  min-height: 52px;
  display: flex;
  align-items: center;
}

#js-rise-chat-wrapper .rise-chat-header .box-content {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
}

#js-rise-chat-wrapper .chat-back,
#js-rise-chat-wrapper .chat-close {
  width: 42px;
  min-width: 42px;
  justify-content: center;
  color: var(--text-secondary);
}

#js-rise-chat-wrapper .chat-back:hover,
#js-rise-chat-wrapper .chat-close:hover {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--brand-cyan) 12%, transparent);
}

#js-rise-chat-wrapper .chat-title {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text-primary);
  font-weight: 700;
}

#js-rise-chat-wrapper .chat-title .chat-active-user {
  width: 100%;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#js-rise-chat-wrapper .chat-active-user-name {
  display: inline-block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tabs and lists */
#js-rise-chat-wrapper .chat-tab {
  width: 100%;
  border: 0;
  box-shadow: none;
}

#js-rise-chat-wrapper .chat-tab > li > a {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0 !important;
  border-bottom: 3px solid transparent !important;
  color: var(--text-secondary);
}

#js-rise-chat-wrapper .chat-tab > li > a:hover,
#js-rise-chat-wrapper .chat-tab > li > a:focus,
#js-rise-chat-wrapper .chat-tab > li > a.active {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--brand-cyan) 14%, transparent);
  border-bottom-color: color-mix(in srgb, var(--brand-teal) 65%, transparent) !important;
}

#js-rise-chat-wrapper .rise-chat-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 6px;
  background: color-mix(in srgb, var(--surface-muted) 92%, transparent);
  overflow-y: auto !important;
  overflow-x: hidden;
}

#js-rise-chat-wrapper .rise-chat-body.chat-active-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#js-rise-chat-wrapper #js-chat-messages-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px;
}

#js-rise-chat-wrapper #js-chat-team-members-list,
#js-rise-chat-wrapper #chatlist-of-user {
  display: grid;
  gap: 6px;
  padding: 6px;
}

#js-rise-chat-wrapper .message-row {
  margin: 0;
  border-radius: 14px;
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--surface-light) 96%, transparent);
  padding: 10px;
  transition: var(--transition-fast);
}

#js-rise-chat-wrapper .message-row:hover {
  border-color: color-mix(in srgb, var(--brand-cyan) 34%, transparent);
  background: color-mix(in srgb, var(--brand-cyan) 11%, transparent);
}

#js-rise-chat-wrapper .message-row.unread {
  border-color: color-mix(in srgb, var(--highlight-blue) 30%, transparent);
  background: color-mix(in srgb, var(--highlight-blue) 10%, transparent);
}

#js-rise-chat-wrapper .chat-row-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

#js-rise-chat-wrapper .chat-row-subline,
#js-rise-chat-wrapper .message-row .time {
  color: var(--text-secondary);
}

/* Avatars */
#js-rise-chat-wrapper .avatar.avatar-xs {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: color-mix(in srgb, var(--brand-cyan) 20%, transparent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#js-rise-chat-wrapper .avatar.avatar-xs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#js-rise-chat-wrapper .avatar.avatar-xs .chat-avatar-fallback {
  display: none;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#js-rise-chat-wrapper .avatar.avatar-xs.is-broken .chat-avatar-fallback {
  display: inline-flex;
}

/* Chat messages */
#js-rise-chat-wrapper .chat-msg {
  max-width: 72%;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface-light) 96%, transparent);
  padding: 8px 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

#js-rise-chat-wrapper .chat-other .chat-msg {
  border-radius: 14px 14px 14px 4px;
}

#js-rise-chat-wrapper .chat-me .chat-msg {
  border: 0;
  border-radius: 14px 14px 4px 14px;
  background: var(--gradient-main);
  color: #fff;
}

#js-rise-chat-wrapper #js-chat-reply-indicator {
  color: var(--text-secondary);
  font-size: 0.76rem;
  padding: 2px 10px 6px;
}

/* Composer */
#js-rise-chat-wrapper .rise-chat-footer {
  border-top: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface-light) 97%, transparent);
  padding: 8px;
}

#js-rise-chat-wrapper .rise-chat-footer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 120px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface-light) 96%, transparent);
  color: var(--text-primary);
  padding: 10px 12px;
  resize: none;
}

#js-rise-chat-wrapper .rise-chat-footer textarea:focus {
  border-color: color-mix(in srgb, var(--brand-cyan) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-cyan) 24%, transparent);
}

#js-rise-chat-wrapper .rise-chat-footer .chat-button-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#js-rise-chat-wrapper .rise-chat-footer .chat-file-upload-icon .btn,
#js-rise-chat-wrapper .rise-chat-footer .chat-file-upload-icon .upload-file-button,
#js-rise-chat-wrapper .rise-chat-footer #record-start-button,
#js-rise-chat-wrapper .rise-chat-footer #record-stop-button {
  width: 40px;
  height: 40px;
  min-height: 40px;
  border-radius: 50% !important;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#js-rise-chat-wrapper .rise-chat-footer .message-send-button {
  width: 46px;
  height: 46px;
  min-height: 46px;
  border-radius: 50%;
  border: 0 !important;
  background: var(--gradient-main) !important;
  color: #fff !important;
}

/* Scrollbars */
#js-rise-chat-wrapper .rise-chat-body,
#js-rise-chat-wrapper #chatlist-of-user,
#js-rise-chat-wrapper #js-chat-messages-container {
  -ms-overflow-style: none;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--brand-cyan) 40%, transparent) color-mix(in srgb, var(--surface-muted) 80%, transparent);
}

#js-rise-chat-wrapper .rise-chat-body::-webkit-scrollbar,
#js-rise-chat-wrapper #chatlist-of-user::-webkit-scrollbar,
#js-rise-chat-wrapper #js-chat-messages-container::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* RTL */
html[dir="rtl"] #js-init-chat-icon {
  right: auto;
  left: 20px;
}

html[dir="rtl"] body.chat-panel-open #js-init-chat-icon {
  right: auto;
  left: 20px;
}

html[dir="rtl"] #js-rise-chat-wrapper.rise-chat-wrapper:not(.rise-cart-wrapper) {
  right: auto;
  left: 20px;
}

/* Responsive */
@media (max-width: 1024px) {
  #js-rise-chat-wrapper.rise-chat-wrapper:not(.rise-cart-wrapper) {
    right: 16px;
    width: min(390px, calc(100vw - 32px));
  }

  html[dir="rtl"] #js-rise-chat-wrapper.rise-chat-wrapper:not(.rise-cart-wrapper) {
    left: 16px;
  }
}

@media (max-width: 767px) {
  #js-rise-chat-wrapper.rise-chat-wrapper:not(.rise-cart-wrapper) {
    left: 12px !important;
    right: 12px !important;
    top: 12px !important;
    bottom: 12px !important;
    width: auto !important;
    height: auto !important;
    min-height: 0;
    max-height: none;
    border-radius: 18px;
  }

  #js-init-chat-icon {
    right: 14px;
    bottom: 86px;
    width: 54px;
    height: 54px;
  }

  body.chat-panel-open #js-init-chat-icon {
    opacity: 0;
    pointer-events: none;
  }

  html[dir="rtl"] #js-init-chat-icon {
    right: auto;
    left: 14px;
  }
}
