/**
 * MeNoGamer Live Chat Widget Styles
 * Professional, mobile-first, dark theme consistent with DaisyUI
 */

/* =========================================================================
   TRIGGER BUTTON
   ========================================================================= */
#mng-chat-trigger {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35), 0 2px 4px rgba(0,0,0,0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 9998;
}
#mng-chat-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.45), 0 2px 8px rgba(0,0,0,0.3);
}
#mng-chat-trigger:active { transform: scale(0.96); }

.mng-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}

/* =========================================================================
   CHAT WINDOW
   ========================================================================= */
#mng-chat-window {
  position: fixed;
  bottom: 88px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - 120px);
  border-radius: 16px;
  background: #1d1f27;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 12px 48px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  animation: mng-slide-up 0.25s ease-out;
}

.mng-hidden { display: none !important; }

@keyframes mng-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================================
   HEADER
   ========================================================================= */
#mng-chat-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, #1e1b4b, #312e81);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.mng-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mng-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a5b4fc;
  flex-shrink: 0;
}

.mng-header-title {
  font-size: 14px;
  font-weight: 600;
  color: #e0e7ff;
}

.mng-header-subtitle {
  font-size: 11px;
  color: #a5b4fc;
  margin-top: 1px;
}

.mng-header-actions {
  display: flex;
  gap: 4px;
}

.mng-header-actions button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: rgba(255,255,255,0.08);
  color: #c7d2fe;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.mng-header-actions button:hover {
  background: rgba(255,255,255,0.15);
}

/* =========================================================================
   BODY / MESSAGES
   ========================================================================= */
#mng-chat-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#mng-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

/* Scrollbar */
#mng-messages::-webkit-scrollbar { width: 4px; }
#mng-messages::-webkit-scrollbar-track { background: transparent; }
#mng-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* Message bubbles */
.mng-msg { display: flex; }
.mng-msg-visitor { justify-content: flex-end; }
.mng-msg-agent { justify-content: flex-start; }
.mng-msg-system { justify-content: center; }

.mng-msg-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.mng-msg-visitor .mng-msg-bubble {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #e0e7ff;
  border-bottom-right-radius: 4px;
}

.mng-msg-agent .mng-msg-bubble {
  background: #2a2d38;
  color: #d1d5db;
  border: 1px solid rgba(255,255,255,0.06);
  border-bottom-left-radius: 4px;
}

.mng-msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.6;
}

.mng-system-text {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  text-align: center;
  padding: 4px 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
}

.mng-msg-text code {
  background: rgba(255,255,255,0.1);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
}

.mng-msg-optimistic { opacity: 0.7; }

/* =========================================================================
   PRE-CHAT FORM
   ========================================================================= */
.mng-prechat-form {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  justify-content: center;
}

.mng-prechat-welcome {
  text-align: center;
  margin-bottom: 8px;
}

.mng-prechat-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  color: #e0e7ff;
}

.mng-prechat-welcome h3 {
  font-size: 18px;
  font-weight: 600;
  color: #e5e7eb;
  margin: 0 0 4px;
}

.mng-prechat-welcome p {
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  margin: 0;
}

.mng-prechat-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mng-prechat-fields input,
.mng-prechat-form textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: #2a2d38;
  color: #e5e7eb;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
  resize: none;
}

.mng-prechat-fields input:focus,
.mng-prechat-form textarea:focus {
  border-color: #6366f1;
}

.mng-prechat-fields input::placeholder,
.mng-prechat-form textarea::placeholder {
  color: rgba(255,255,255,0.3);
}

.mng-send-btn {
  width: 100%;
  padding: 11px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #e0e7ff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.mng-send-btn:hover { opacity: 0.9; }
.mng-send-btn:disabled { opacity: 0.5; cursor: default; }

/* =========================================================================
   FOOTER / INPUT
   ========================================================================= */
#mng-chat-footer {
  padding: 8px 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.mng-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#mng-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: #2a2d38;
  color: #e5e7eb;
  font-size: 13px;
  outline: none;
  resize: none;
  min-height: 36px;
  max-height: 80px;
  line-height: 1.4;
}
#mng-input:focus { border-color: #6366f1; }
#mng-input::placeholder { color: rgba(255,255,255,0.3); }

#mng-send {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: #6366f1;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
#mng-send:hover { background: #4f46e5; }

.mng-footer-meta {
  text-align: center;
  font-size: 10px;
  color: rgba(255,255,255,0.2);
  margin-top: 6px;
}

/* Typing indicator */
#mng-typing-indicator {
  display: flex;
  gap: 3px;
  padding: 4px 12px;
  align-items: center;
}

.mng-typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  animation: mng-typing 1.2s infinite;
}
.mng-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.mng-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes mng-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* =========================================================================
   RATING
   ========================================================================= */
#mng-rating {
  position: absolute;
  inset: 0;
  background: rgba(29, 31, 39, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.mng-rating-content {
  text-align: center;
}

.mng-rating-content p {
  font-size: 15px;
  font-weight: 600;
  color: #e5e7eb;
  margin: 0 0 16px;
}

.mng-stars {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 12px;
}

.mng-stars button {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  font-size: 28px;
  color: rgba(255,255,255,0.15);
  cursor: pointer;
  transition: color 0.15s, transform 0.15s;
}
.mng-stars button:hover,
.mng-stars button.active { color: #fbbf24; transform: scale(1.15); }

.mng-text-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
}
.mng-text-btn:hover { color: rgba(255,255,255,0.7); }

/* =========================================================================
   MOBILE RESPONSIVE
   ========================================================================= */
@media (max-width: 480px) {
  #mng-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  #mng-chat-trigger {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
  }
}

@media (max-width: 768px) and (min-width: 481px) {
  #mng-chat-window {
    width: 340px;
    height: 480px;
    bottom: 80px;
    right: 12px;
  }
}

/* =========================================================================
   DARK MODE ADJUSTMENTS (if page uses light theme)
   ========================================================================= */
@media (prefers-color-scheme: light) {
  /* Widget stays dark regardless of page theme */
  #mng-chat-window { background: #1d1f27; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  #mng-chat-window { animation: none; }
  .mng-typing-dot { animation: none; opacity: 0.5; }
  #mng-chat-trigger { transition: none; }
}
