:root{
  --navy-950: #f4f9ff;
  --navy-900: #e4effa;
  --navy-800: #d0e3f5;
  --navy-700: #bce0fd;
  --ice-500: #35b7ff;
  --ice-300: #00509e;
  --text: #061827;
  --muted: #555555;
  --card: #ffffff;
  --card-2: #f9f9f9;
  --stroke: #cce6ff;
  --shadow: 0 4px 15px rgba(0,0,0,0.05);
  --radius: 18px;
  --radius-sm: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

.bubble ul, .bubble ol { margin-top: 6px; margin-bottom: 6px; padding-left: 20px; }
.bubble li { margin-bottom: 4px; }

.bubble p { margin: 0 0 8px 0; }
.bubble ul, .bubble ol { margin: 4px 0 8px 0; padding-left: 20px; }
.bubble li { margin-bottom: 4px; }
.bubble > *:last-child { margin-bottom: 0; }


*{box-sizing:border-box}

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

body{
  display:flex;
  justify-content:center;
  font-family:var(--font);
  color:#061827;
  background:
    radial-gradient(1200px 800px at 20% 10%, rgba(53,183,255,.18), transparent 60%),
    radial-gradient(1200px 800px at 90% 30%, rgba(138,217,255,.10), transparent 55%),
    linear-gradient(180deg, var(--navy-950), var(--navy-900));
}

.page{
  width:100%;
  max-width:1200px;
  height:100%;
  display:flex;
  flex-direction:column;
  padding:0;
  margin:0;
}

.shell{
  flex:1;
  width:100%;
  height:100%;
  background:#ffffff;
  border:none;
  border-radius:0;
  box-shadow:none;
  overflow:hidden;
  backdrop-filter: blur(10px);
  display:flex;
  flex-direction:column;
}

.topbar{
  padding:16px 18px;
  display:flex;
  flex-direction:row;
  align-items:center;
  justify-content:space-between;
  flex-wrap:nowrap;
  gap:10px;
  border-bottom:1px solid var(--stroke);
  background:#ffffff;
}

/* Desktop header layout: single row */
.header-main{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}

.header-meta{
  display:flex;
  align-items:center;
  gap:10px;
}

.brand{display:flex; gap:12px; align-items:center; min-width:0}
.brand__logo{
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 10px;
  flex: 0 0 auto;
}
.brand__text{min-width:0}
.brand__name{font-weight:700; letter-spacing:.2px; white-space:nowrap}
.brand__sub{font-size:12px; color:var(--muted); margin-top:2px}

.meta{display:flex; gap:10px; align-items:center; flex-wrap:wrap; justify-content:flex-end}
.meta__pill{
  font-size:12px;
  color:var(--muted);
  border:1px solid var(--stroke);
  padding:7px 10px;
  border-radius:999px;
  background:rgba(255,255,255,.04);
}

.chat{flex:1; display:flex; flex-direction:column; min-height:0; position:relative}
.messages{
  flex:1;
  overflow:auto;
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.msg{display:flex; align-items:flex-end; gap:10px; max-width:100%}
.msg--user{justify-content:flex-end}
.msg--bot{justify-content:flex-start}

.bubble{
  width: fit-content;
  max-width: 100%;
  padding:12px 14px;
  border-radius:16px;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.06);
  color:var(--text);
  line-height:1.45;
  white-space:pre-wrap;
  word-wrap:break-word;
}

.badge-source {
  user-select: none; -webkit-user-select: none; pointer-events: none;
  display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 800;
  padding: 2px 6px; border-radius: 4px; vertical-align: middle; opacity: 0.8;
}
.badge-cache { color: #f1c40f; background: rgba(241, 196, 15, 0.15); }
.badge-gemini { color: #3498db; background: rgba(52, 152, 219, 0.15); }
.badge-openai { color: #2ecc71; background: rgba(46, 204, 113, 0.15); }

.msg--user .bubble {
  background: #ebf5ff;
  border-color: #cce6ff;
  color: #061827;
}

.msg--bot .bubble {
  background: #ffffff;
  border-color: #e1ecf4;
  color: #061827;
}

.avatar{
  width:36px; height:36px;
  border-radius:50%;
  border:2px solid var(--ice-500);
  background:var(--navy-800);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  flex:0 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.avatar__img{
  width:100%;
  height:100%;
  object-fit:cover;
}

.avatar__svg{
  width: 20px;
  height: 20px;
  display: block;
  color: var(--ice-300);
}

.msg--user .avatar__svg{
  color: var(--muted);
}

.bubble-wrapper{
  position:relative;
  display:flex;
  flex-direction:column;
  width: fit-content;
  max-width:min(720px, 85%);
}

.msg--user .bubble-wrapper{align-items:flex-end}
.msg--bot .bubble-wrapper{align-items:flex-start}

.bubble__copy{
  position:absolute;
  bottom:-22px;
  right:0;
  background:transparent;
  border:none;
  color:var(--muted);
  cursor:pointer;
  padding:4px;
  display:flex;
  align-items:center;
  justify-content:center;
  opacity:0.4;
  transition:opacity 0.2s, color 0.2s;
}

.msg:hover .bubble__copy{opacity:1; color:var(--ice-300)}

.toast{
  position:fixed;
  bottom:100px;
  left:50%;
  transform:translateX(-50%) translateY(20px);
  background:rgba(11,34,56,0.95);
  color:var(--ice-300);
  padding:10px 20px;
  border-radius:20px;
  border:1px solid var(--ice-500);
  font-size:14px;
  font-weight:600;
  z-index:9999;
  opacity:0;
  pointer-events:none;
  transition:all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast--show{
  opacity:1;
  transform:translateX(-50%) translateY(0);
}

.composer{
  padding:14px;
  border-top: 1px solid #cce6ff;
  display:flex;
  gap:10px;
  align-items:center;
  background: #f4f9ff;
}

.composer__input{
  flex:1;
  width:100%;
  max-width:none;
  resize:none;
  border-radius:var(--radius-sm);
  border:1px solid #bce0fd;
  background:#f0f7ff;
  color:#061827;
  padding:14px 16px;
  outline:none;
  font-size:15px;
  min-height:48px;
  max-height:140px;
}

.composer__send{
  height:48px;
  padding:0 20px;
  border-radius:var(--radius-sm);
  border:1px solid rgba(53,183,255,.40);
  background:linear-gradient(180deg, rgba(53,183,255,.35), rgba(53,183,255,.18));
  color:var(--text);
  cursor:pointer;
  font-weight:700;
  font-size:15px;
  flex:0 0 auto;
}
.composer__image{
  height:48px;
  width:48px;
  padding:0;
  border-radius:var(--radius-sm);
  border:1px solid rgba(53,183,255,.40);
  background:linear-gradient(180deg, rgba(53,183,255,.35), rgba(53,183,255,.18));
  color:var(--text);
  cursor:pointer;
  font-size:20px;
  flex:0 0 auto;
  display:flex;
  align-items:center;
  justify-content:center;
}
.composer__image:hover{
  background:linear-gradient(180deg, rgba(53,183,255,.50), rgba(53,183,255,.30));
}
.image-preview-container{
  position:relative;
  display:inline-block;
  margin-bottom:8px;
}
.image-preview-container[hidden]{
  display:none !important;
}
.image-preview{
  max-width: 180px;
  max-height: 140px;
  border-radius: var(--radius-sm);
  border: 1px solid #bce0fd;
  object-fit: contain;
  background: #ffffff;
}
.group-preview-wrap {
  align-self: flex-end;
  margin-bottom: 0;
  margin-right: 10px;
}
.group-preview-img {
  max-height: 100px;
}
.image-preview-remove{
  position:absolute;
  top:-8px;
  right:-8px;
  width:20px;
  height:20px;
  border-radius:50%;
  background:#ff4444;
  color:white;
  border:none;
  cursor:pointer;
  font-size:12px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.typing{
  display:inline-flex;
  gap:4px;
  align-items:center;
  padding:4px 0;
}
.dot{
  width:6px; height:6px; border-radius:50%;
  background: rgba(6, 24, 39, 0.7);
  animation: bounce 1.2s infinite ease-in-out;
}
.dot:nth-child(2){animation-delay:.2s}
.dot:nth-child(3){animation-delay:.4s}
@keyframes bounce{
  0%, 60%, 100% {transform: translateY(0)}
  30% {transform: translateY(-6px)}
}

/* =========================================================
   🚀 BẢN CẬP NHẬT GIAO DIỆN ADMIN 3D HIỆN ĐẠI (SaaS UI)
   ========================================================= */

.admin {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  display: none;
  flex-direction: column;
  padding: 14px;
  gap: 12px;
  z-index: 9999;
  color: #061827;
  /* Glassmorphism */
  background: rgba(240, 247, 255, 0.85) !important;
  backdrop-filter: blur(20px) saturate(160%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(160%) !important;
}
.admin.is-open { display: flex; }

.admin__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.admin__title {
  font-weight: 900;
  letter-spacing: .2px;
  font-size: 18px;
  color: #061827;
}

/* Nút Back 3D */
.admin__back {
  padding: 10px 14px;
  cursor: pointer;
  background: linear-gradient(135deg, #0056b3 0%, #00a8ff 100%) !important;
  border: none !important;
  color: white !important;
  border-radius: 12px !important;
  box-shadow: 0 6px 15px rgba(0, 168, 255, 0.3), inset 0 -3px 0 rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  transform: translateY(0);
  font-weight: 700 !important;
  letter-spacing: 0.3px;
}
.admin__back:hover {
  box-shadow: 0 8px 20px rgba(0, 168, 255, 0.4), inset 0 -3px 0 rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
  transform: translateY(-2px) !important;
}
.admin__back:active {
  transform: translateY(2px) !important;
  box-shadow: 0 2px 5px rgba(0, 168, 255, 0.3), inset 0 2px 0 rgba(0, 0, 0, 0.1) !important;
}

/* Các khối Card 3D */
.admin__auth, .admin__section {
  background: linear-gradient(145deg, #ffffff, #fbfdff) !important;
  border: 1px solid rgba(255, 255, 255, 0.9) !important;
  box-shadow: 0 10px 30px rgba(0, 80, 158, 0.05), 0 4px 6px rgba(0, 80, 158, 0.02), inset 0 2px 0 rgba(255, 255, 255, 1) !important;
  border-radius: 16px !important;
  transition: all 0.3s ease;
  padding: 12px;
  color: #061827;
}
.admin__section {
  flex: 1;
  overflow: auto;
}

.admin__btn-small {
  background: transparent;
  border: none;
  color: #00509e;
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-weight: bold;
}
.admin__btn-small:hover { color: #d35400; }

#adminAuthControls.is-hidden,
.admin__password.is-hidden,
.admin__hint.is-hidden {
  display: none !important;
}

.admin__hint { margin-top: 6px; font-size: 12px; color: #555555; font-weight: 600; }
.admin__label { font-size: 12px; color: #555555; font-weight: 600; }
.admin__password { margin-top: 6px; display: flex; gap: 10px; align-items: center; }

/* Ô nhập liệu 3D chìm */
.admin__input, .admin__file, .admin__select {
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02) !important;
  border-radius: 12px !important;
  transition: all 0.2s ease !important;
  color: #0f172a !important;
}
.admin__input {
  flex: 1;
  height: 52px;
  padding: 0 16px;
  outline: none;
  font-size: 16px;
  margin-bottom: 8px;
}
.admin__select {
  height: 44px;
  padding: 0 12px;
  outline: none;
}
.admin__input:focus, .admin__select:focus {
  background: #ffffff !important;
  border-color: #00a8ff !important;
  box-shadow: 0 0 0 4px rgba(0, 168, 255, 0.15), inset 0 1px 2px rgba(0,0,0,0.01) !important;
  outline: none !important;
}
.admin__eye {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid #bce0fd;
  background: #ffffff;
  color: #555555;
  cursor: pointer;
}

/* Tabs viên thuốc 3D */
.admin__tabs {
  gap: 10px !important;
  padding: 4px;
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center;
}
.admin__tab {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 2px 5px rgba(0,0,0,0.02) !important;
  color: #64748b !important;
  border-radius: 999px !important;
  padding: 10px 16px !important;
  transition: all 0.25s ease !important;
  font-weight: 700 !important;
  font-size: 12px;
  cursor: pointer;
}
.admin__tab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0,0,0,0.08) !important;
  color: #00509e !important;
}
.admin__tab--active {
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 6px 15px rgba(15, 23, 42, 0.25) !important;
  transform: scale(1.02);
}

.guide-select-wrapper {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.guide-label {
  color: #555555;
  font-size: 13px;
  font-weight: 600;
}
#guideSelect {
  width: auto;
  max-width: 250px;
}
#guideSelect option, .admin__select option {
  color: #c0392b;
  background-color: #ffffff;
  font-weight: 600;
}

.admin__section[data-admin-section="guides"] {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

#guideFrame,
.admin__guide-frame {
  width: 100%;
  height: 100%;
  flex: 1;
  border: none;
  border-radius: 0 0 14px 14px;
  background: #ffffff;
}

.admin__form { display: flex; flex-direction: column; gap: 12px; }
.admin__field { display: flex; flex-direction: column; gap: 8px; }

.admin__file {
  border: 1px dashed #35b7ff !important;
  background: #f4f9ff !important;
  padding: 10px;
}
.admin__filename { font-size: 12px; color: #00509e; font-weight: bold; }

/* Nút Submit chính 3D */
.admin__btn {
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  background: linear-gradient(135deg, #0056b3 0%, #00a8ff 100%) !important;
  border: none !important;
  color: white !important;
  border-radius: 12px !important;
  box-shadow: 0 6px 15px rgba(0, 168, 255, 0.3), inset 0 -3px 0 rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  transform: translateY(0);
  font-weight: 900 !important;
  letter-spacing: 0.3px;
}
.admin__btn[disabled] { opacity: .6; cursor: not-allowed; }
.admin__btn:hover {
  box-shadow: 0 8px 20px rgba(0, 168, 255, 0.4), inset 0 -3px 0 rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
  transform: translateY(-2px) !important;
}
.admin__btn:active {
  transform: translateY(2px) !important;
  box-shadow: 0 2px 5px rgba(0, 168, 255, 0.3), inset 0 2px 0 rgba(0, 0, 0, 0.1) !important;
}

.admin__spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(234, 242, 255, 0.25);
  border-top-color: rgba(234, 242, 255, 0.85);
  display: none;
  animation: spin 0.9s linear infinite;
}
.admin__btn.is-loading .admin__spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg) } }

.admin__result {
  font-size: 13px;
  color: #061827;
  border: 1px solid #bce0fd;
  background: #f4f9ff;
  border-radius: 12px;
  padding: 10px;
}

/* Bảng dữ liệu tối ưu ngang Mobile */
.admin__tableWrap {
  border-radius: 12px !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04) !important;
  border: 1px solid #e2e8f0 !important;
  overflow-x: auto !important;
  background: #ffffff !important;
}
.admin__table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  color: #061827;
  border: none !important;
  margin: 0 !important;
}
.admin__table th,
.admin__table td {
  padding: 10px 12px;
  font-size: 12px;
}
.admin__table th {
  background: #f8fafc !important;
  color: #475569 !important;
  font-weight: 800 !important;
  text-transform: uppercase;
  font-size: 11px !important;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e2e8f0 !important;
  text-align: left;
}
.admin__table td {
  border-bottom: 1px solid #f1f5f9 !important;
  color: #334155 !important;
}
.admin__table tr:last-child td { border-bottom: none; }

/* Nút xóa 3D */
.admin__danger {
  background: linear-gradient(135deg, #e74c3c 0%, #ff7675 100%) !important;
  box-shadow: 0 5px 15px rgba(231, 76, 60, 0.25), inset 0 -3px 0 rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
  border: none !important;
  border-radius: 8px !important;
  color: white !important;
  font-weight: 700 !important;
  transition: all 0.2s ease !important;
  padding: 8px 10px;
  cursor: pointer;
}
.admin__danger:active {
  transform: translateY(2px) !important;
  box-shadow: 0 2px 5px rgba(231, 76, 60, 0.3), inset 0 2px 0 rgba(0, 0, 0, 0.1) !important;
}

.admin__code {
  margin: 0;
  padding: 12px;
  border-radius: 14px;
  background: #f4f9ff;
  border: 1px solid #bce0fd;
  overflow: auto;
  color: #061827;
  font-size: 12px;
}

/* --- LOGIN OVERLAY LỘT XÁC --- */
.login-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
  z-index: 10000;
}
.login-overlay.is-hidden { display: none; }
.login-card {
  width: min(460px, 100%);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 25px 50px rgba(0, 51, 102, 0.15);
  padding: 40px 30px;
  backdrop-filter: blur(20px);
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.login-logo {
  width: 100px; height: 100px;
  object-fit: contain;
  border-radius: 20px;
  margin-bottom: 15px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
.login-title { font-weight: 900; letter-spacing: 0.5px; font-size: 28px; color: var(--secondary); }
.login-welcome { margin-top: 8px; color: var(--primary); font-size: 15px; font-weight: 600; line-height: 1.4; }
.login-sub { margin-top: 5px; color: #64748b; font-size: 14px; margin-bottom: 25px; }
.login-form { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.login-input {
  width: 100%; height: 56px;
  border-radius: 14px;
  border: 2px solid #e2e8f0; background: #f8fafc;
  color: #1e293b; padding: 0 20px; font-size: 16px; outline: none;
  transition: all 0.3s;
}
.login-input:focus { border-color: var(--primary); background: #ffffff; box-shadow: 0 0 0 4px rgba(188, 0, 45, 0.1); }
.login-password-wrapper { position: relative; width: 100%; }
.login-eye {
  position: absolute; right: 15px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; font-size: 20px; color: #94a3b8;
  cursor: pointer; padding: 5px; transition: color 0.2s;
}
.login-eye:hover { color: var(--primary); }
.login-btn {
  height: 56px; border-radius: 14px; margin-top: 10px;
  border: none; background: #BC002D;
  color: #ffffff; font-weight: 800; font-size: 18px; cursor: pointer;
  box-shadow: 0 10px 20px rgba(188, 0, 45, 0.3); transition: all 0.2s;
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 15px 25px rgba(188, 0, 45, 0.4); }
.login-error { margin-top: 15px; color: #ef4444; font-size: 14px; font-weight: 600; min-height: 20px; }
.login-footer {
  margin-top: 30px; font-size: 13px; color: #64748b;
  border-top: 1px solid #e2e8f0; padding-top: 15px; width: 100%; line-height: 1.6;
}
.login-footer b { color: var(--secondary); }

/* Mobile Group Chat - Responsive */
@media (max-width: 768px) {
  .group-chat-container {
    flex-direction: column !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
  }
  .group-chat-sidebar {
    width: 100% !important;
    min-width: 100% !important;
    height: auto !important;
    border-right: none !important;
    border-bottom: 1px solid #cce6ff !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .chat-sidebar-header {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 10px 15px !important;
  }
  .btn-new-channel {
    margin: 0 !important;
    padding: 8px 12px !important;
  }
  .chat-channel-list {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    padding: 5px 15px 10px 15px !important;
    gap: 10px !important;
  }
  .chat-channel-item {
    display: inline-block !important;
    margin: 0 !important;
    border: 1px solid #bce0fd;
  }
  .group-chat-main {
    flex: 1 !important;
    width: 100% !important;
    min-width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    height: 0 !important; /* Ép cuộn tin nhắn ở thẻ con */
  }
  .group-chat-messages {
    padding: 10px !important;
  }
  .group-msg {
    max-width: 90% !important;
  }
  .group-chat-input-area {
    padding: 10px !important;
  }
  /* Phình to ô gõ AI trên Mobile */
  .composer__input:focus {
    max-height: 40vh !important;
  }
  /* Phình to ô gõ Group Chat trên Mobile */
  .group-chat-input-area textarea:focus {
    max-height: 40vh !important;
  }
  .group-chat-input-area {
    align-items: flex-end !important;
  }
}

/* Mặc định: Ẩn nút chỉ dành cho Mobile trên màn hình máy tính */
.mobile-only {
  display: none !important;
}

@media (max-width:640px){
  .page{padding:0}
  .shell{height:100%; width:100%; border-radius:0; border:none}

  /* Keep existing 2-line mobile header rules */
  .topbar {
    padding: 10px 14px;
    flex-direction: column; /* Quan trọng: Đổi thành xếp dọc để không bị nén */
    align-items: stretch;
    height: auto;
    gap: 10px;
  }
  .header-main{
    display:flex;
    justify-content:space-between;
    align-items:center;
    width:100%;
    gap:10px;
  }
  .header-meta{
    display:flex;
    gap:5px;
    margin-top:5px;
    font-size:10px;
    width:100%;
    justify-content:flex-end;
  }
  .meta__pill{font-size:10px; padding:5px 8px}

  .brand__logo{width:28px; height:28px}
  .brand__name{font-size:14px}

  .messages{padding:14px}
  .bubble-wrapper{max-width:90%}
  .bubble{padding:10px 14px; font-size:15px}
  .avatar{width:32px; height:32px}
  .composer{padding:10px; gap:8px}
  .bubble__copy{opacity:0.6; bottom:-20px}

  .admin{position:fixed; inset:0; padding:14px; z-index:9999}
  .admin__guide-frame{height:calc(100vh - 220px)}

  .login-form{flex-direction:column}
  .login-btn{width:100%}

  /* Hiện lại nút trên màn hình Mobile */
  .mobile-only {
    display: flex !important;
  }
}
/* Ép ẩn tuyệt đối các section và kết quả rỗng */
.admin__section[hidden] {
  display: none !important;
}
#adminUploadResult:empty {
  display: none !important;
  padding: 0 !important;
  border: none !important;
}

/* Role switch divider in chat */
.role-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 20px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.role-divider::before, .role-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--stroke);
}
.role-divider span {
  padding: 0 15px;
  color: var(--ice-300);
}

/* Bảng HTML cho AI Chat */
.bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
  display: block;
  overflow-x: auto; /* Tạo thanh cuộn ngang chống vỡ layout */
  white-space: normal; /* Reset lại để text trong bảng không bị lỗi pre-wrap */
  font-size: 13px;
}
.bubble th, .bubble td {
  border: 1px solid #cce6ff;
  padding: 10px 14px;
  text-align: left;
}
.bubble th {
  background: #ebf5ff;
  color: #061827;
  font-weight: bold;
  white-space: nowrap;
}
.bubble tr:nth-child(even) {
  background: #f7fbff;
}

/* --- ADMIN LOG VIEWER --- */
.admin__log-container { background: #ffffff; border: 1px solid #cce6ff; border-radius: 14px; padding: 15px; margin-top: 15px; color: #061827; }
.admin__log-content { max-height: 400px; overflow-y: auto; background: #f4f9ff; border-radius: 8px; padding: 10px; border: 1px solid #e1ecf4; }
.log-msg { margin-bottom: 12px; font-size: 13px; line-height: 1.4; padding: 10px; border-radius: 8px; word-break: break-word; color: #061827; }
.log-msg--user { background: #ebf5ff; border-left: 4px solid #35b7ff; }
.log-msg--assistant { background: #ffffff; border-left: 4px solid #b9c8de; border: 1px solid #e1ecf4; }

/* --- GROUP CHAT INTERNAL --- */
.btn-group-chat {
  background: linear-gradient(180deg, rgba(46, 204, 113, 0.35), rgba(46, 204, 113, 0.18));
  border: 1px solid rgba(46, 204, 113, 0.5);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 14px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.btn-group-chat:hover {
  background: linear-gradient(180deg, rgba(46, 204, 113, 0.5), rgba(46, 204, 113, 0.3));
}
.chat-badge {
  background: #ff4444;
  color: white;
  font-size: 11px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.chat-badge[hidden] {
  display: none;
}

.group-chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.group-chat-overlay[hidden] {
  display: none;
}
.group-chat-container {
  background: #ffffff;
  border-radius: 12px;
  width: 95vw;
  height: 90vh;
  max-width: 1400px;
  display: flex;
  flex-direction: row;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

/* Sidebar - Danh sách kênh */
.group-chat-sidebar {
  width: 250px;
  min-width: 250px;
  background: #f4f9ff;
  border-right: 1px solid #cce6ff;
  display: flex;
  flex-direction: column;
}
.chat-sidebar-header {
  padding: 15px;
  border-bottom: 1px solid #cce6ff;
  background: linear-gradient(180deg, #e8f4fc, #d4ebf7);
}
.chat-sidebar-header h4 {
  margin: 0 0 10px 0;
  color: #061827;
  font-size: 14px;
}
.chat-channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}
.chat-channel-item {
  padding: 10px 12px;
  margin-bottom: 5px;
  border-radius: 8px;
  cursor: pointer;
  color: #061827;
  font-size: 14px;
  transition: background 0.2s;
}
.chat-channel-item:hover {
  background: #e1f0ff;
}
.chat-channel-item.active {
  background: #35b7ff;
  color: white;
}
.chat-channel-item .channel-icon {
  margin-right: 8px;
}

/* Nút xóa kênh (Admin only) */
.chat-channel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.channel-delete-btn {
  background: transparent;
  border: none;
  color: #ff4444;
  opacity: 0.4;
  cursor: pointer;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 4px;
  transition: 0.2s;
}
.channel-delete-btn:hover {
  background: rgba(255, 0, 0, 0.1);
  opacity: 1;
}

.btn-new-channel {
  margin: 10px 15px;
  padding: 10px;
  background: #35b7ff;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.btn-new-channel:hover {
  background: #2196f3;
}

/* Main Chat Area */
.group-chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.group-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: linear-gradient(180deg, #f4f9ff, #e8f4fc);
  border-bottom: 1px solid #cce6ff;
}
.group-chat-header h3 {
  margin: 0;
  color: #061827;
  font-size: 18px;
}
.group-chat-header button {
  background: #ff6b6b;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.group-chat-header button:hover {
  background: #ee5a5a;
}
.group-chat-filters {
  display: flex;
  gap: 10px;
  padding: 10px 20px;
  background: #f7fbff;
  border-bottom: 1px solid #e1ecf4;
}
.group-chat-filters input {
  padding: 6px 10px;
  border: 1px solid #bce0fd;
  border-radius: 4px;
  font-size: 13px;
}
.group-chat-filters input[type="text"] {
  flex: 1;
}
.group-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px 20px;
  background: #f4f9ff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.group-msg {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
  word-break: break-word;
}
.group-msg--other {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #e1ecf4;
  color: #061827;
  border-bottom-left-radius: 4px;
}
.group-msg--self {
  align-self: flex-end;
  background: #35b7ff;
  color: white;
  border-bottom-right-radius: 4px;
}
.group-msg__content img {
  max-width: 200px;
  border-radius: 8px;
  margin-top: 8px;
  border: 1px solid #cce6ff;
}
.group-msg__content {
  word-wrap: break-word;
}
.group-msg__meta {
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.group-msg__delete {
  background: transparent;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
}
.group-msg__delete:hover {
  opacity: 1;
  background: rgba(255, 0, 0, 0.2);
}
.group-chat-input-area {
  display: flex;
  gap: 10px;
  padding: 15px 20px;
  background: #ffffff;
  border-top: 1px solid #cce6ff;
}
.group-chat-input-area textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #bce0fd;
  border-radius: 8px;
  resize: none;
  font-size: 14px;
  font-family: inherit;
  min-height: 44px;
  max-height: 100px;
}
.group-chat-input-area textarea:focus {
  outline: none;
  border-color: #35b7ff;
}
.group-chat-input-area button {
  background: linear-gradient(180deg, rgba(46, 204, 113, 0.35), rgba(46, 204, 113, 0.18));
  border: 1px solid rgba(46, 204, 113, 0.5);
  color: #061827;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.group-chat-input-area button:hover {
  background: linear-gradient(180deg, rgba(46, 204, 113, 0.5), rgba(46, 204, 113, 0.3));
}