/* Modern support widget — site glass + orange accent (Intercom/Crisp inspired) */
#rax-support-root {
  --rax-support-orange: #ff8c00;
  --rax-support-orange-deep: #d2691e;
  position: fixed !important;
  right: 20px;
  bottom: 20px;
  left: auto;
  top: auto;
  width: auto;
  height: auto;
  z-index: 2147483000 !important;
  font-family: inherit;
  color: #f3f4f6;
  pointer-events: none;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

#rax-support-launcher,
#rax-support-panel {
  pointer-events: auto;
}

/* Launcher: glass chat pill with live avatar */
#rax-support-launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: min(280px, calc(100vw - 40px));
  padding: 10px 16px 10px 10px;
  border: 1px solid rgba(255, 140, 0, 0.35);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255, 140, 0, 0.18), rgba(20, 20, 25, 0.55)),
    rgba(20, 20, 25, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 12px 32px rgba(0, 0, 0, 0.45),
    0 0 28px rgba(255, 140, 0, 0.18);
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  animation: rax-support-float 3s ease-in-out infinite;
}

#rax-support-launcher::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 1px solid rgba(255, 140, 0, 0.35);
  opacity: 0.65;
  animation: rax-support-ring 2.6s ease-out infinite;
  pointer-events: none;
}

#rax-support-launcher:hover {
  transform: translateY(-4px) scale(1.03);
  border-color: rgba(255, 140, 0, 0.65);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 16px 40px rgba(0, 0, 0, 0.5),
    0 0 36px rgba(255, 140, 0, 0.32);
  animation-play-state: paused;
}

#rax-support-root.open #rax-support-launcher {
  animation: none;
  border-radius: 999px;
  padding: 12px;
  min-width: 0;
  width: 52px;
  height: 52px;
  justify-content: center;
}

#rax-support-root.open #rax-support-launcher::before {
  display: none;
}

#rax-support-root.open .rax-support-launcher-copy,
#rax-support-root.open .rax-support-launcher-avatar {
  display: none;
}

#rax-support-root.open #rax-support-launcher::after {
  content: '×';
  font-size: 1.55rem;
  font-weight: 400;
  line-height: 1;
  color: #fff;
}

.rax-support-launcher-avatar {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ff8c00, #cd7f32);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(255, 140, 0, 0.35);
}

.rax-support-launcher-avatar i {
  color: #111;
  font-size: 1.05rem;
}

.rax-support-launcher-avatar .rax-support-online {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid rgba(20, 20, 25, 0.95);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: rax-support-online 1.8s ease-out infinite;
}

.rax-support-launcher-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding-right: 2px;
}

.rax-support-launcher-kicker {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
}

.rax-support-launcher-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
}

.rax-support-launcher-now {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffb347;
}

.rax-support-launcher-now::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
}

/* Panel */
#rax-support-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: min(390px, calc(100vw - 28px));
  height: min(540px, calc(100vh - 110px));
  display: none;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(16, 16, 20, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 140, 0, 0.08) inset;
  transform-origin: bottom right;
  animation: rax-support-panel-in 0.22s ease-out;
}

#rax-support-root.open #rax-support-panel {
  display: flex;
}

.rax-support-header {
  padding: 16px 16px 14px;
  background:
    linear-gradient(135deg, rgba(255, 140, 0, 0.28), rgba(210, 105, 30, 0.08) 55%, transparent),
    rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rax-support-header-main {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.rax-support-header-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: linear-gradient(145deg, #ff8c00, #cd7f32);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111;
  font-size: 1.05rem;
}

.rax-support-header-avatar .rax-support-online {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid rgba(20, 20, 25, 0.95);
}

.rax-support-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.rax-support-header p {
  margin: 3px 0 0;
  font-size: 0.75rem;
  color: rgba(243, 244, 246, 0.72);
}

.rax-support-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(243, 244, 246, 0.9);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.rax-support-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.rax-support-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    radial-gradient(ellipse at top right, rgba(255, 140, 0, 0.05), transparent 45%),
    transparent;
}

.rax-support-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.rax-support-msg.web {
  align-self: flex-end;
  border-radius: 14px 14px 4px 14px;
  background: linear-gradient(145deg, rgba(255, 140, 0, 0.28), rgba(210, 105, 30, 0.18));
  border: 1px solid rgba(255, 140, 0, 0.35);
  color: #fff7ed;
}

.rax-support-msg.discord {
  align-self: flex-start;
  border-radius: 14px 14px 14px 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.rax-support-msg .meta {
  display: block;
  font-size: 0.68rem;
  opacity: 0.7;
  margin-bottom: 4px;
}

.rax-support-msg img {
  display: block;
  max-width: 100%;
  border-radius: 10px;
  margin-top: 6px;
}

.rax-support-greeting {
  animation: rax-support-msg-in 0.32s ease-out;
}

.rax-support-typing {
  align-self: flex-start;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 92%;
}

.rax-support-typing-avatar {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ff8c00, #cd7f32);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111;
  font-size: 0.75rem;
}

.rax-support-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px 14px 14px 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.rax-support-typing-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(243, 244, 246, 0.88);
  animation: rax-support-typing-pulse 1.4s ease-in-out infinite;
}

.rax-support-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 10px;
}

