/* ═══════════════════════════════════════════
   MMO Chat Widget — มุมล่างขวา
═══════════════════════════════════════════ */

.mmo-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9800;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #3D0000;
  background: linear-gradient(135deg, #C8892E, #F0D080);
  box-shadow: 0 6px 24px rgba(200,137,46,.45), 0 0 0 4px rgba(240,208,96,.15);
  transition: transform .25s, box-shadow .25s;
}
.mmo-chat-launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 8px 28px rgba(200,137,46,.55), 0 0 0 5px rgba(240,208,96,.22);
}
.mmo-chat-launcher.open {
  transform: rotate(0deg) scale(1);
  background: linear-gradient(135deg, #4A1010, #2A0005);
  color: #F0D060;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
.mmo-chat-launcher.open i.fa-comments { display: none; }
.mmo-chat-launcher:not(.open) i.fa-times { display: none; }

.mmo-chat-launcher-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(240,208,96,.5);
  animation: mmoChatPulse 2.2s ease-out infinite;
  pointer-events: none;
}
.mmo-chat-launcher.open .mmo-chat-launcher-pulse { display: none; }

@keyframes mmoChatPulse {
  0%   { transform: scale(1); opacity: .7; }
  100% { transform: scale(1.35); opacity: 0; }
}

.mmo-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #C62828;
  color: #fff;
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.mmo-chat-launcher.open .mmo-chat-badge { display: none; }

/* Panel */
.mmo-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 94px;
  z-index: 9799;
  width: min(360px, calc(100vw - 32px));
  max-height: min(520px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(165deg, #1A0005 0%, #2A0810 100%);
  border: 1px solid rgba(212,160,64,.35);
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(.96);
  transform-origin: bottom right;
  transition: opacity .28s, transform .28s, visibility .28s;
}
.mmo-chat-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.mmo-chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(200,137,46,.25), rgba(240,208,96,.08));
  border-bottom: 1px solid rgba(212,160,64,.25);
}
.mmo-chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #1C0004;
  border: 2px solid rgba(240,208,96,.5);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mmo-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.mmo-chat-head-text h4 {
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #FFF0D2;
  margin: 0 0 2px;
}
.mmo-chat-head-text p {
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  color: rgba(255,240,210,.55);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.mmo-chat-online {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4CAF50;
  box-shadow: 0 0 6px rgba(76,175,80,.6);
}

.mmo-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.mmo-chat-msg {
  max-width: 88%;
  padding: 11px 14px;
  border-radius: 14px 14px 14px 4px;
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  line-height: 1.55;
  color: rgba(255,255,255,.92);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(212,160,64,.18);
  opacity: 0;
  transform: translateY(8px);
  animation: mmoChatMsgIn .35s ease forwards;
}
.mmo-chat-msg.user {
  align-self: flex-end;
  border-radius: 14px 14px 4px 14px;
  background: linear-gradient(135deg, rgba(200,137,46,.35), rgba(240,208,96,.15));
  border-color: rgba(212,160,64,.3);
  color: #FFF8E8;
}
.mmo-chat-msg:nth-child(1) { animation-delay: .1s; }
.mmo-chat-msg:nth-child(2) { animation-delay: .35s; }
.mmo-chat-msg:nth-child(3) { animation-delay: .6s; }

@keyframes mmoChatMsgIn {
  to { opacity: 1; transform: translateY(0); }
}

.mmo-chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  align-self: flex-start;
  background: rgba(255,255,255,.06);
  border-radius: 14px;
  border: 1px solid rgba(212,160,64,.15);
}
.mmo-chat-typing.hidden { display: none; }
.mmo-chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(240,208,96,.6);
  animation: mmoChatDot 1.2s ease-in-out infinite;
}
.mmo-chat-typing span:nth-child(2) { animation-delay: .15s; }
.mmo-chat-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes mmoChatDot {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.mmo-chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}
.mmo-chat-chip {
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid rgba(212,160,64,.35);
  background: rgba(255,255,255,.06);
  color: rgba(255,240,210,.9);
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mmo-chat-chip:hover {
  background: rgba(212,160,64,.18);
  border-color: rgba(212,160,64,.55);
  color: #FFF0D2;
}
.mmo-chat-chip.line {
  background: rgba(6,199,85,.15);
  border-color: rgba(6,199,85,.4);
  color: #B8F5CE;
}
.mmo-chat-chip.line:hover { background: rgba(6,199,85,.28); }

.mmo-chat-foot {
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(212,160,64,.2);
  background: rgba(0,0,0,.2);
}
.mmo-chat-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}
.mmo-chat-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 22px;
  border: 1px solid rgba(212,160,64,.3);
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.9);
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  outline: none;
}
.mmo-chat-input::placeholder { color: rgba(255,240,210,.35); }
.mmo-chat-send {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  background: linear-gradient(135deg, #C8892E, #F0D080);
  color: #3D0000;
  font-size: 15px;
  transition: transform .2s;
}
.mmo-chat-send:hover { transform: scale(1.08); }
.mmo-chat-foot-note {
  margin-top: 8px;
  font-family: 'Prompt', sans-serif;
  font-size: 10px;
  color: rgba(255,240,210,.4);
  text-align: center;
}

@media (max-width: 640px) {
  .mmo-chat-launcher {
    right: 16px;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    width: 52px;
    height: 52px;
    font-size: 22px;
  }
  .mmo-chat-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: calc(140px + env(safe-area-inset-bottom, 0px));
    max-height: min(460px, calc(100vh - 180px));
  }
}
