:root{
  --bg: #f7f7f8;          /* nền ChatGPT */
  --card: #ffffff;
  --stroke: #e5e7eb;

  --text: #1f2937;
  --muted: #6b7280;

  --brand: #4143d8;       /* màu xanh ChatGPT */

  --shadow: 0 4px 12px rgba(0,0,0,0.04);

  --radius: 16px;
}

html, body{ height:100%; }

body{
  margin:0;
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.wrap{
  max-width: 980px;
  margin: 0 auto;
  padding: 14px;
  min-height: 100dvh;
  display:flex;
  flex-direction:column;
  gap: 12px;
}

/* ===== topbar ===== */
.topbar{
  background: #ffffff;
  border: 1px solid var(--stroke);
  box-shadow: none;
  border-radius: 12px;
}

.topbar__left{ display:flex; align-items:center; gap: 12px; min-width: 0; }
.topbar__avatar{
  background: var(--brand);
  box-shadow: none;
}
.topbar__title{ font-weight: 800; letter-spacing: .2px; line-height: 1.1; }
.topbar__sub{ font-size: 12px; color: var(--muted); display:flex; align-items:center; gap: 8px; }
.dot{ width:8px; height:8px; border-radius:999px; background:#22c55e; box-shadow:0 0 0 4px rgba(34,197,94,.16); }

.topbar__actions{ display:inline-flex; gap: 10px; align-items:center; }
.clear-top{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke-strong);
  background: rgba(255,255,255,.9);
  color: var(--text);
  cursor:pointer;
  font-size: 13px;
  line-height: 1;
}
.clear-top .ico{ width: 16px; height: 16px; fill: currentColor; opacity: .85; }
.clear-top:active{ transform: translateY(1px); }

.scroll-bottom{
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.85);
  color: var(--text);
  display:grid;
  place-items:center;
  box-shadow: 0 4px 10px rgba(0,0,0,.05);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.scroll-bottom.show{ opacity: 1; pointer-events: auto; }
.scroll-bottom svg{ width: 20px; height: 20px; }

/* ===== chat ===== */
.chat{
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 20px 0;
}

.msgrow{ display:flex; margin: 10px 0; }
.msgrow.me{ justify-content:flex-end; }
.msgrow.bot{ justify-content:flex-start; }

.bubble{
  position: relative;
  max-width: 100%;
  border-radius: var(--radius);
  padding: 12px 12px;
  line-height: 1.45;
  font-size: 14px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.me .bubble{
  background: var(--brand);
  color: #fff;
  border-radius: 18px;
  padding: 12px 16px;
  max-width: 72%;

  box-shadow: 0 2px 8px rgba(16,163,127,0.2);
}

.bot .bubble{
  background: #ffffff;
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 14px 16px;
  max-width: 72%;

  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* copy button */
.copy-btn{
  position:absolute;
  top:8px;
  right:8px;
  font-size:12px;
  background:#1f2937;
  color:#fff;
  border:none;
  border-radius:6px;
  padding:4px 6px;
  cursor:pointer;
  opacity:0.8;
}
.copy-btn:hover{ transform: translateY(-1px); }
.copy-btn:active{ transform: translateY(0); opacity: .8; }
.copy-btn svg{ width: 16px; height: 16px; }

/* code blocks */
pre{ margin: 10px 0 0; }
pre code{
  display:block;
  padding: 14px;
  border-radius: 14px;
  background:#0b1020;
  color:#d7def5;
  font-size:13px;
  line-height:1.45;

  overflow-x:auto;
  white-space:pre;
}

/* MathJax */
.bot mjx-container{
  max-width: 100% !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  display:block;
  -webkit-overflow-scrolling: touch;
}

/* ===== status ===== */
.status{
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,243,205,.92);
  border: 1px solid rgba(0,0,0,.08);
  font-size: 13px;
  box-shadow: 0 4px 10px rgba(0,0,0,.05);
}

/* ===== composer ===== */
#composer{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  background: #ffffff;
  border-top: 1px solid var(--stroke);
}

.composer-inner{
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 14px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display:flex;
  gap: 10px;
  align-items:flex-end;
}

.iconbtn{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(17,24,39,.10);
  background: rgba(255,255,255,.92);
  color: var(--text);
  display:grid;
  place-items:center;
  cursor:pointer;
  padding: 0;
}
.iconbtn .ico{ width: 20px; height: 20px; }
.iconbtn:active{ transform: translateY(1px); }

.textwrap{
  border-radius: 20px;
  border: 1px solid var(--stroke);
  background: #fff;
  box-shadow: none;
}



#msg{
resize:none;
overflow-y:auto;
min-height:40px;
max-height:180px;
}