.rax-support-typing-dots i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff8c00;
  animation: rax-support-dot 1.15s infinite ease-in-out;
}

.rax-support-typing-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.rax-support-typing-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

.rax-support-gate,
.rax-support-composer {
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.28);
}

.rax-support-gate label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 6px;
  color: rgba(243, 244, 246, 0.8);
}

.rax-support-gate input,
.rax-support-composer textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  padding: 11px 12px;
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rax-support-gate input:focus,
.rax-support-composer textarea:focus {
  border-color: rgba(255, 140, 0, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 140, 0, 0.15);
}

.rax-support-composer textarea {
  min-height: 68px;
  resize: none;
}

.rax-support-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.rax-support-hint {
  font-size: 0.7rem;
  color: rgba(243, 244, 246, 0.55);
}

.rax-support-btn {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff8c00 0%, #cd7f32 100%);
  color: #111;
  font-weight: 800;
  padding: 10px 16px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(255, 140, 0, 0.28);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.rax-support-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.rax-support-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.rax-support-error {
  color: #fecaca;
  font-size: 0.8rem;
  margin-top: 8px;
}

.rax-support-preview {
  margin-top: 8px;
  position: relative;
  display: none;
}

.rax-support-preview img {
  max-height: 96px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.rax-support-preview button {
  position: absolute;
  top: 4px;
  right: 4px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  width: 22px;
  height: 22px;
  cursor: pointer;
}

@keyframes rax-support-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes rax-support-ring {
  0% { transform: scale(1); opacity: 0.7; }
  70% { transform: scale(1.08); opacity: 0; }
  100% { transform: scale(1.08); opacity: 0; }
}

@keyframes rax-support-online {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

@keyframes rax-support-panel-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes rax-support-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes rax-support-dot {
  0%, 70%, 100% { transform: translateY(0); opacity: 0.35; }
  35% { transform: translateY(-4px); opacity: 1; }
}

@keyframes rax-support-typing-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.rax-support-badge {
  position: absolute;
  top: -4px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px rgba(20, 20, 25, 0.95);
  z-index: 2;
}

.rax-support-field-tip {
  margin: 6px 0 12px;
  font-size: 0.75rem;
  color: rgba(243, 244, 246, 0.62);
  line-height: 1.35;
}

.rax-support-optional {
  font-weight: 500;
  opacity: 0.7;
}

.rax-support-gate textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  padding: 11px 12px;
  font: inherit;
  outline: none;
  resize: vertical;
  min-height: 72px;
  margin-bottom: 4px;
}

.rax-support-gate textarea:focus {
  border-color: rgba(255, 140, 0, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 140, 0, 0.15);
}

.rax-support-gate label[for="rax-support-first-msg"] {
  margin-top: 10px;
}

.rax-support-tools {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.rax-support-tool {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #ffb347;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.rax-support-tool:hover {
  background: rgba(255, 140, 0, 0.16);
  border-color: rgba(255, 140, 0, 0.45);
}

/* Phones + small tablets: compact FAB above Safari/Chrome chrome */
@media (max-width: 767px) {
  #rax-support-root {
    right: max(14px, env(safe-area-inset-right, 0px)) !important;
    bottom: max(14px, env(safe-area-inset-bottom, 0px)) !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    z-index: 2147483000 !important;
  }
  #rax-support-root.open {
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    top: 0 !important;
    pointer-events: auto !important;
  }
  #rax-support-launcher {
    position: relative !important;
    right: auto !important;
    bottom: auto !important;
    width: 58px;
    height: 58px;
    min-width: 58px;
    min-height: 58px;
    max-width: none;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
    gap: 0;
  }
  #rax-support-launcher .rax-support-launcher-copy {
    display: none !important;
  }
  #rax-support-launcher .rax-support-launcher-avatar {
    width: 42px;
    height: 42px;
  }
  /* Header close only — avoid dual X controls covering the panel */
  #rax-support-root.open #rax-support-launcher {
    display: none !important;
  }
  #rax-support-panel {
    position: fixed !important;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    bottom: 0;
    right: 0;
    border-radius: 0;
    z-index: 2147483001;
    pointer-events: auto !important;
  }
  .rax-support-composer textarea,
  .rax-support-gate input,
  .rax-support-gate textarea,
  .rax-support-btn,
  .rax-support-tool {
    font-size: 16px;
  }
  .rax-support-composer {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  #rax-support-launcher,
  #rax-support-launcher::before,
  .rax-support-launcher-avatar .rax-support-online,
  #rax-support-panel,
  .rax-support-greeting,
  .rax-support-typing-label,
  .rax-support-typing-dots i {
    animation: none;
  }
}
