/* ===== Chat Widget ===== */
.chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.4), 0 0 15px rgba(var(--accent-rgb), 0.35);
  transition: background-color 0.3s, border-color 0.3s, color 0.3s, fill 0.3s, stroke 0.3s, opacity 0.3s, box-shadow 0.3s, transform 0.3s;
  position: relative;
}

.chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(var(--primary-rgb), 0.6);
}

.chat-toggle svg {
  width: 28px;
  height: 28px;
  fill: white;
}

.chat-toggle .unread-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ed4245;
  color: white;
  font-size: 12px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.chat-window {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 380px;
  max-height: 520px;
  background: rgba(14, 9, 24, 0.88);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1.5px solid rgba(168, 85, 247, 0.35);
  border-radius: var(--radius-xl, 24px);
  box-shadow: 
    0 20px 60px -10px rgba(0, 0, 0, 0.9),
    0 0 30px rgba(168, 85, 247, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.chat-window.open {
  display: flex;
  animation: chatSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes chatSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: rgba(18, 12, 30, 0.85);
  border-bottom: 1px solid rgba(168, 85, 247, 0.25);
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #ffffff;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.chat-header-title .online-dot {
  width: 9px;
  height: 9px;
  background: var(--accent, #18ec00);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent, #18ec00);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.3); }
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-expand {
  width: 30px;
  height: 30px;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: #c4b5fd;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.chat-expand:hover {
  background: rgba(168, 85, 247, 0.25);
  color: #ffffff;
  transform: scale(1.08);
}

.chat-expand svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.chat-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #72767d;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, fill 0.2s, stroke 0.2s, opacity 0.2s, box-shadow 0.2s, transform 0.2s;
}

.chat-close:hover {
  background: #2a2a3a;
  color: #fff;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 350px;
  min-height: 200px;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #3a3a4a;
  border-radius: 3px;
}

.chat-message {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  background: #12121a;
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
}

.chat-message:hover {
  background: #1e1e2a;
}

.chat-message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #5865f2;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-message-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.chat-message-avatar svg {
  width: 24px;
  height: 24px;
  fill: white;
}

.chat-message-content {
  flex: 1;
  min-width: 0;
}

.chat-message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.chat-message-username {
  font-weight: 600;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

.chat-message-username:hover {
  text-decoration: underline;
}

.chat-message-menu {
  opacity: 0;
  transition: opacity 0.2s;
}

.chat-message:hover .chat-message-menu {
  opacity: 1;
}

.chat-message-menu button {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: #72767d;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
}

.chat-message-menu button:hover {
  background: #ed4245;
  color: white;
}

.chat-message-text {
  color: #b9bbbe;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: break-word;
}

.chat-message-time {
  color: #72767d;
  font-size: 11px;
  margin-top: 4px;
  text-align: right;
}

.chat-input::placeholder {
  color: #72767d;
}

.chat-input:focus {
  border-color: var(--primary);
}

.chat-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.4);
}

.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chat-empty {
  text-align: center;
  padding: 40px 20px;
  color: #72767d;
}

.chat-login-required {
  text-align: center;
  padding: 30px 20px;
  color: #72767d;
}

.chat-login-required a {
  color: var(--primary);
  text-decoration: none;
}

.chat-login-required a:hover {
  text-decoration: underline;
}

/* Mobile */
@media (max-width: 480px) {
  .chat-window {
    width: calc(100vw - 40px);
    right: -10px;
    bottom: 65px;
    max-height: 70vh;
  }
  
  .chat-toggle {
    width: 50px;
    height: 50px;
  }
}


/* Mute notice */
.chat-muted-notice {
  padding: 12px 16px;
  background: rgba(237, 66, 69, 0.2);
  border-top: 1px solid rgba(237, 66, 69, 0.3);
  color: #ed4245;
  font-size: 13px;
  text-align: center;
}

/* Mute menu */
.mute-menu {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a25;
  border: 1px solid #2a2a3a;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 100;
  min-width: 180px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.mute-menu-header {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  padding-bottom: 8px;
  border-bottom: 1px solid #2a2a3a;
  margin-bottom: 4px;
}

.mute-menu button {
  padding: 8px 12px;
  background: #2a2a3a;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, fill 0.2s, stroke 0.2s, opacity 0.2s, box-shadow 0.2s, transform 0.2s;
}

.mute-menu button:hover {
  background: #3a3a4a;
}

.mute-menu .mute-permanent {
  background: rgba(237, 66, 69, 0.3);
  color: #ed4245;
}

.mute-menu .mute-permanent:hover {
  background: rgba(237, 66, 69, 0.5);
}

.mute-menu .mute-remove {
  background: rgba(var(--accent-rgb), 0.2);
  color: var(--accent);
}

.mute-menu .mute-remove:hover {
  background: rgba(var(--accent-rgb), 0.3);
}

.mute-menu .mute-cancel {
  background: transparent;
  color: #72767d;
}

.mute-menu .mute-cancel:hover {
  color: #fff;
}

/* Multiple buttons in message menu */
.chat-message-menu {
  display: flex;
  gap: 4px;
}

.chat-message-menu button {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: #72767d;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-message-menu button:hover {
  background: #2a2a3a;
  color: #fff;
}


/* ===== Media Upload ===== */
.chat-attach {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, fill 0.2s, stroke 0.2s, opacity 0.2s, box-shadow 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.chat-attach:hover {
  background: rgba(var(--primary-rgb), 0.2);
}

.chat-attach svg {
  width: 22px;
  height: 22px;
  fill: var(--primary);
}

.chat-upload-preview {
  padding: 8px 12px;
  background: #12121a;
  border-top: 1px solid #2a2a3a;
}

.upload-preview-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-file-name {
  color: #fff;
  font-size: 13px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-file-size {
  color: #72767d;
  font-size: 12px;
}

.upload-cancel {
  width: 24px;
  height: 24px;
  border: none;
  background: rgba(237, 66, 69, 0.3);
  color: #ed4245;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-cancel:hover {
  background: #ed4245;
  color: #fff;
}

.upload-progress {
  margin-top: 8px;
  height: 4px;
  background: #2a2a3a;
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  width: 0%;
  transition: width 0.2s;
}

/* ===== Media in Messages ===== */
.chat-media {
  margin-top: 8px;
  border-radius: 8px;
  overflow: hidden;
  max-width: 100%;
}

.chat-media img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}

.chat-media img:hover {
  transform: scale(1.02);
}

.chat-media video {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  background: #000;
}

.chat-media.chat-audio {
  background: #2a2a3a;
  padding: 10px;
  border-radius: 8px;
}

.chat-media audio {
  width: 100%;
  height: 36px;
}

/* Fix input container with attach button */
.chat-input-container {
  padding: 10px 12px;
  background: #12121a;
  border-top: 1px solid #2a2a3a;
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  background: #1a1a25;
  border: 1px solid #2a2a3a;
  border-radius: 18px;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.chat-send {
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border: none;
  border-radius: 18px;
  color: white;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, fill 0.2s, stroke 0.2s, opacity 0.2s, box-shadow 0.2s, transform 0.2s;
  white-space: nowrap;
}


/* Drag & Drop */
.chat-window.drag-over {
  border: 2px dashed var(--primary);
  background: rgba(var(--primary-rgb), 0.1);
}

.chat-window.drag-over::after {
  content: '📎 Отпустите для загрузки';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(var(--primary-rgb), 0.9);
  color: white;
  padding: 16px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  z-index: 10;
  pointer-events: none;
}


/* ===== Media Modal ===== */
.media-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  cursor: pointer;
}

.media-modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  cursor: default;
}

.media-modal-content img,
.media-modal-content video {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.media-modal-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 18px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, fill 0.2s, stroke 0.2s, opacity 0.2s, box-shadow 0.2s, transform 0.2s;
}

.media-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Position chat widget above the bottom nav bar on mobile screens */
@media (max-width: 768px) {
  .chat-widget {
    bottom: max(72px, calc(68px + env(safe-area-inset-bottom))) !important;
    right: 14px !important;
  }
  
  .chat-window {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 75vh !important;
    max-height: 85vh !important;
    border-radius: 20px 20px 0 0 !important;
    border-bottom: none !important;
    z-index: 10001 !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.75) !important;
  }

  .chat-header {
    border-radius: 20px 20px 0 0;
    padding: 12px 16px;
  }

  .chat-input-container {
    padding-bottom: max(12px, calc(10px + env(safe-area-inset-bottom))) !important;
  }
}

/* Highlight flash animation */
@keyframes highlightFlash {
  0% {
    background: rgba(var(--primary-rgb), 0.25) !important;
    box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.45) !important;
    border-color: rgba(var(--primary-rgb), 0.6) !important;
  }
  70% {
    background: rgba(var(--primary-rgb), 0.05) !important;
    box-shadow: 0 0 8px rgba(var(--primary-rgb), 0.15) !important;
  }
  100% {
    background: transparent;
    box-shadow: none;
  }
}
.highlight-flash {
  animation: highlightFlash 2s cubic-bezier(0.25, 1, 0.5, 1) !important;
  border-radius: 12px;
}