.sendbtn{
  background: var(--brand);
  border-radius: 12px;
  box-shadow: none;
}
.sendbtn:disabled{ opacity: .6; cursor:not-allowed; }
.sendbtn:active{ transform: translateY(1px); }

/* dropdown */
.dropdown-menu{
  border-radius: 16px;
  border: 1px solid rgba(17,24,39,.10);
  box-shadow: 0 18px 50px rgba(17,24,39,.18);
  padding: 8px;
}
.dropdown-item{
  display:flex;
  align-items:center;
  gap: 10px;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
}
.dropdown-item:active{ background: rgba(17,24,39,.06); }
.menu-ico{ width: 20px; height: 20px; flex: 0 0 auto; }

/* attachments */
.attachments{ margin-top: 8px; display:flex; gap: 8px; flex-wrap: wrap; }
.atchip{
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(17,24,39,.06);
  border: 1px solid rgba(17,24,39,.10);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}



/* image preview in attachments */
.atimg{
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 10px;
  border: 1px solid rgba(17,24,39,.12);
  overflow: hidden;
  background: rgba(17,24,39,.03);
}
.atimg img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.atremove{
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: rgba(0,0,0,.6);
  color: #fff;
  cursor: pointer;
  line-height: 22px;
  padding: 0;
}

/* images/files inside sent user messages */
.usertxt{ white-space: pre-wrap; }
.msgatts{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.msgimg{
  width: 180px;
  max-width: 100%;
  max-height: 240px;
  height: auto;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.35);
  display: block;
}
.msgfile{
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.22);
  color: #fff;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* footer */
.hint{ font-size: 12px; color: rgba(15,23,42,.55); }

/* home button */
.home-btn{
  background: #ffffff;
  border: 1px solid var(--stroke);
}
/*#loginBox{
  width:300px;
  margin:120px auto;
  text-align:center;
}

#loginBox input{
  width:100%;
  margin:5px 0;
  padding:10px;
}

#loginBox button{
  width:100%;
  padding:10px;
  margin-top:5px;
}*/

/* ===== responsive ===== */
@media (max-width: 640px){
  .wrap{ padding: 10px; gap: 10px; }
  .topbar{ top: 8px; padding: 10px 12px; }
  .topbar__avatar{ width: 38px; height: 38px; }
  .bubble{ font-size: 14px; }
  .composer-inner{ padding: 10px 10px; }
  .sendbtn{ width: 64px; }
  .home-btn{ right: 12px; }
}
/* layout chat + sidebar */

#chatApp{
  display:none;
  height:100dvh;
  background:#f4f6fb;
  pointer-events:auto; /* 🔥 QUAN TRỌNG */
}

#chatApp > .d-flex{
  height:100%;
  width: 100%;
}

/* sidebar */

.sidebar{
  background: #ffffff;
  border-right: 1px solid var(--stroke);
}

/* main chat */

.flex-grow-1{
  display:flex;
  flex-direction:column;
  min-width:0;
}

/* chat scroll */

#chat{
  flex:1;
  overflow:auto;
}

.menu-btn{
z-index:3000;
position:relative;
}

/* mobile */
@media (max-width:768px){
.copy-btn {
    padding: 6px 10px;
    font-size: 13px;
}

#sidebar{
position:fixed;
top:0;
left:0;
width:260px;
height:100%;
background:#fff;
z-index:2000;

transform:translateX(-100%);
transition:transform .3s ease;
}

#sidebar.open{
transform:translateX(0);
}

}
.chat-history-item{
  border-bottom: none;
  border-radius: 10px;
  margin: 4px 6px;
}
.chat-history-item:hover{
  background: #f1f5f9;
}

.chat-history-item button{
border:none;
background:none;
font-size:18px;
z-index:2;
}
.chat-title{
cursor:pointer;
flex:1;
}
mjx-container{
font-size: 110%;
margin: 6px 0;
}
/*pre{
background:#0f172a;
color:#e5e7eb;
padding:14px
border-radius:10px;
overflow:auto;
font-size:13px;
}*/

pre code{
font-family: "JetBrains Mono", monospace;
}
pre{
position:relative;
background:#0f172a;
color:#e5e7eb;
padding:16px;
border-radius:10px;

overflow-x:auto;
max-width:100%;
white-space:pre;

-webkit-overflow-scrolling: touch;
}
.bot pre{
width:100%;
}



