/* ==========================================================
   CTIM AI CHATBOT v2.0
   File: style.css
   PHẦN 1
   RESET + LAYOUT + SIDEBAR + DRAWER
========================================================== */


/* ==========================
   ROOT
========================== */

:root{

    --primary:#2563eb;
    --primary-dark:#1d4ed8;

    --sidebar:#123c88;

    --bg:#f5f7fb;

    --white:#ffffff;

    --text:#1f2937;

    --text-light:#6b7280;

    --border:#e5e7eb;

    --shadow:
        0 10px 25px rgba(0,0,0,.08);

    --radius:16px;

    --transition:.28s ease;

}


/* ==========================
   RESET
========================== */

*{

    margin:0;

    padding:0;

    box-sizing:border-box;

}

html{

    width:100%;

    min-height:100%;

    -webkit-text-size-adjust:100%;

    scroll-behavior:smooth;

}

body{

    width:100%;

    min-height:100%;

    overflow-x:hidden;

    font-family:"Inter",sans-serif;

    background:var(--bg);

    color:var(--text);

}

img{

    display:block;

    max-width:100%;

}

button{

    font-family:inherit;

}

textarea{

    font-family:inherit;

}

a{

    color:inherit;

    text-decoration:none;

}


/* ==========================
   APP
========================== */

.app{

    display:flex;

    width:100%;

    min-height:100vh;

    height:100dvh;

    overflow:hidden;

}


/* ==========================
   OVERLAY
========================== */

.overlay{

    position:fixed;

    inset:0;

    background:rgba(15,23,42,.45);

    backdrop-filter:blur(3px);

    opacity:0;

    visibility:hidden;

    transition:var(--transition);

    z-index:998;

}

.overlay.show{

    opacity:1;

    visibility:visible;

}


/* ==========================
   SIDEBAR
========================== */

.sidebar{

    width:300px;

    min-width:300px;

    max-width:300px;

    display:flex;

    flex-direction:column;

    background:linear-gradient(

        180deg,

        #123c88,

        #0b2f6b

    );

    color:#fff;

    border-right:1px solid rgba(255,255,255,.08);

    transition:transform .3s ease;

    z-index:999;

}


/* ==========================
   LOGO
========================== */

.logo{

    display:flex;

    align-items:center;

    gap:15px;

    padding:24px;

    border-bottom:1px solid rgba(255,255,255,.08);

}

.logo img{

    width:56px;

    height:56px;

    border-radius:50%;

    background:#fff;

    padding:6px;

}

.logo h2{

    font-size:22px;

    font-weight:700;

}

.logo span{

    display:block;

    margin-top:4px;

    font-size:13px;

    color:#dbeafe;

}


/* ==========================
   NEW CHAT
========================== */

.new-chat{

    margin:18px;

    padding:14px 18px;

    border:none;

    border-radius:14px;

    background:var(--primary);

    color:#fff;

    font-size:15px;

    font-weight:600;

    cursor:pointer;

    transition:var(--transition);

}

.new-chat:hover{

    background:var(--primary-dark);

    transform:translateY(-2px);

    box-shadow:

        0 10px 20px rgba(0,0,0,.18);

}


/* ==========================
   HISTORY
========================== */

.history{

    flex:1;

    min-height:0;

    overflow-y:auto;

    padding:16px;

}

.history-empty{

    padding:20px;

    text-align:center;

    color:#dbeafe;

    font-size:14px;

}

.history-item{

    padding:12px 14px;

    margin-bottom:10px;

    border-radius:12px;

    background:rgba(255,255,255,.08);

    cursor:pointer;

    transition:var(--transition);

    white-space:nowrap;

    overflow:hidden;

    text-overflow:ellipsis;

    font-size:14px;

}

.history-item:hover{

    background:rgba(255,255,255,.18);

    transform:translateX(3px);

}


/* ==========================
   SIDEBAR FOOTER
========================== */

