#app[hidden],
#login[hidden],
#thread[hidden],
#empty[hidden],
#monitoring[hidden] {
  display: none !important;
}

/* Header, công cụ, tin nhắn, trả lời nhanh và ô soạn là 5 hàng riêng. */
.conversation > #thread {
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
}

/* Giao diện gọn để dùng thoải mái khi Hộp thư được mở trong portal. */
.conversation {
  padding: 8px;
  min-height: 0;
  overflow: hidden;
}

.conversation > #thread {
  border-radius: 12px;
  min-height: 0;
}

.conversation header {
  padding: 10px 16px;
}

.avatar {
  width: 34px;
  height: 34px;
}

.conversation header strong {
  font-size: 14px;
}

#conversation-tools {
  padding: 7px 16px;
  gap: 6px;
}

#conversation-tools input,
#conversation-tools select,
#save-tools {
  height: 32px;
}

#save-tools {
  padding: 0 13px;
}

#messages {
  padding: 14px clamp(14px, 3vw, 36px);
}

#quick-replies {
  padding: 6px 16px;
}

#reply-form {
  align-items: flex-end;
  padding: 9px 16px;
}

#reply {
  height: 54px;
  min-height: 54px;
  max-height: 96px;
}

#reply-form button {
  width: 42px;
  height: 42px;
}

@media (max-width: 900px) {
  .conversation {
    padding: 0;
  }

  .conversation > #thread {
    border-radius: 0;
  }
}

@media (max-height: 650px) {
  #conversation-tools {
    grid-template-columns: repeat(5, minmax(112px, 1fr));
    overflow-x: auto;
  }

  #conversation-tools label,
  #save-tools {
    min-width: 112px;
  }

  #quick-replies {
    min-height: 40px;
  }
}

/* ===== Giao diện Hộp thư chuyên nghiệp, rõ ràng ===== */
:root {
  --inbox-primary: #2563eb;
  --inbox-primary-dark: #1d4ed8;
  --inbox-ink: #172033;
  --inbox-muted: #64748b;
  --inbox-line: #dce5f0;
  --inbox-surface: #ffffff;
  --inbox-canvas: #f3f6fb;
}

#app {
  grid-template-columns: 350px minmax(0, 1fr);
  color: var(--inbox-ink);
  background: var(--inbox-canvas);
}

aside {
  background: #fff;
  border-right-color: var(--inbox-line);
  scrollbar-color: #cbd5e1 transparent;
  scrollbar-width: thin;
}

.brand {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 14px 16px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
}

.brand > div {
  font-size: 15px;
}

#admin-nav {
  padding: 10px;
}

#admin-nav button {
  min-height: 40px;
  padding: 10px 12px;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

.inbox-label {
  padding: 17px 15px 8px;
  color: #64748b;
}

#site-inboxes {
  margin: 0 8px 8px;
  padding: 9px;
  border: 1px solid #e0e7f0;
  border-radius: 12px;
  background: #f8fafc;
}

.site-inboxes-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 3px 7px;
  color: #42536a;
}

.site-inboxes-title span {
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.site-inboxes-title small {
  color: #8290a3;
  font-size: 10px;
}

.site-inbox-list {
  display: grid;
  gap: 5px;
  max-height: 180px;
  overflow-y: auto;
  scrollbar-color: #cbd5e1 transparent;
  scrollbar-width: thin;
}

.site-inbox {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #35455a;
  text-align: left;
  box-shadow: none;
}

.site-inbox:hover {
  transform: none;
  border-color: #d5e0ee;
  background: #fff;
  box-shadow: none;
}

.site-inbox.active {
  border-color: #b9d0ff;
  background: #eaf2ff;
  color: #1d4ed8;
}

.site-inbox > i {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #fff;
  color: #2563eb;
  font-size: 13px;
  font-style: normal;
}

.site-inbox.active > i {
  background: #2563eb;
  color: #fff;
}

.site-inbox > span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.site-inbox b,
.site-inbox small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-inbox b {
  font-size: 11.5px;
}

.site-inbox small {
  color: #7b8ba1;
  font-size: 9.5px;
  font-weight: 600;
}

.site-inbox em {
  min-width: 22px;
  padding: 3px 6px;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-size: 9.5px;
  font-style: normal;
  text-align: center;
}

#chat-list {
  padding: 4px 8px 190px;
}

.chat {
  margin: 6px 0;
  padding: 12px 13px;
  border: 1px solid transparent;
  border-radius: 12px;
}

.chat:hover {
  border-color: #d9e4f2;
  background: #f8fafc;
}

.chat.active {
  border-color: #a9c6ff;
  background: #eef4ff;
  box-shadow: inset 3px 0 0 var(--inbox-primary);
}

.chat strong {
  color: #1e293b;
  font-size: 14px;
  line-height: 1.35;
}

.chat small {
  margin-top: 6px;
  color: #65758b;
  font-size: 12px;
  line-height: 1.4;
}

.chat-meta {
  margin-top: 8px;
  color: #7b8ba1;
  font-size: 10.5px;
}

.priority {
  padding: 3px 7px;
  border-radius: 6px;
  background: #e8f0ff;
  color: #315da8;
  font-weight: 700;
}

.conversation {
  background: var(--inbox-canvas);
}

.conversation > #thread {
  width: 100%;
  max-width: 1180px;
  border-color: #dbe4ef;
  background: #fff;
  box-shadow: 0 10px 30px rgba(35, 55, 85, .08);
}

