/**
 * Sketch3D-Art Studio Pro - Community Live Chat & Active Members Styles
 */

/* ==========================================================================
   1. Floating Chat Launcher (Bottom Corner)
   ========================================================================== */
.s3a-floating-chat-launcher {
  position: fixed;
  bottom: 16px;
  inset-inline-end: 18px;
  z-index: 99990;
  width: 50px;
  height: 50px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #042f2e 0%, #0f766e 100%);
  color: #ffffff;
  border: 1.5px solid rgba(45, 212, 191, 0.55);
  border-radius: 50%;
  box-shadow: 0 6px 22px rgba(15, 118, 110, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  font-family: inherit;
}

/* In 3D Studio mode or when a modal/fullscreen sim is open, hide floating launcher (navbar button remains accessible) */
body.s3a-design-lock .s3a-floating-chat-launcher,
body.s3a-modal-open .s3a-floating-chat-launcher,
body.s3a-sim-fullscreen .s3a-floating-chat-launcher,
body:has(.scrim) .s3a-floating-chat-launcher {
  display: none !important;
}

.s3a-floating-chat-launcher:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 28px rgba(15, 118, 110, 0.5), 0 3px 10px rgba(0, 0, 0, 0.3);
  border-color: #2dd4bf;
}

.s3a-floating-chat-launcher:active {
  transform: translateY(0) scale(0.98);
}

.s3a-chat-launcher-icon {
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.s3a-chat-launcher-badge {
  position: absolute;
  top: -5px;
  inset-inline-start: -5px;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  border-radius: 999px;
  background: #22c55e;
  color: #052e16;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0b1118;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
}

.s3a-chat-purpose-banner {
  background: rgba(13, 148, 136, 0.14);
  border-bottom: 1px solid rgba(45, 212, 191, 0.22);
  color: #cbd5e1;
  font-size: 11.5px;
  line-height: 1.55;
  padding: 8px 14px;
  flex-shrink: 0;
}

.s3a-chat-pulse-dot {
  width: 7px;
  height: 7px;
  background-color: #22c55e;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: s3aPulseDot 1.8s infinite;
}

@keyframes s3aPulseDot {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* ==========================================================================
   2. Chat Modal / Window
   ========================================================================== */
.s3a-chat-container {
  position: fixed;
  bottom: 68px;
  inset-inline-end: 18px;
  z-index: 99995;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 100px);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
}

.s3a-chat-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
}

.s3a-chat-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.s3a-chat-window {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(45, 212, 191, 0.2);
  overflow: hidden;
  box-sizing: border-box;
}

/* Header */
.s3a-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(135deg, #0d1726 0%, #112638 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.s3a-chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.s3a-chat-header-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.s3a-chat-header-title h4 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 800;
  color: #f8fafc;
  line-height: 1.2;
}

.s3a-chat-header-subtitle {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
}

.s3a-chat-close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all 0.15s;
}

.s3a-chat-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