.sidebar-footer{

    padding:18px;

    border-top:1px solid rgba(255,255,255,.08);

    text-align:center;

    color:#dbeafe;

    font-size:12px;

}


/* ==========================
   SCROLLBAR
========================== */

.history::-webkit-scrollbar{

    width:7px;

}

.history::-webkit-scrollbar-thumb{

    background:rgba(255,255,255,.25);

    border-radius:10px;

}

.history::-webkit-scrollbar-track{

    background:transparent;

}


/* ==========================
   MOBILE DRAWER
========================== */

.menu-btn{

    display:none;

    align-items:center;

    justify-content:center;

    width:42px;

    height:42px;

    border:none;

    border-radius:10px;

    background:transparent;

    font-size:24px;

    cursor:pointer;

    color:#1f2937;

    transition:var(--transition);

}

.menu-btn:hover{

    background:#eef2ff;

}


/* Sidebar trượt */

.sidebar.show{

    transform:translateX(0);

}

/* ==========================================================
   CTIM AI CHATBOT v2.0
   PHẦN 2
   CHAT AREA + HEADER + MESSAGE + BUBBLE + TYPING
========================================================== */


/* ==========================
   CHAT AREA
========================== */

.chat-area{

    flex:1;

    min-width:0;

    display:flex;

    flex-direction:column;

    background:var(--bg);

}


/* ==========================
   HEADER
========================== */

header{

    height:72px;

    flex-shrink:0;

    display:flex;

    align-items:center;

    justify-content:space-between;

    padding:0 24px;

    background:rgba(255,255,255,.92);

    backdrop-filter:blur(12px);

    border-bottom:1px solid var(--border);

    box-shadow:

        0 2px 10px rgba(0,0,0,.04);

}


/* ==========================
   HEADER LEFT
========================== */

.header-left{

    display:flex;

    align-items:center;

    gap:14px;

    min-width:0;

}

.header-logo{

    width:48px;

    height:48px;

    border-radius:50%;

    flex-shrink:0;

}

.header-left h1{

    font-size:20px;

    font-weight:700;

    color:var(--text);

}

.header-left span{

    display:block;

    margin-top:3px;

    font-size:13px;

    color:var(--text-light);

}


/* ==========================
   HEADER RIGHT
========================== */

.header-right{

    display:flex;

    align-items:center;

    gap:12px;

}

.status{

    display:flex;

    align-items:center;

    gap:8px;

    padding:8px 14px;

    border-radius:999px;

    background:#ecfdf5;

    color:#16a34a;

    font-size:13px;

    font-weight:600;

    white-space:nowrap;

}


/* ==========================
   MESSAGE LIST
========================== */

.messages{

    flex:1;

    min-height:0;

    overflow-y:auto;

    padding:24px;

    display:flex;

    flex-direction:column;

    gap:18px;

    scroll-behavior:smooth;

}


/* ==========================
   MESSAGE
========================== */

.message{

    display:flex;

    align-items:flex-start;

    gap:14px;

}

.message.user{

    flex-direction:row-reverse;

}


/* ==========================
   CONTENT
========================== */

.message > div{

    display:flex;

    flex-direction:column;

    max-width:min(82%,850px);

}


/* ==========================
   AVATAR
========================== */

.avatar{

    width:42px;

    height:42px;

    border-radius:50%;

    flex-shrink:0;

    object-fit:cover;

    box-shadow:

        0 4px 12px rgba(0,0,0,.12);

}


/* ==========================
   BUBBLE
========================== */

.bubble{

    background:#ffffff;

    border-radius:18px;

    padding:14px 18px;

    line-height:1.7;

    font-size:15px;

    color:var(--text);

    border:1px solid rgba(0,0,0,.04);

    box-shadow:

        0 4px 16px rgba(0,0,0,.06);

    word-break:break-word;

}


/* ==========================
   USER
========================== */

