/* Floating support chat widget */
#apex-support-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 180;
  font-family: inherit;
}

body.apex-app-page #apex-support-root {
  bottom: 96px;
}

@media (max-width: 640px) {
  #apex-support-root {
    right: 14px;
    bottom: 14px;
  }
  body.apex-app-page #apex-support-root {
    bottom: 88px;
  }
}

.apex-support-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--apex-accent-border, rgba(192, 132, 252, 0.45));
  background: linear-gradient(145deg, rgba(168, 85, 247, 0.35), rgba(88, 28, 135, 0.55));
  color: var(--apex-accent-light, #e9d5ff);
  box-shadow: 0 0 24px var(--apex-accent-glow, rgba(168, 85, 247, 0.35));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.apex-support-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 32px var(--apex-accent-glow, rgba(168, 85, 247, 0.5));
}

.apex-support-fab svg {
  width: 26px;
  height: 26px;
}

.apex-support-panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  width: min(360px, calc(100vw - 28px));
  height: min(480px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid var(--apex-accent-border, rgba(192, 132, 252, 0.35));
  background: var(--apex-card, rgba(15, 10, 25, 0.96));
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.45), 0 0 40px var(--apex-accent-glow, rgba(168, 85, 247, 0.15));
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.apex-support-panel.apex-hidden {
  display: none;
}

.apex-support-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(192, 132, 252, 0.2);
  background: linear-gradient(90deg, rgba(168, 85, 247, 0.12), transparent);
}

.apex-support-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--apex-text, #f3e8ff);
}

.apex-support-status {
  font-size: 0.75rem;
  color: var(--apex-muted, #a78bfa);
}

.apex-support-close {
  border: none;
  background: transparent;
  color: var(--apex-muted, #a78bfa);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.apex-support-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.apex-support-empty,
.apex-support-login {
  margin: auto;
  text-align: center;
  color: var(--apex-muted, #a78bfa);
  font-size: 0.9rem;
  padding: 20px;
}

.apex-support-login .apex-btn {
  margin-top: 12px;
}

.apex-support-msg {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}

.apex-support-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.45), rgba(124, 58, 237, 0.35));
  border: 1px solid rgba(192, 132, 252, 0.35);
  color: var(--apex-text, #f3e8ff);
}

.apex-support-msg--admin {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--apex-text, #f3e8ff);
}

.apex-support-msg time {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
  opacity: 0.65;
}

.apex-support-compose {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(192, 132, 252, 0.15);
  background: rgba(0, 0, 0, 0.2);
}

.apex-support-compose input {
  flex: 1;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid rgba(192, 132, 252, 0.25);
  background: rgba(0, 0, 0, 0.35);
  color: var(--apex-text, #f3e8ff);
  padding: 10px 12px;
  font-size: 0.9rem;
}

.apex-support-compose input:focus {
  outline: none;
  border-color: var(--apex-accent, #c084fc);
  box-shadow: 0 0 0 2px rgba(192, 132, 252, 0.2);
}

.apex-support-send {
  border: none;
  border-radius: 10px;
  padding: 0 14px;
  background: var(--apex-accent, #c084fc);
  color: #1a0a2e;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.apex-support-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Admin support section */
.admin-support-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 16px;
  min-height: 420px;
}

@media (max-width: 900px) {
  .admin-support-layout {
    grid-template-columns: 1fr;
  }
}

.admin-support-list {
  border: 1px solid rgba(192, 132, 252, 0.2);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  max-height: 520px;
  overflow-y: auto;
}

.admin-support-conv {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.admin-support-conv:hover,
.admin-support-conv.active {
  background: rgba(168, 85, 247, 0.12);
}

.admin-support-conv strong {
  display: block;
  font-size: 0.9rem;
}

.admin-support-conv span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted, #a78bfa);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-support-unread {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--apex-accent, #c084fc);
  color: #1a0a2e;
  font-size: 0.7rem;
  font-weight: 700;
}

.admin-support-chat {
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(192, 132, 252, 0.2);
  border-radius: 12px;
  overflow: hidden;
  min-height: 420px;
  background: rgba(0, 0, 0, 0.15);
}

.admin-support-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-support-chat-compose {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(192, 132, 252, 0.15);
}

.admin-support-chat-compose input {
  flex: 1;
  min-width: 0;
}

.admin-support-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  color: var(--muted, #a78bfa);
  padding: 24px;
  text-align: center;
}
