/* ===== Chat Widget (Visitor) ===== */

.chat-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 50%;
  padding: 0 5px;
  display: none;
  pointer-events: none;
}
.chat-badge.visible {
  display: block;
}


/* Chat Panel */
.chat-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  z-index: 10000;
  overflow: hidden;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.chat-panel.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: #6A5773;
  color: #fff;
}
.chat-panel__header-title {
  font-weight: 600;
  font-size: 15px;
}
.chat-panel__header-sub {
  font-size: 12px;
  opacity: 0.85;
}
.chat-panel__close {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.chat-panel__close:hover {
  opacity: 1;
}

.chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 260px;
  max-height: 340px;
  background: #f8f9fa;
}

.chat-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}
.chat-msg--visitor {
  align-self: flex-end;
  background: #6A5773;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg--admin {
  align-self: flex-start;
  background: #e9ecef;
  color: #333;
  border-bottom-left-radius: 4px;
}
.chat-msg__time {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
}

.chat-panel__closed-notice {
  padding: 12px 18px;
  text-align: center;
  font-size: 13px;
  color: #888;
  background: #f0f0f0;
}

.chat-panel__input-area {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid #e9ecef;
  gap: 8px;
  background: #fff;
}
.chat-panel__input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
}
.chat-panel__input:focus {
  border-color: #A294AB;
}
.chat-panel__send {
  background: #6A5773;
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.chat-panel__send:hover {
  opacity: 0.85;
}
.chat-panel__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Welcome state */
.chat-panel__welcome {
  text-align: center;
  padding: 30px 20px;
  color: #666;
}
.chat-panel__welcome i {
  font-size: 40px;
  color: #A294AB;
  margin-bottom: 12px;
}
.chat-panel__welcome p {
  font-size: 14px;
  line-height: 1.5;
}

/* Mobile */
@media (max-width: 480px) {
  .chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
  .chat-panel__messages {
    max-height: none;
    flex: 1;
  }
}

/* ===== Admin Chat Dashboard ===== */

.achat {
  display: flex;
  height: calc(100vh - 48px);
  font-family: 'Segoe UI', Roboto, -apple-system, sans-serif;
  background: #f0f2f5;
}

/* Sidebar */
.achat__sidebar {
  width: 340px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.achat__tabs {
  display: flex;
  border-bottom: 1px solid #e0e0e0;
}
.achat__tab {
  flex: 1;
  padding: 14px 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: none;
  color: #666;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.achat__tab.active {
  color: #A294AB;
  border-bottom-color: #A294AB;
}
.achat__tab:hover {
  background: #f8f9fa;
}

.achat__list {
  flex: 1;
  overflow-y: auto;
}
.achat__item {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
  gap: 12px;
}
.achat__item:hover {
  background: #f8f9fa;
}
.achat__item.active {
  background: #e8f8f5;
}
.achat__item-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #6A5773;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}
.achat__item-body {
  flex: 1;
  min-width: 0;
}
.achat__item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}
.achat__item-name {
  font-weight: 600;
  font-size: 14px;
  color: #333;
}
.achat__item-time {
  font-size: 11px;
  color: #999;
  flex-shrink: 0;
}
.achat__item-preview {
  font-size: 13px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.achat__item-unread {
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 50%;
  padding: 0 5px;
  flex-shrink: 0;
}
.achat__empty {
  padding: 40px 20px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

/* Main chat area */
.achat__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.achat__main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}
.achat__main-title {
  font-weight: 600;
  font-size: 16px;
  color: #333;
}
.achat__main-actions {
  display: flex;
  gap: 8px;
}
.achat__btn {
  padding: 7px 16px;
  border: 1px solid #ddd;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: #fff;
  color: #555;
  transition: all 0.2s;
}
.achat__btn:hover {
  background: #f0f0f0;
}
.achat__btn--danger {
  color: #e74c3c;
  border-color: #e74c3c;
}
.achat__btn--danger:hover {
  background: #fdf0ef;
}

.achat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8f9fa;
}

.achat__msg {
  max-width: 65%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}
.achat__msg--visitor {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border: 1px solid #e0e0e0;
  border-bottom-left-radius: 4px;
}
.achat__msg--admin {
  align-self: flex-end;
  background: #6A5773;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.achat__msg-time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
}

.achat__reply {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  border-top: 1px solid #e0e0e0;
  gap: 10px;
  background: #fff;
}
.achat__reply-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 10px 18px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
}
.achat__reply-input:focus {
  border-color: #A294AB;
}
.achat__reply-send {
  background: #6A5773;
  border: none;
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.achat__reply-send:hover {
  opacity: 0.85;
}

.achat__placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 15px;
}