.message.user .bubble{

    background:linear-gradient(

        135deg,

        var(--primary),

        #4f7cf0

    );

    color:#fff;

    border:none;

}


/* ==========================
   BOT
========================== */

.message.bot .bubble{

    background:#ffffff;

}


/* ==========================
   LIST
========================== */

.bubble ul{

    margin-top:10px;

    margin-left:22px;

}

.bubble li{

    margin:6px 0;

}


/* ==========================
   LINK
========================== */

.bubble a{

    color:#2563eb;

    font-weight:600;

    text-decoration:none;

}

.bubble a:hover{

    text-decoration:underline;

}


/* ==========================
   INLINE CODE
========================== */

.bubble code{

    padding:2px 6px;

    border-radius:6px;

    background:#eef2ff;

    color:#1d4ed8;

    font-family:Consolas, monospace;

    font-size:.92em;

}


/* ==========================
   PRE
========================== */

.bubble pre{

    overflow:auto;

    margin:12px 0;

    padding:14px;

    border-radius:12px;

    background:#0f172a;

    color:#f8fafc;

    font-family:Consolas, monospace;

    font-size:14px;

}


/* ==========================
   TABLE
========================== */

.bubble table{

    width:100%;

    margin:12px 0;

    border-collapse:collapse;

}

.bubble table th,

.bubble table td{

    padding:10px;

    border:1px solid #d1d5db;

}

.bubble table th{

    background:#eff6ff;

}


/* ==========================
   TIME
========================== */

.time{

    margin-top:6px;

    margin-left:8px;

    font-size:11px;

    color:#94a3b8;

}

.message.user .time{

    text-align:right;

    margin-right:8px;

}


/* ==========================
   TYPING
========================== */

.typing{

    display:flex;

    align-items:center;

    gap:12px;

    padding:0 24px 18px;

}

.typing-box{

    display:flex;

    align-items:center;

    gap:7px;

    padding:12px 16px;

    background:#ffffff;

    border-radius:16px;

    box-shadow:

        0 4px 14px rgba(0,0,0,.06);

}

.typing-box span{

    width:8px;

    height:8px;

    border-radius:50%;

    background:#94a3b8;

    animation:typing 1.1s infinite;

}

.typing-box span:nth-child(2){

    animation-delay:.2s;

}

.typing-box span:nth-child(3){

    animation-delay:.4s;

}

@keyframes typing{

    0%{

        transform:translateY(0);

        opacity:.4;

    }

    50%{

        transform:translateY(-6px);

        opacity:1;

    }

    100%{

        transform:translateY(0);

        opacity:.4;

    }

}


/* ==========================
   HIDDEN
========================== */

.hidden{

    display:none !important;

}


/* ==========================
   CHAT SCROLLBAR
========================== */

.messages::-webkit-scrollbar{

    width:8px;

}

.messages::-webkit-scrollbar-thumb{

    background:#cbd5e1;

    border-radius:999px;

}

.messages::-webkit-scrollbar-thumb:hover{

    background:#94a3b8;

}

.messages::-webkit-scrollbar-track{

    background:transparent;

}

/* ==========================================================
   CTIM AI CHATBOT v2.0
   PHẦN 3
   FOOTER + INPUT + BUTTON + NOTE
========================================================== */


/* ==========================
   FOOTER
========================== */

footer{

    flex-shrink:0;

    background:#ffffff;

    border-top:1px solid var(--border);

    padding:18px 22px;

    padding-bottom:calc(

        18px + env(safe-area-inset-bottom)

    );

    box-shadow:

        0 -2px 10px rgba(0,0,0,.04);

}


/* ==========================
   INPUT BOX
========================== */

.input-box{

    display:flex;

    align-items:flex-end;

    gap:14px;

}


/* ==========================
   TEXTAREA
========================== */