.password-box{
position:relative;
}

.password-box input{
padding-right:40px;
}

.toggle-pass{
position:absolute;
right:12px;
top:50%;
transform:translateY(-50%);
cursor:pointer;
font-size:18px;
color:#555;
}
.mode-toggle{
display:flex;
gap:5px;
margin-bottom:5px;
}

.mode-btn{
border:none;
background:#eee;
padding:4px 8px;
border-radius:6px;
cursor:pointer;
font-size:14px;
}

.mode-btn.active{
background:#2b7cff;
color:white;
}

.copy-btn-msg{
      opacity: 0.7;


  position: absolute;
  top: 6px;
  right: 6px;

  width: 26px;
  height: 26px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 8px;
  border: 1px solid transparent;

  background: transparent;
  color: #6b7280;

  cursor: pointer;
  opacity: 0;

  transition: all 0.15s ease;
}

.bubble:hover .copy-btn-msg{
  opacity:1;
}

.copy-btn-msg i{
  font-size:14px;
  
}


.copy-btn-msg:hover{
    opacity: 1;
}

.copy-btn-clean{
  position: absolute;
  bottom: 6px;
  right: 8px;

  font-size: 12px;
  padding: 4px 8px;

  border-radius: 8px;
  border: 1px solid var(--stroke);

  background: #f9fafb;
  color: #374151;

  cursor: pointer;
  opacity: 0;

  transition: all 0.2s ease;
}

.bubble:hover .copy-btn-clean{
  opacity: 1;
}
#profileBox{
  position:fixed;
  inset:0;
  background:#fff;
  z-index:999999; /* 🔥 tăng */
  display:flex;
}
.send-btn{
  width: 48px !important;
  height: 44px;
  padding: 0 !important;
  border-radius: 10px;
  flex-shrink: 0;
}

#msg{
  flex:1;
}

.send-btn i{
  font-size:18px;
  color:#fff;
}
/* ===== UI nâng cấp ===== */

.btn-primary{
  background: linear-gradient(135deg,#6366f1,#4f46e5);
  border:none;
}

.new-chat-btn{
  background: linear-gradient(135deg,#6366f1,#4f46e5);
}

.sidebar{
  background:#f9fafb;
}

.topbar{
  background:#fff;
  border-bottom:1px solid #eee;
}
#pf_dob{
  letter-spacing:1px;
  font-weight:500;
}
.dropdown > button{
  width:40px;
  height:40px;
  border-radius:10px;
  padding:0;
  display:flex;
  align-items:center;
  justify-content:center;
}
.chat-history-item button{
  border:none;
  background:none;
  font-size:18px;
}
.p-2.border-top{
  flex-shrink:0;
}
#attachments{
  flex-shrink:0;
}
@media (max-width:768px){

  /* Ẩn hiệu ứng container gốc */
  #loginBox .container{
    display:block;
    width:100%;
    max-width:380px;
    margin:auto;
    height:auto;
  }

  /* Ẩn toggle animation */
  .toggle-box{
    display:none !important;
  }

  /* Ẩn hết form */
  .form-box{
    display:none !important;
    width:100% !important;
    position:relative !important;
  }

  /* Form active sẽ hiện */
  .form-box.active{
    display:block !important;
  }

  /* Style card cho đẹp */
  .form-box form{
    background:#fff;
    padding:25px 20px;
    border-radius:14px;
    box-shadow:0 10px 30px rgba(0,0,0,0.1);
  }

  /* Button chuyển form */
  .switch-auth{
    text-align:center;
    margin-top:15px;
    font-size:14px;
  }

  .switch-auth span{
    color:#4f46e5;
    font-weight:600;
    cursor:pointer;
  }
}
@media (max-width:768px){


}
@media (max-width:768px){

  html, body{
    width:100%;
    overflow-x:hidden !important;
  }

  #loginBox{
    padding:10px;
  }

  #loginBox .container{
    width:100% !important;
    max-width:100% !important;
    padding:0 10px;
  }

  .form-box form{
    width:100%;
    max-width:100%;
    box-sizing:border-box;
  }

  .input-box input{
    width:100%;
  }

}
@media (max-width:768px){

  .toggle-box{
    display:none !important;
    pointer-events:none !important;
    z-index:-1 !important;
  }

}
.form-box{
  position:relative;
  z-index:10;
}