/* ===== Chat Page Layout ===== */

.chat-page-body {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg, #FAF7F2);
  font-family: 'Noto Sans SC', sans-serif;
  display: flex;
  flex-direction: column;
}

/* ── Navbar ── */
.chat-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--bg-card, #FFFBF5);
  border-bottom: 1px solid var(--border, #E8DFD0);
  flex-shrink: 0;
  z-index: 100;
}

.chat-nav-logo {
  color: var(--text, #2C2416);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  transition: opacity 0.2s;
}

.chat-nav-logo:hover {
  opacity: 0.7;
}

.chat-nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted, #6B5E4A);
}

.chat-nav-user img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

/* ── Chat Layout (Sidebar + Main) ── */
.chat-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ── */
.chat-sidebar {
  width: 320px;
  min-width: 280px;
  border-right: 1px solid var(--border, #E8DFD0);
  background: var(--bg-card, #FFFBF5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
  flex-shrink: 0;
}

.chat-sidebar-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text, #2C2416);
}

.chat-sidebar-count {
  font-size: 0.75rem;
  color: var(--text-muted, #6B5E4A);
  background: var(--bg, #FAF7F2);
  padding: 2px 10px;
  border-radius: 12px;
}

.chat-sidebar-search {
  padding: 0 18px 12px;
  flex-shrink: 0;
}

.chat-sidebar-search input {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--border, #E8DFD0);
  border-radius: 10px;
  font-size: 0.85rem;
  background: var(--bg, #FAF7F2);
  color: var(--text, #2C2416);
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.chat-sidebar-search input:focus {
  border-color: var(--accent, #E8A850);
}

/* ── User List ── */
.chat-user-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.chat-user-list-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted, #6B5E4A);
  font-size: 0.9rem;
}

.chat-user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin: 2px 0;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-user-item:hover {
  background: var(--bg, #FAF7F2);
}

.chat-user-item.active {
  background: rgba(232, 168, 80, 0.12);
}

.chat-user-item-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent, #E8A850);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
  overflow: hidden;
}

.chat-user-item-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-user-item-info {
  flex: 1;
  min-width: 0;
}

.chat-user-item-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text, #2C2416);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-user-item-email {
  font-size: 0.75rem;
  color: var(--text-muted, #6B5E4A);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-user-item-badge {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 8px;
  flex-shrink: 0;
}

.chat-user-item-badge.plan-a {
  background: #E8F0FE;
  color: #1A73E8;
}

.chat-user-item-badge.plan-b {
  background: #FCE8E6;
  color: #E84855;
}

/* ── Main Chat Area ── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg, #FAF7F2);
}

.chat-main-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted, #6B5E4A);
  padding: 40px;
  text-align: center;
}

.chat-main-empty-icon {
  font-size: 52px;
  margin-bottom: 8px;
  opacity: 0.6;
}

.chat-main-empty h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text, #2C2416);
  font-weight: 600;
}

.chat-main-empty p {
  margin: 0;
  font-size: 0.9rem;
}

/* ── Active Chat Panel (in-page) ── */
.chat-panel-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-card, #FFFBF5);
}

.chat-panel-page.hidden {
  display: none;
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
  .chat-sidebar {
    position: absolute;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    z-index: 50;
    transform: translateX(-100%);
  }

  .chat-sidebar.open {
    transform: translateX(0);
  }

  .chat-main {
    width: 100%;
  }

  /* Mobile toggle button */
  .chat-mobile-toggle {
    display: flex !important;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent, #E8A850);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(44, 36, 22, 0.18);
    z-index: 60;
    align-items: center;
    justify-content: center;
    font-size: 20px;
  }
}

@media (min-width: 769px) {
  .chat-mobile-toggle {
    display: none;
  }
}