.input-box textarea{

    flex:1;

    width:100%;

    min-height:52px;

    max-height:180px;

    padding:14px 18px;

    resize:none;

    outline:none;

    border:1px solid #d1d5db;

    border-radius:16px;

    background:#ffffff;

    font-size:15px;

    line-height:1.6;

    transition:.25s;

    overflow-y:auto;

}


.input-box textarea:focus{

    border-color:var(--primary);

    box-shadow:

        0 0 0 4px rgba(37,99,235,.12);

}


.input-box textarea::placeholder{

    color:#9ca3af;

}


/* ==========================
   SEND BUTTON
========================== */

#sendBtn{

    min-width:120px;

    height:52px;

    border:none;

    border-radius:16px;

    background:linear-gradient(

        135deg,

        var(--primary),

        #4f7cf0

    );

    color:#ffffff;

    font-size:15px;

    font-weight:600;

    cursor:pointer;

    transition:.25s;

    box-shadow:

        0 6px 18px rgba(37,99,235,.28);

}


#sendBtn:hover{

    transform:translateY(-2px);

    box-shadow:

        0 10px 24px rgba(37,99,235,.35);

}


#sendBtn:active{

    transform:scale(.97);

}


#sendBtn:disabled{

    opacity:.75;

    cursor:not-allowed;

    transform:none;

}


/* ==========================
   NOTE
========================== */

.note{

    margin-top:12px;

    text-align:center;

    color:var(--text-light);

    font-size:12px;

    line-height:1.5;

}


/* ==========================
   INPUT SCROLLBAR
========================== */

.input-box textarea::-webkit-scrollbar{

    width:6px;

}


.input-box textarea::-webkit-scrollbar-thumb{

    background:#cbd5e1;

    border-radius:999px;

}


.input-box textarea::-webkit-scrollbar-track{

    background:transparent;

}


/* ==========================
   BUTTON EFFECT
========================== */

#sendBtn{

    position:relative;

    overflow:hidden;

}


#sendBtn::after{

    content:"";

    position:absolute;

    inset:0;

    background:rgba(255,255,255,.12);

    opacity:0;

    transition:.25s;

}


#sendBtn:hover::after{

    opacity:1;

}


/* ==========================
   SELECTION
========================== */

::selection{

    background:#bfdbfe;

    color:#1e3a8a;

}


/* ==========================
   FOCUS
========================== */

button:focus-visible,

textarea:focus-visible{

    outline:none;

}


/* ==========================
   TRANSITION
========================== */

button,

textarea,

.history-item,

.bubble,

.sidebar,

.menu-btn{

    transition:all .25s ease;

}

/* ==========================================================
   CTIM AI CHATBOT v2.0
   PHẦN 4
   RESPONSIVE + DARK MODE + FIX ANDROID DESKTOP SITE
========================================================== */


/* ==========================
   LARGE DESKTOP
========================== */

@media (min-width:1600px){

.messages{

    padding:32px 40px;

}

.message > div{

    max-width:900px;

}

}


/* ==========================
   LAPTOP
========================== */

@media (max-width:1200px){

.sidebar{

    width:280px;

    min-width:280px;

    max-width:280px;

}

.messages{

    padding:20px;

}

}


/* ==========================
   TABLET
========================== */

@media (max-width:992px){

.header-left h1{

    font-size:18px;

}

.header-left span{

    font-size:12px;

}

.messages{

    padding:18px;

}

.message > div{

    max-width:88%;

}

.status{

    display:none;

}

}


/* ==========================
   MOBILE
========================== */

