/* DEFAULT: popup mode untuk desktop */
.chat-wrapper {
  position: relative;
  width: 350px;
  height: 500px;
  border-radius: 18px;
  overflow: hidden;
  background: #f0f2f5;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
}

/* KHUSUS HALAMAN /chat */
body.chat-page {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
}

body.chat-page .chat-wrapper {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  border-radius: 0;
  box-shadow: none;
}

body.chat-page .chat-sidebar,
body.chat-page .chat-container {
  height: 100dvh;
}

body.chat-page .chat-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.chat-popup-mode .chat-wrapper.guest .chat-back {
  display: none !important;
}

/* SCREEN BASE */
.chat-sidebar,
.chat-container {
  position: absolute;
  width: 100%;
  height: 100%;
  background: #fff;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* DEFAULT = LIST */
.chat-sidebar {
  transform: translateX(0);
  z-index: 2;
}

.chat-container {
  transform: translateX(100%);
  z-index: 3;
}

/* ACTIVE CHAT */
.chat-wrapper.active .chat-sidebar {
  transform: translateX(-100%);
}

.chat-wrapper.active .chat-container {
  transform: translateX(0);
}

/* ================= HEADER ================= */
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid #eee;
  background: #fff;
  font-weight: 600;
  font-size: 14px;
}

.chat-back {
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  color: #555;
}

/* ================= SIDEBAR ================= */
.chat-sidebar {
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 14px;
  font-weight: 600;
  font-size: 15px;
  border-bottom: 1px solid #eee;
  background: #fff;
}

.chat-room-list {
  flex: 1;
  overflow-y: auto;
  background: #f9fafb;
}

/* ROOM ITEM */
.chat-room {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f1f1;
  font-size: 13px;
  transition: all 0.2s ease;
}

.chat-room:hover {
  background: #eef2ff;
}

/* ================= CHAT BOX ================= */
.chat-container {
  display: flex;
  flex-direction: column;
}

/* PRODUCT BOX */
.chat-product {
  padding: 10px 14px;
  background: #f9fafb;
  border-bottom: 1px solid #eee;
}

.product-name {
  font-weight: 600;
  font-size: 13px;
}

.product-price {
  font-size: 12px;
  color: #777;
}

/* ================= BODY ================= */
.chat-body {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(to bottom, #f9fafb, #f1f5f9);
  overscroll-behavior: contain;
}

/* ================= MESSAGE ================= */
.chat-message {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

/* USER */
.chat-message.user {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* USER MODE = langsung tampil chat */
.chat-wrapper.guest .chat-container {
  transform: translateX(0);
}

/* DEFAULT: hidden */
.chat-wrapper.guest .chat-back {
  display: none;
}

/* ADMIN: selalu tampil */
.chat-wrapper.admin .chat-back {
  display: flex;
}

.chat-wrapper.guest .chat-sidebar {
  display: none;
}

/* ADMIN */
.chat-message.admin {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border: 1px solid #eee;
  border-bottom-left-radius: 4px;
}

/* ================= INPUT ================= */
.chat-input {
  display: flex;
  padding: 8px;
  gap: 8px;
  border-top: 1px solid #eee;
  background: #fff;
}

.chat-input input {
  flex: 1;
  border: none;
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
  background: #f1f5f9;
  border-radius: 10px;
}

.chat-input button {
  width: 42px;
  border: none;
  background: #2563eb;
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-input button:hover {
  background: #1d4ed8;
}

/* ================= EMPTY ================= */
.chat-empty {
  margin: auto 0;
  text-align: center;
  font-size: 13px;
  color: #888;
  padding: 20px;
}

/* ================= PRODUCT CARD ================= */
.chat-product-card {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #eee;
  margin-bottom: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chat-product-card img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
}

.chat-product-card .info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.chat-product-card .name {
  font-size: 12px;
  font-weight: 600;
}

.chat-product-card .price {
  font-size: 11px;
  color: #666;
}

.chat-product-draft {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #fff8f2;
  border-bottom: 1px solid #eee;
}

.chat-product-draft img {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
}

.chat-product-draft .info {
  flex: 1;
}

.chat-product-draft .name {
  font-size: 12px;
  font-weight: 600;
}

.chat-product-draft .price {
  font-size: 11px;
  color: #666;
}

.chat-product-draft button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
}

/* ================= SCROLLBAR (BIAR CLEAN) ================= */
.chat-body::-webkit-scrollbar,
.chat-room-list::-webkit-scrollbar {
  width: 5px;
}

.chat-body::-webkit-scrollbar-thumb,
.chat-room-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}

/* ================= MOBILE ================= */
@media (max-width: 768px) {
  .chat-wrapper {
    width: 100%;
    height: 100vh;
    border-radius: 0;
  }
  body.chat-page .chat-wrapper.guest .chat-back {
    display: flex;
  }
}
