/* ═══════════════════════════════════════════════════════════════════════════
   MANXACOINS — Chat Styles
   ═══════════════════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════
   CUSTOMER WIDGET
   ══════════════════════════════════════════ */

.chat-bubble {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 1000;
  width: 52px;
  height: 52px;
  background: var(--pink);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(232, 67, 147, .3);
  cursor: pointer;
  transition: .2s ease;
  border: none;
  color: #fff;
}
.chat-bubble:hover { filter: brightness(1.1); }

.chat-bubble__badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 4px;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.chat-bubble__badge.visible { display: flex; }

/* Chat window */
.chat-window {
  position: fixed;
  bottom: 88px;
  left: 24px;
  width: 355px;
  height: 490px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  display: flex;
  flex-direction: column;
  z-index: 999;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: .22s ease;
  overflow: hidden;
}
.chat-window.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
.chat-win-header {
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  flex-shrink: 0;
}
.chat-win-avatar {
  width: 32px;
  height: 32px;
  background: var(--pink);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}
.chat-win-info { flex: 1; min-width: 0; }
.chat-win-name   { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-win-status { font-size: 11px; color: var(--green); margin-top: 1px; }
.chat-win-close {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
  font-size: 16px;
  transition: .15s;
  flex-shrink: 0;
}
.chat-win-close:hover { background: var(--bg4); color: var(--text); }

/* Entry form */
.chat-entry {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 22px 20px;
  gap: 10px;
}
.chat-entry__logo {
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 2px;
  letter-spacing: 1px;
}
.chat-entry__sub {
  font-size: 12px;
  color: var(--text3);
  text-align: center;
  margin-bottom: 4px;
}
.chat-entry input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: 13px;
  transition: .15s;
}
.chat-entry input:focus    { outline: none; border-color: var(--pink-border); }
.chat-entry input.input-error { border-color: var(--red); }
.chat-entry__btn {
  width: 100%;
  padding: 11px;
  background: var(--pink);
  color: #fff;
  border-radius: var(--r);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .4px;
  transition: .15s;
  margin-top: 4px;
}
.chat-entry__btn:hover    { filter: brightness(1.1); }
.chat-entry__btn:disabled { opacity: .5; cursor: not-allowed; }

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 13px 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--bg5); border-radius: 2px; }

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}
.chat-msg--user  { align-self: flex-end;  align-items: flex-end; }
.chat-msg--admin { align-self: flex-start; align-items: flex-start; }