@media (max-width:768px){

.app{

    height:100dvh;

}

.sidebar{

    position:fixed;

    top:0;

    left:0;

    bottom:0;

    width:280px;

    min-width:280px;

    max-width:280px;

    transform:translateX(-100%);

    box-shadow:

        0 10px 30px rgba(0,0,0,.25);

}

.sidebar.show{

    transform:translateX(0);

}

.menu-btn{

    display:flex;

}

header{

    padding:0 16px;

}

.header-logo{

    width:42px;

    height:42px;

}

.header-left{

    gap:10px;

}

.messages{

    padding:16px;

}

.message{

    gap:10px;

}

.message > div{

    max-width:94%;

}

.avatar{

    width:38px;

    height:38px;

}

.typing{

    padding:0 16px 14px;

}

footer{

    padding:16px;

    padding-bottom:calc(

        16px + env(safe-area-inset-bottom)

    );

}

.input-box{

    flex-direction:column;

    align-items:stretch;

}

#sendBtn{

    width:100%;

    min-width:unset;

    margin-top:4px;

}

}


/* ==========================
   SMALL MOBILE
========================== */

@media (max-width:576px){

header{

    height:64px;

}

.header-logo{

    width:36px;

    height:36px;

}

.header-left h1{

    font-size:16px;

}

.header-left span{

    display:none;

}

.messages{

    padding:12px;

}

.avatar{

    width:34px;

    height:34px;

}

.bubble{

    font-size:14px;

    padding:12px 14px;

}

.typing{

    padding:0 12px 12px;

}

.typing-box{

    padding:10px 14px;

}

.note{

    font-size:11px;

}

}


/* ==========================
   VERY SMALL SCREEN
========================== */

@media (max-width:360px){

.logo{

    padding:18px;

}

.logo img{

    width:46px;

    height:46px;

}

.new-chat{

    margin:12px;

    font-size:14px;

}

.history{

    padding:12px;

}

}


/* ==========================
   DESKTOP SITE FIX
========================== */

/*
Chrome Android khi bật
"Trang web cho máy tính"
thường báo viewport khoảng 980px.

Đoạn này giúp giao diện Desktop
không bị co lại.
*/

@media (min-width:769px){

.sidebar{

    position:relative;

    transform:none !important;

}

.overlay{

    display:none !important;

}

.menu-btn{

    display:none !important;

}

}


/* ==========================
   FLEX FIX
========================== */

.chat-area{

    min-width:0;

}

.messages{

    min-height:0;

}

footer{

    flex-shrink:0;

}


/* ==========================
   ANIMATION
========================== */

@keyframes fadeUp{

    from{

        opacity:0;

        transform:translateY(15px);

    }

    to{

        opacity:1;

        transform:translateY(0);

    }

}

.message{

    animation:fadeUp .25s ease;

}


/* ==========================
   DARK MODE
========================== */

body.dark{

    background:#0f172a;

    color:#f8fafc;

}

body.dark .chat-area{

    background:#0f172a;

}

body.dark header{

    background:#111827;

    border-bottom:1px solid #374151;

}

body.dark footer{

    background:#111827;

    border-top:1px solid #374151;

}

body.dark .bubble{

    background:#1f2937;

    color:#f8fafc;

    border-color:#374151;

}

body.dark .message.user .bubble{

    background:linear-gradient(

        135deg,

        #2563eb,

        #1d4ed8

    );

}

body.dark textarea{

    background:#1f2937;

    color:#ffffff;

    border-color:#374151;

}

body.dark textarea::placeholder{

    color:#9ca3af;

}

body.dark .typing-box{

    background:#1f2937;

}

body.dark .status{

    background:#052e16;

    color:#4ade80;

}

body.dark .messages::-webkit-scrollbar-thumb{

    background:#4b5563;

}

body.dark .history-item{

    background:rgba(255,255,255,.08);

}

body.dark .history-item:hover{

    background:rgba(255,255,255,.14);

}

body.dark .menu-btn{

    color:#f8fafc;

}

body.dark .menu-btn:hover{

    background:#1f2937;

}


/* ==========================
   PRINT
========================== */

@media print{

.sidebar,

header,

footer,

.typing{

    display:none !important;

}

.messages{

    overflow:visible;

    height:auto;

}

}