/* ============================================================
   CYBER-NEON GLASSMORPHISM OVERRIDES FOR CHAT WIDGET
   ============================================================ */
.chat-window {
  background: rgba(18, 9, 28, 0.35) !important;
  backdrop-filter: blur(20px) saturate(140%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(140%) !important;
  border: 1px solid rgba(var(--primary-rgb, 148, 0, 253), 0.22) !important;
  box-shadow: 0 10px 35px 0 rgba(0, 0, 0, 0.42), inset 0 1px 0 0 rgba(255, 255, 255, 0.06) !important;
}

.chat-header {
  background: rgba(18, 9, 28, 0.2) !important;
  border-bottom: 1px solid rgba(var(--primary-rgb, 148, 0, 253), 0.2) !important;
}

.chat-message {
  background: rgba(18, 9, 28, 0.2) !important;
  border: 1px solid rgba(255, 255, 255, 0.03) !important;
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

.chat-message:hover {
  background: rgba(24, 12, 36, 0.4) !important;
  border-color: rgba(var(--primary-rgb), 0.5) !important;
  box-shadow: 
    0 10px 25px rgba(0, 0, 0, 0.5),
    0 0 15px rgba(var(--primary-rgb), 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
  transform: translateY(-1px) scale(1.01) !important;
}

.chat-input-container {
  background: rgba(18, 9, 28, 0.2) !important;
  border-top: 1px solid rgba(var(--primary-rgb, 148, 0, 253), 0.2) !important;
}

.chat-input {
  background: rgba(18, 9, 28, 0.2) !important;
  border: 1px solid rgba(var(--primary-rgb, 148, 0, 253), 0.2) !important;
  color: #fff !important;
}

.chat-input:focus {
  border-color: var(--primary-light) !important;
  box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.3) !important;
}

.mute-menu {
  background: rgba(18, 9, 28, 0.95) !important;
  backdrop-filter: blur(25px) !important;
  border: 1px solid rgba(var(--primary-rgb, 148, 0, 253), 0.3) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6) !important;
}

.mute-menu button {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.mute-menu button:hover {
  background: rgba(var(--primary-rgb, 148, 0, 253), 0.2) !important;
  border-color: rgba(var(--primary-rgb, 148, 0, 253), 0.4) !important;
}