.chat-msg__bubble {
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}
.chat-msg--user  .chat-msg__bubble {
  background: var(--pink);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg--admin .chat-msg__bubble {
  background: var(--bg4);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-msg__time {
  font-size: 10px;
  color: var(--text3);
  margin-top: 3px;
  padding: 0 3px;
}

.chat-sys-msg {
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  padding: 3px 0;
  font-style: italic;
}

/* Input bar */
.chat-input-bar {
  padding: 9px 11px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 7px;
  align-items: flex-end;
  background: var(--bg3);
  flex-shrink: 0;
}
.chat-input-bar textarea {
  flex: 1;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  resize: none;
  height: 36px;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color .15s;
  overflow-y: auto;
}
.chat-input-bar textarea:focus { outline: none; border-color: var(--pink-border); }
.chat-send-btn {
  width: 36px;
  height: 36px;
  background: var(--pink);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: .15s;
  color: #fff;
}
.chat-send-btn:hover    { filter: brightness(1.1); }
.chat-send-btn:disabled { opacity: .35; cursor: not-allowed; }

/* Typing indicator */
.chat-typing {
  padding: 3px 13px 5px;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.chat-typing__text {
  font-size: 11px;
  color: var(--text3);
  font-style: italic;
}
.chat-typing__dots {
  display: flex;
  gap: 3px;
  align-items: center;
}
.chat-typing__dots span {
  width: 4px;
  height: 4px;
  background: var(--text3);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}
.chat-typing__dots span:nth-child(2) { animation-delay: .2s; }
.chat-typing__dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30%            { transform: translateY(-4px); opacity: 1; }
}

/* ══════════════════════════════════════════
   MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
  .chat-bubble { bottom: 16px; left: 14px; width: 48px; height: 48px; }
  .chat-window {
    left: 10px; right: 10px;
    width: auto;
    bottom: 74px;
    height: calc(100svh - 96px);
    max-height: 520px;
    border-radius: var(--r-xl);
  }
  .chat-entry   { padding: 18px 14px; gap: 9px; }
  .chat-input-bar { padding: 8px 10px; }
}


/* ══════════════════════════════════════════
   ADMIN CHAT PANEL
   ══════════════════════════════════════════ */

.admin-nav__badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  display: none;
  line-height: 1.2;
}
.admin-nav__badge.visible { display: inline-block; }

#sec-chats { overflow: hidden; }

.chat-admin-layout {
  display: flex;
  gap: 16px;
  height: calc(100vh - 152px);
}

/* Left: conversation list */
.chat-list-panel {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-list-panel__header {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.chat-list-panel__count { font-size: 11px; color: var(--text3); font-weight: 400; }

.chat-list { overflow-y: auto; flex: 1; }
.chat-list::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-thumb { background: var(--bg5); border-radius: 2px; }

.chat-list-item {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.chat-list-item:hover  { background: var(--bg3); }
.chat-list-item.active { background: var(--pink-glow); border-left: 2px solid var(--pink); padding-left: 14px; }

.chat-list-item__name {
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-list-item__time  { font-size: 10px; color: var(--text3); flex-shrink: 0; }
.chat-list-item__phone { font-size: 11px; color: var(--text3); margin-top: 2px; }
.chat-list-item__row   { display: flex; align-items: center; gap: 7px; margin-top: 4px; }
.chat-list-item__last  { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.chat-list-item__unread {
  background: var(--pink);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  display: none;
  flex-shrink: 0;
}
.chat-list-item__unread.visible { display: inline-block; }

.chat-list-empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}

/* Right: active conversation */
.chat-convo-panel {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.chat-convo-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text3);
  font-size: 13px;
}

/* Convo header */
.chat-convo-header {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  flex-shrink: 0;
}
.chat-convo-avatar {
  width: 34px;
  height: 34px;
  background: var(--pink);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}
.chat-convo-header-info    { flex: 1; min-width: 0; }
.chat-convo-header-name    { font-weight: 700; font-size: 14px; }
.chat-convo-header-phone   { font-size: 12px; color: var(--text3); }
.chat-convo-header-actions { display: flex; gap: 7px; flex-shrink: 0; }
.chat-convo-hbtn {
  padding: 6px 12px;
  border-radius: var(--r);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text2);
  transition: .15s;
}
.chat-convo-hbtn:hover           { background: var(--bg4); color: var(--text); border-color: var(--border-h); }
.chat-convo-hbtn--danger         { border-color: rgba(245, 95, 95, .25); color: var(--red); }
.chat-convo-hbtn--danger:hover   { background: rgba(245, 95, 95, .08); }

/* Messages */
.chat-convo-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-convo-messages::-webkit-scrollbar { width: 4px; }
.chat-convo-messages::-webkit-scrollbar-thumb { background: var(--bg5); border-radius: 2px; }

/* Reply bar */
.chat-convo-input-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 9px;
  align-items: flex-end;
  background: var(--bg3);
  flex-shrink: 0;
}
.chat-convo-input-bar textarea {
  flex: 1;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: 14px;
  padding: 9px 12px;
  resize: none;
  height: 40px;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color .15s;
  overflow-y: auto;
}
.chat-convo-input-bar textarea:focus { outline: none; border-color: var(--pink-border); }
.chat-convo-send {
  padding: 9px 18px;
  background: var(--pink);
  color: #fff;
  border-radius: var(--r);
  font-weight: 700;
  font-size: 13px;
  transition: .15s;
  flex-shrink: 0;
  height: 40px;
}
.chat-convo-send:hover    { filter: brightness(1.1); }
.chat-convo-send:disabled { opacity: .4; cursor: not-allowed; }

/* Reuse chat-msg styles for admin panel */
.chat-msg--user .chat-msg__bubble  { background: var(--pink); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg--admin .chat-msg__bubble { background: var(--bg4);  color: var(--text); border-bottom-left-radius: 4px; }
.chat-sys-msg { text-align: center; font-size: 11px; color: var(--text3); padding: 3px 0; font-style: italic; }