.conversation header {
  min-height: 58px;
  border-bottom-color: var(--inbox-line);
  background: #fff;
}

.avatar {
  color: #1d4ed8;
  background: #e8f0ff;
}

.conversation header strong {
  color: #162033;
  font-size: 15px;
}

.conversation header span {
  max-width: 520px;
  color: #68778c;
  font-size: 11.5px;
}

.ai-switch {
  color: #475569;
  font-size: 12px;
  font-weight: 750;
}

#conversation-tools {
  border-bottom-color: var(--inbox-line);
  background: #f8fafc;
}

#conversation-tools label > span {
  margin-bottom: 5px;
  color: #53657a;
  font-size: 10.5px;
  letter-spacing: .01em;
}

#conversation-tools input,
#conversation-tools select {
  border-color: #cfdbea;
  background: #fff;
  color: #27364a;
  font-size: 12.5px;
}

#conversation-tools input:focus,
#conversation-tools select:focus {
  border-color: #7aa7ff;
  outline: 3px solid #dbeafe;
}

#save-tools {
  background: var(--inbox-primary);
  color: #fff;
  font-size: 12px;
}

#save-tools:hover {
  background: var(--inbox-primary-dark);
}

#messages {
  gap: 14px;
  background: #f4f7fb;
  scrollbar-color: #cbd5e1 transparent;
  scrollbar-width: thin;
}

.visitor-journey {
  margin-bottom: 10px;
  padding: 13px 15px;
  border-color: #d8e3ef;
  border-radius: 12px;
  box-shadow: 0 3px 12px rgba(31, 55, 85, .05);
}

.current-page span {
  color: #51647c;
  font-size: 10.5px;
}

.current-page strong {
  margin-top: 2px;
  color: #172033;
  font-size: 13.5px;
}

.current-page a {
  margin-top: 2px;
  font-size: 11.5px;
}

.current-page > b {
  background: #edf4ff;
  color: #1d4ed8;
}

.message {
  max-width: min(72%, 680px);
  padding: 11px 14px;
  border-radius: 13px;
  color: #243247;
  font-size: 14px;
  line-height: 1.55;
}

.message.visitor {
  border: 1px solid #d9e3ef;
  background: #fff;
  box-shadow: 0 3px 10px rgba(23, 49, 80, .06);
}

.message.agent,
.message.ai {
  border: 1px solid #255ddd;
  background: #2563eb;
  box-shadow: 0 5px 14px rgba(37, 99, 235, .2);
}

.message.ai {
  border-color: #4f46e5;
  background: #4f46e5;
}

.message small {
  margin-top: 5px;
  font-size: 10.5px;
  opacity: .76;
}

#quick-replies {
  border-top-color: var(--inbox-line);
  background: #fff;
}

#quick-replies > span {
  color: #51647c;
  font-weight: 750;
}

#quick-replies button {
  border-color: #cfdbeb;
  background: #f8fafc;
  color: #334e70;
  font-size: 11.5px;
}

#reply-form {
  border-top-color: var(--inbox-line);
  background: #fff;
  box-shadow: 0 -6px 18px rgba(30, 50, 80, .04);
}

#reply {
  border-color: #cbd8e8;
  background: #f8fafc;
  color: #1e293b;
  font-size: 13.5px;
  line-height: 1.45;
}

#reply::placeholder {
  color: #7b8ba1;
}

#reply-form button {
  background: var(--inbox-primary);
  box-shadow: 0 5px 12px rgba(37, 99, 235, .25);
}

#reply-form button:hover {
  background: var(--inbox-primary-dark);
}

@media (max-width: 900px) {
  #app {
    grid-template-columns: 290px minmax(0, 1fr);
  }

  .message {
    max-width: 84%;
  }
}

/* Không để hộp website che danh sách hội thoại bên dưới. */
#site-inboxes {
  max-height: none;
  overflow: visible;
}

.site-inbox-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: none;
  overflow: visible;
  gap: 5px;
}

.site-inbox {
  grid-template-columns: 22px minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 38px;
  padding: 5px 6px;
  gap: 5px;
}

.site-inbox > i {
  width: 22px;
  height: 22px;
  font-size: 11px;
}

.site-inbox b {
  font-size: 10.5px;
}

.site-inbox small {
  font-size: 9px;
}

.site-inbox em {
  min-width: 18px;
  padding: 2px 4px;
  font-size: 9px;
}

#chat-list {
  position: relative;
  z-index: 1;
  min-height: 0;
}

#conversation-tools {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

#conversation-tools label,
#save-tools {
  min-width: 0;
}

@media (max-width: 700px) {
  .site-inbox-list {
    grid-template-columns: 1fr;
  }

  #conversation-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Tách vùng danh sách thư khỏi các thẻ thống kê, không để nội dung bị đè. */
aside {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#chat-list {
  flex: 0 0 260px;
  height: 260px;
  min-height: 260px;
  overflow-y: auto;
  padding-bottom: 16px;
}

#inbox-tools {
  position: relative;
  z-index: 2;
  flex: 0 1 150px;
  max-height: 150px;
  overflow-y: auto;
}

#site-inboxes {
  flex: 0 0 auto;
  max-height: 135px;
  overflow: hidden;
}

#site-inboxes .site-inbox-list {
  max-height: 92px;
  overflow-y: auto;
}
