/* ==========================================================================
   Apex Live & Gold Scalping Desk - Live Chat Widget (Tawk.to Style)
   ========================================================================== */

:root {
  --apex-chat-primary: #f59e0b;
  --apex-chat-dark: #0b111e;
  --apex-chat-header: linear-gradient(135deg, #0b111e 0%, #151f33 100%);
  --apex-chat-card-bg: #0d1527;
  --apex-chat-body-bg: #090e1a;
  --apex-chat-bubble-bot: #162238;
  --apex-chat-bubble-user: #f59e0b;
  --apex-chat-text-main: #f8fafc;
  --apex-chat-text-muted: #94a3b8;
  --apex-chat-border: rgba(255, 255, 255, 0.08);
}

/* Chat Launcher Button */
.apex-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  height: 56px;
  min-width: 56px;
  padding: 0 18px 0 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border: 1.5px solid rgba(245, 158, 11, 0.6);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 0 15px rgba(245, 158, 11, 0.25);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  z-index: 99999;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  color: #ffffff;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
}

.apex-chat-launcher:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: #f59e0b;
  box-shadow: 0 14px 30px -4px rgba(0, 0, 0, 0.7), 0 0 20px rgba(245, 158, 11, 0.45);
}

.apex-chat-launcher-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  position: relative;
}

.apex-chat-online-pulse {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  background-color: #10b981;
  border-radius: 50%;
  border: 1.5px solid #0f172a;
  animation: apexPulse 2s infinite;
}

@keyframes apexPulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.apex-chat-launcher-text {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #ffffff;
}

.apex-chat-unread-badge {
  background: #ef4444;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 2px;
}

/* Chat Popup Window */
.apex-chat-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: var(--apex-chat-card-bg);
  border: 1px solid var(--apex-chat-border);
  border-radius: 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.65), 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.apex-chat-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Chat Header */
.apex-chat-header {
  background: var(--apex-chat-header);
  padding: 16px 18px;
  border-bottom: 1px solid var(--apex-chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.apex-chat-header-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.apex-chat-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f59e0b;
  font-size: 1.25rem;
  border: 1.5px solid rgba(245, 158, 11, 0.4);
}

.apex-chat-header-info h5 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.apex-chat-header-status {
  font-size: 0.76rem;
  color: var(--apex-chat-text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.apex-chat-header-status .status-dot {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
}

.apex-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.apex-chat-btn-action {
  background: transparent;
  border: none;
  color: #94a3b8;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.apex-chat-btn-action:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* Chat Body / Messages Area */
.apex-chat-body {
  flex: 1;
  background: var(--apex-chat-body-bg);
  padding: 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.apex-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
}

.apex-chat-msg.msg-incoming {
  align-self: flex-start;
}

.apex-chat-msg.msg-outgoing {
  align-self: flex-end;
}

.apex-chat-bubble {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}

.msg-incoming .apex-chat-bubble {
  background: var(--apex-chat-bubble-bot);
  color: #e2e8f0;
  border: 1px solid var(--apex-chat-border);
  border-bottom-left-radius: 4px;
}

.msg-outgoing .apex-chat-bubble {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0b111e;
  font-weight: 600;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.apex-chat-msg-time {
  font-size: 0.7rem;
  color: #64748b;
  margin-top: 4px;
  padding: 0 4px;
}

.msg-outgoing .apex-chat-msg-time {
  align-self: flex-end;
}

/* Quick Action Chips */
.apex-chat-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.apex-chat-chip-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #f1f5f9;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.apex-chat-chip-btn:hover {
  background: rgba(245, 158, 11, 0.12);
  border-color: #f59e0b;
  color: #f59e0b;
  transform: translateX(3px);
}

/* Typing Indicator */
.apex-chat-typing {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  background: var(--apex-chat-bubble-bot);
  border-radius: 12px;
  width: fit-content;
  border: 1px solid var(--apex-chat-border);
}

.apex-chat-typing span {
  width: 6px;
  height: 6px;
  background: #f59e0b;
  border-radius: 50%;
  animation: apexBounce 1.4s infinite ease-in-out both;
}

.apex-chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.apex-chat-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes apexBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Chat Footer / Input */
.apex-chat-footer {
  background: var(--apex-chat-header);
  border-top: 1px solid var(--apex-chat-border);
  padding: 12px 14px;
}

.apex-chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #060a12;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s;
}

.apex-chat-input-wrap:focus-within {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.apex-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 0.88rem;
  font-family: inherit;
}

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

.apex-chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f59e0b;
  border: none;
  color: #0b111e;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, background-color 0.15s;
}

.apex-chat-send-btn:hover {
  background: #fbbf24;
  transform: scale(1.06);
}

.apex-chat-branding-tag {
  text-align: center;
  font-size: 0.68rem;
  color: #64748b;
  margin-top: 6px;
}

.apex-chat-branding-tag a {
  color: #f59e0b;
  text-decoration: none;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .apex-chat-window {
    right: 12px;
    bottom: 80px;
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
  }
  .apex-chat-launcher {
    bottom: 16px;
    right: 16px;
  }
}
