* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b0b0f;
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  color: #111827;
  background: #f3f4f6;
}

/* Top bar */
.topbar {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: #111827;
  color: #e5e7eb;
  font-size: 14px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-circle {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #22c55e;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.paid-tag {
  background: #0f172a;
  color: #facc15;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  border: 1px solid #facc15;
}

.main {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* Sidebar left */
.sidebar {
  width: 360px;
  border-right: 1px solid #e5e7eb;
  background: #ffffff;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 12px 12px 8px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.chat-search {
  margin: 0 12px 8px;
  position: relative;
}

.chat-search input {
  width: 100%;
  padding: 6px 8px 6px 26px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  font-size: 12px;
  outline: none;
}

.chat-search i {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: #9ca3af;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 10px;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.chat-item:hover {
  background: #f3f4f6;
}

.chat-item.active {
  background: #e5f2ff;
  border-left-color: #2563eb;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
}

.chat-meta {
  flex: 1;
  min-width: 0;
}

.chat-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

.chat-preview {
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-time {
  font-size: 10px;
  color: #9ca3af;
}

/* Chat area center */
.chat-area {
  flex: 1.6;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e5e7eb;
  background: #f9fafb;
}

.chat-area-header {
  height: 48px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: #ffffff;
}

.chat-area-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-area-title h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.chat-area-actions button {
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 4px;
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  margin-left: 4px;
}

.chat-area-actions button:hover {
  background: #e5e7eb;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  background: #e5e7eb;
  background-image: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.5),
    rgba(219, 234, 254, 0.2)
  );
}

.date-separator {
  text-align: center;
  font-size: 11px;
  color: #6b7280;
  margin: 8px 0 12px;
}

.bubble-row {
  display: flex;
  margin-bottom: 8px;
}

.bubble-row.customer {
  justify-content: flex-start;
}

.bubble-row.shop {
  justify-content: flex-end;
}

.message-bubble {
  max-width: 70%;
  padding: 6px 10px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.4;
  position: relative;
  white-space: pre-line;
}

.bubble-customer {
  background: #ffffff;
  border-radius: 16px 16px 16px 4px;
  border: 1px solid #e5e7eb;
}

.bubble-shop {
  background: #4f46e5;
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
}

.message-meta {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 2px;
  text-align: right;
}

.typing-indicator {
  display: inline-flex;
  gap: 2px;
  align-items: center;
  font-size: 11px;
  color: #6b7280;
  margin-top: 4px;
}

.typing-indicator span {
  width: 4px;
  height: 4px;
  background: #9ca3af;
  border-radius: 50%;
  animation: blink 1s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.chat-input {
  padding: 8px 12px;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
}

.chat-input-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  padding: 4px 8px;
  background: #f9fafb;
}

.chat-input textarea {
  flex: 1;
  border: none;
  resize: none;
  outline: none;
  font-size: 13px;
  background: transparent;
  height: 28px;
  padding: 4px 0;
}

.chat-input button {
  border-radius: 999px;
  border: none;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: #22c55e;
  color: #ffffff;
}

.chat-input button:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Right panel */
.info-panel {
  width: 280px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
}

.info-header {
  padding: 10px 14px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.profile-section {
  padding: 16px 16px 8px;
  border-bottom: 1px solid #e5e7eb;
}

.profile-main {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
}

.profile-name {
  font-size: 15px;
  font-weight: 600;
}

.profile-tags {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}

.profile-buttons {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.profile-buttons button {
  flex: 1;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  cursor: pointer;
}

.profile-buttons button:hover {
  background: #e5e7eb;
}

.note-section {
  padding: 10px 14px 16px;
  font-size: 12px;
}

.note-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-weight: 600;
}

.note-box {
  border: 1px dashed #d1d5db;
  border-radius: 6px;
  background: #f9fafb;
  padding: 8px;
  font-size: 11px;
  color: #4b5563;
  min-height: 60px;
}

.note-box span {
  display: block;
  margin-bottom: 4px;
}

/* จุดเล็ก ๆ บอกว่าแชทยังมีสคริปต์ที่ยังไม่เล่น (ยังไม่ตอบ) */
.unreplied-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 4px;
  border-radius: 999px;
  background: #f97316; /* ส้ม ๆ ให้เห็นบนเวทีง่าย */
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Simple responsive: stack panels on small screens */
@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  .info-panel {
    display: none;
  }
  .chat-area {
    flex: 1;
  }
}