/* Tabs */
.s3a-chat-tabs {
  display: flex;
  background: rgba(10, 16, 26, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.s3a-chat-tab {
  flex: 1;
  padding: 10px 8px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}

.s3a-chat-tab:hover {
  color: #e2e8f0;
}

.s3a-chat-tab.active {
  color: #2dd4bf;
  border-bottom-color: #2dd4bf;
  background: rgba(45, 212, 191, 0.05);
}

.s3a-chat-tab-count,
.s3a-chat-tab-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 800;
}

.s3a-chat-tab-count {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.s3a-chat-tab-badge {
  background: #0f766e;
  color: #99f6e4;
}

/* Views Container */
.s3a-chat-view {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.s3a-view-hidden {
  display: none !important;
}

/* Messages Feed */
.s3a-chat-messages-feed {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.s3a-chat-empty,
.s3a-chat-loading-placeholder {
  text-align: center;
  padding: 40px 16px;
  color: #94a3b8;
  font-size: 13px;
  margin: auto;
}

/* Message Bubble */
.s3a-chat-bubble-wrap {
  display: flex;
  gap: 9px;
  max-width: 86%;
}

.s3a-chat-bubble-other {
  align-self: flex-start;
}

.s3a-chat-bubble-me {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.s3a-chat-bubble-avatar {
  flex-shrink: 0;
}

.s3a-chat-avatar-fallback {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.s3a-chat-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.s3a-chat-bubble-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.s3a-chat-bubble-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}

.s3a-chat-bubble-sender {
  font-size: 11px;
  font-weight: 700;
  color: #cbd5e1;
}

.s3a-chat-bubble-time {
  font-size: 10px;
  color: #64748b;
  font-family: monospace;
}

.s3a-chat-bubble-text {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.s3a-chat-bubble-other .s3a-chat-bubble-text {
  background: rgba(30, 41, 59, 0.85);
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top-left-radius: 2px;
}

.s3a-chat-bubble-me .s3a-chat-bubble-text {
  background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
  color: #ffffff;
  border: 1px solid rgba(45, 212, 191, 0.3);
  border-top-right-radius: 2px;
}

/* Voice Player Bubble */
.s3a-chat-voice-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(45, 212, 191, 0.25);
  min-width: 170px;
}

.s3a-chat-bubble-me .s3a-chat-voice-player {
  background: linear-gradient(135deg, #0d5952 0%, #064e3b 100%);
}

.s3a-chat-voice-play-btn {
  background: #2dd4bf;
  border: none;
  color: #042f2e;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  flex-shrink: 0;
  transition: all 0.15s;
}

.s3a-chat-voice-play-btn:hover {
  transform: scale(1.08);
  background: #5eead4;
}

.s3a-chat-voice-waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 24px;
  flex: 1;
}

.s3a-chat-waveform-bar {
  width: 3px;
  background: #2dd4bf;
  border-radius: 2px;
  opacity: 0.75;
}

.s3a-chat-voice-duration {
  font-size: 11px;
  color: #99f6e4;
  font-family: monospace;
  font-weight: 700;
  flex-shrink: 0;
}

.s3a-chat-hidden-audio {
  display: none;
}

/* Active Users View */
.s3a-chat-users-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
}

.s3a-chat-online-pill {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

.s3a-chat-users-list {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.s3a-chat-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.15s;
}

.s3a-chat-user-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(45, 212, 191, 0.2);
}

.s3a-chat-user-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.s3a-chat-user-online-dot {
  position: absolute;
  bottom: -1px;
  inset-inline-end: -1px;
  width: 9px;
  height: 9px;
  background: #22c55e;
  border: 2px solid #0f172a;
  border-radius: 50%;
}

.s3a-chat-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.s3a-chat-user-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.s3a-chat-user-company {
  font-size: 11px;
  color: #38bdf8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.s3a-chat-user-status-tag {
  font-size: 10.5px;
  color: #4ade80;
  font-weight: 600;
  flex-shrink: 0;
}

.s3a-chat-empty-users {
  text-align: center;
  padding: 30px 14px;
  color: #94a3b8;
  font-size: 12.5px;
}

/* ==========================================================================
   3. Footer & Action Controls
   ========================================================================== */
.s3a-chat-footer {
  padding: 10px 12px;
  background: rgba(10, 16, 26, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Input Row */
.s3a-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.s3a-chat-text-input {
  flex: 1;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 12px;
  color: #f8fafc;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: all 0.15s;
}

.s3a-chat-text-input:focus {
  border-color: #2dd4bf;
  background: rgba(30, 41, 59, 0.95);
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.2);
}

.s3a-chat-text-input::placeholder {
  color: #64748b;
}

.s3a-chat-voice-btn,
.s3a-chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: all 0.15s;
}

.s3a-chat-voice-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #38bdf8;
}

.s3a-chat-voice-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.4);
  transform: scale(1.05);
}

.s3a-chat-send-btn {
  background: #0d9488;
  color: #ffffff;
}

.s3a-chat-send-btn:hover {
  background: #0f766e;
  transform: scale(1.05);
}

.s3a-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Recording Panel */
.s3a-chat-recording-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 4px;
}

.s3a-chat-recording-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.s3a-chat-rec-dot {
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
  animation: s3aRecBlink 1s infinite;
}

@keyframes s3aRecBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.85); }
}

.s3a-chat-rec-time {
  font-size: 13px;
  font-weight: 800;
  color: #f87171;
  font-family: monospace;
}

.s3a-chat-recording-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.s3a-chat-btn-cancel-rec {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.s3a-chat-btn-cancel-rec:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

.s3a-chat-btn-send-rec {
  background: #10b981;
  border: none;
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.s3a-chat-btn-send-rec:hover {
  background: #059669;
  transform: scale(1.04);
}

/* Auth Prompt Banner */
.s3a-chat-auth-prompt {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
  padding: 4px 0;
}

.s3a-chat-auth-msg {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.4;
}

.s3a-chat-login-action-btn {
  background: linear-gradient(135deg, #0d9488 0%, #0284c7 100%);
  border: none;
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
  transition: all 0.15s;
}

.s3a-chat-login-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.45);
}

/* ==========================================================================
   4. Mobile Responsiveness
   ========================================================================== */
@media (max-width: 600px) {
  .s3a-floating-chat-launcher {
    bottom: 12px;
    inset-inline-end: 12px;
    width: 46px;
    height: 46px;
  }
  .s3a-chat-launcher-badge {
    min-width: 19px;
    height: 19px;
    font-size: 10px;
  }
  .s3a-chat-container {
    bottom: 64px;
    inset-inline-start: 8px;
    inset-inline-end: 8px;
    width: auto;
    max-width: none;
    height: 480px;
  }
}
