/* /www/wwwroot/chat.webtui.vn/config/css.css */

:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --border: #e0e3ee;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
}

/* ===== Layout chung: header / main / footer ===== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo-wrap {
  flex: 0 0 auto;
}

.logo {
  max-height: 42px;
  width: auto;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  flex: 1 1 auto;
}

.header-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
}

.btn-header {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}

.btn-header:hover {
  border-color: var(--accent);
}

.site-main {
  max-width: 1200px;
  width: 100%;
  margin: 8px auto 24px;
  padding: 0 8px;
}

/* Cho màn to hơn thì cho phép rộng tới 1440px */
@media (min-width: 1440px) {
  .site-main {
    max-width: 1440px;
  }
  .header-inner {
    max-width: 1440px;
  }
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  background: #ffffff;
}

/* ===== Thông báo ===== */

.alert-error {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.alert-ok {
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 8px;
  margin-bottom: 10px;
}

/* ===== Login ===== */

.login-wrap {
  max-width: 360px;
  margin: 60px auto;
  padding: 20px 20px 24px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(15,23,42,0.08);
}

.login-wrap h1 {
  margin: 0 0 16px;
  font-size: 20px;
  text-align: center;
}

.login-wrap .field {
  margin-bottom: 12px;
}

.login-wrap label {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.login-wrap input[type="text"],
.login-wrap input[type="password"] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.login-wrap button {
  width: 100%;
  margin-top: 8px;
  padding: 9px 10px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.login-wrap button:hover {
  filter: brightness(1.05);
}

/* ===== Đổi mật khẩu ===== */

.cp-wrap {
  max-width: 420px;
  margin: 24px auto;
  padding: 20px 20px 24px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(15,23,42,0.08);
}

.cp-wrap h1 {
  margin: 0 0 16px;
  font-size: 18px;
}

.cp-wrap .field {
  margin-bottom: 12px;
}

.cp-wrap label {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.cp-wrap input[type="password"] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.cp-wrap button {
  padding: 9px 12px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

/* ===== Chat layout ===== */

.chat-wrap {
  display: flex;
  gap: 16px;
  height: calc(100vh - 140px);   /* full chiều cao còn lại trừ header/footer */
  align-items: stretch;
  overflow: hidden;              /* chỉ phần con được scroll */
}

.chat-left,
.chat-right {
  min-height: 0;                 /* để flex con có thể overflow: auto */
}

/* LEFT: danh sách nhóm */

.chat-left {
  width: 320px;
  max-width: 360px;
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.thread-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}

.thread-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;                /* scroll danh sách group riêng */
}

.thread-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(148,163,184,0.2);
  text-decoration: none;
  color: var(--text);
  background: #ffffff;
}

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

.thread-item.active {
  background: #e0edff;
}

.ti-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #e5e7eb;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

.ti-content {
  flex: 1 1 auto;
  min-width: 0;
}

.ti-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.ti-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ti-time {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.ti-role {
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 1px;
}

.ti-last {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* RIGHT: khung chat */

.chat-right {
  flex: 1 1 auto;
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kh-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.kh-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #e5e7eb;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.kh-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kh-right {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* Ghim_1 */

.pin-note {
  padding: 8px 14px;
  border-bottom: 1px dashed var(--border);
  background: #f1f5f9;
  font-size: 13px;
  color: var(--muted);
}

/* Vùng tin nhắn – scroll riêng */

.msgs {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;                /* chỉ phần tin nhắn scroll */
}

/* Bubbles */

.bubble {
  max-width: 72%;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(15,23,42,0.08);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  word-wrap: break-word;
}

.bubble.in {
  align-self: flex-start;
  background: #f8fafc;
}

.bubble.out {
  align-self: flex-end;
  background: #e0edff;
}

.bubble .meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.bubble .meta .role {
  font-weight: 600;
}

.bubble .text {
  white-space: pre-wrap;
}

/* Composer – ghim dưới khung chat */

.composer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f9fafb;
}

.composer textarea {
  flex: 1 1 auto;
  min-height: 40px;
  max-height: 120px;
  resize: vertical;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.composer button {
  flex: 0 0 auto;
  padding: 9px 12px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.composer button:hover {
  filter: brightness(1.05);
}

/* Thanh emoji */

.emoji-bar {
  border-top: 1px solid var(--border);
  padding: 6px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: #f9fafb;
}

.emoji-btn {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  padding: 3px 6px;
  cursor: pointer;
  font-size: 18px;
}

.emoji-btn:hover {
  background: #e5e7eb;
}

/* ===== Responsive cho điện thoại ===== */

@media (max-width: 768px) {
  .header-inner {
    padding: 8px 10px;
  }

  .site-main {
    margin-top: 8px;
    padding: 0 4px;
  }

  /* Khung chat chiếm gần full màn hình, scroll bên trong */
  .chat-wrap {
    flex-direction: column;
    height: calc(100vh - 130px);  /* trừ header + footer */
    overflow: hidden;
  }

  .chat-left {
    width: 100%;
    max-width: 100%;
    flex: 0 0 40%;               /* ~40% chiều cao cho danh sách nhóm */
    max-height: none;
  }

  .chat-right {
    width: 100%;
    max-width: 100%;
    flex: 1 1 auto;              /* phần còn lại cho khung chat */
    max-height: none;
  }

  .thread-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
  }

  .msgs {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
  }

  .bubble {
    max-width: 90%;
  }
}
