/* =====================================
   Pundit Junction AI Chatbot
===================================== */

*{
    box-sizing:border-box;
}

:root{

    --primary:#2f4f63;
    --primary-dark:#254052;
    --secondary:#f4f6f9;
    --bot:#ffffff;
    --user:#2f4f63;
    --text:#333;
    --border:#e6e6e6;
    --shadow:0 12px 35px rgba(0,0,0,.15);
    --radius:18px;

    font-family:
    "Segoe UI",
    Roboto,
    Arial,
    sans-serif;

}

/* =====================================
Floating Button
===================================== */

#pj-chat-btn{

    position:fixed;

    right:25px;

    bottom:25px;

    width:65px;

    height:65px;

    border-radius:50%;

    background:var(--primary);

    color:#fff;

    display:flex;

    align-items:center;

    justify-content:center;

    font-size:28px;

    cursor:pointer;

    z-index:99999;

    box-shadow:var(--shadow);

    transition:.3s;

}

#pj-chat-btn:hover{

    transform:scale(1.08);

}

#pj-chat-btn .pulse{

    position:absolute;

    width:65px;

    height:65px;

    border-radius:50%;

    border:2px solid rgba(255,255,255,.4);

    animation:pulse 2s infinite;

}

@keyframes pulse{

0%{

transform:scale(1);

opacity:1;

}

100%{

transform:scale(1.8);

opacity:0;

}

}

/* =====================================
Chat Window
===================================== */

#pj-chat{

    position:fixed;

    right:25px;

    bottom:25px;

    width:380px;

    max-width:95%;

    height:520px;

    background:#fff;

    border-radius:22px;

    overflow:hidden;

    display:none;

    flex-direction:column;

    box-shadow:var(--shadow);

    z-index:99999;

}

/* =====================================
Header
===================================== */

.pj-header{

    background:linear-gradient(120deg, #36556c, #2f4f63);

    color:#fff;

    padding:16px;

    display:flex;

    justify-content:space-between;

    align-items:center;

}

.pj-header .left{

    display:flex;

    gap:12px;

    align-items:center;

}

.pj-header h3{

    margin:0;

    font-size:15.5px;
    color: white;

}

.pj-header span{

    font-size:11.5px;

    opacity:.85;

    margin-top: 2px;

}

.online{

    width:9px;

    height:9px;

    background:#3ddb64;

    display:inline-block;

    border-radius:50%;

}

#pj-close{

    border:none;

    background:none;

    color:#fff;

    font-size:22px;

    cursor:pointer;

}

/* =====================================
Avatar
===================================== */

.avatar{

    width:38px;

    height:38px;

    border-radius:50%;

    background:#e7edf2;

    color:var(--primary);

    display:flex;

    justify-content:center;

    align-items:center;

    font-weight:bold;

    flex-shrink:0;

}

/* =====================================
Messages
===================================== */

#pj-messages{

      flex:1;

    overflow-y:auto;

    overflow-x:hidden;

    padding:20px;

    background:#f7f8fb;

    scroll-behavior:smooth;

    min-height:0;

}

.msg{

    display:flex;

    margin-bottom:18px;

    align-items:flex-end;

    gap:10px;

}

.msg.user{

    justify-content:flex-end;

}

.msg.user .avatar{

    display:none;

}

.bubble{

    max-width:78%;

    padding:14px 18px;

    border-radius:18px;

    font-size:15px;

    line-height:1.6;

    word-wrap:break-word;

}

.msg.bot .bubble{

    background:#fff;

    color:#333;

    border:1px solid var(--border);

}

.msg.user .bubble{

    background:var(--user);

    color:#fff;

    border-bottom-right-radius:5px;

}

.msg.bot .bubble{

    border-bottom-left-radius:5px;

}

/* =====================================
Timestamp
===================================== */

.time{

    font-size:11px;

    color:#888;

    margin-top:5px;

}

/* =====================================
Typing
===================================== */

#pj-typing{

    display:flex;

    align-items:center;

    padding:15px;

    background:#f7f8fb;

}

.typing{

    background:#fff;

    border-radius:16px;

    padding:10px 16px;

}

.typing span{

    display:inline-block;

    width:8px;

    height:8px;

    margin:0 2px;

    border-radius:50%;

    background:#999;

    animation:typing 1.2s infinite;

}

.typing span:nth-child(2){

animation-delay:.2s;

}

.typing span:nth-child(3){

animation-delay:.4s;

}

@keyframes typing{

0%,80%,100%{

transform:scale(.8);

opacity:.4;

}

40%{

transform:scale(1.2);

opacity:1;

}

}

/* =====================================
Footer
===================================== */

.pj-footer{

      flex-shrink:0;

    border-top:1px solid #eee;

    padding:12px;

    display:flex;

    gap:10px;

    align-items:flex-end;

    background:#fff;

}

#pj-input{

    flex: 1;
    resize: none;
    border: 1px solid #ddd;
    border-radius: 14px;
    padding: 10px 13px;
    font-size: 13.5px;
    outline: none;
    max-height: 90px;
    line-height: 1.4;
    background: #fafafa;
    transition: border-color .15s;

}

#pj-input:focus{

    border-color:var(--primary);

}

#pj-send{

    width:50px;

    height:50px;

    border:none;

    border-radius:50%;

    background:var(--primary);

    color:#fff;

    font-size:20px;

    cursor:pointer;

    transition:.25s;

}

#pj-send:hover{

    background:var(--primary-dark);

    transform:scale(1.05);

}

#pj-send:disabled{

    opacity:.5;

    cursor:not-allowed;

}

/* =====================================
Scrollbar
===================================== */

#pj-messages::-webkit-scrollbar{

    width:6px;

}

#pj-messages::-webkit-scrollbar-thumb{

    background:#c9c9c9;

    border-radius:20px;

}

#pj-messages::-webkit-scrollbar-track{

    background:transparent;

}

/* =====================================
Mobile
===================================== */

@media (max-width: 768px) {

    #pj-chat {
        position: fixed;

        /* Almost full width */
        width: calc(100vw - 24px);
        max-width: none;

        /* Almost full height */
        height: calc(100dvh - 24px);
        max-height: none;

        right: 12px;
        bottom: 12px;
        left: 12px;

        border-radius: 20px;

        overflow: hidden;

        display: none;
        flex-direction: column;

        z-index: 999999;
    }

    /* Header */
    .pj-header {
        min-height: 72px;
        padding: 14px 16px;
        flex-shrink: 0;
    }

    .pj-header .left {
        gap: 10px;
    }

    .pj-header h3 {
        font-size: 18px;
        line-height: 1.2;
    }

    .pj-header span {
        font-size: 13px;
    }

    /* Header avatar */
    .pj-header .avatar {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }

    /* Close button */
    #pj-close {
        width: 42px;
        height: 42px;
        font-size: 24px;
    }

    /* Messages */
    #pj-messages {
        flex: 1;
        min-height: 0;

        padding: 16px;

        overflow-y: auto;
        overflow-x: hidden;

        background: #f7f8fb;
    }

    /* Message */
    .msg {
        margin-bottom: 14px;
        gap: 8px;
    }

    /* Bot/User bubbles */
    .bubble {
        max-width: 88%;
        padding: 12px 15px;
        font-size: 15px;
        line-height: 1.5;
    }

    /* Bot avatar */
    .msg .avatar {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }

    /* Typing */
    #pj-typing {
        flex-shrink: 0;
        padding: 10px 15px;
    }

    /* Footer */
    .pj-footer {
        flex-shrink: 0;

        padding: 10px;

        gap: 8px;

        min-height: 70px;
    }

    /* Input */
    #pj-input {
        min-height: 48px;

        padding: 12px 15px;

        font-size: 15px;

        border-radius: 24px;

        max-height: 100px;
    }

    /* Send */
    #pj-send {
        width: 48px;
        height: 48px;

        min-width: 48px;

        font-size: 19px;
    }

   #pj-chat-btn {
        position: fixed;

        width: 150px;
        height: 150px;

        right: 18px;
        bottom: 18px;

        border-radius: 50%;

        background: #2f4f63;
        color: #fff;

        display: flex;
        align-items: center;
        justify-content: center;

        font-size: 32px;
        line-height: 1;

        cursor: pointer;

        z-index: 999999;

        box-shadow:
            0 5px 18px rgba(0, 0, 0, 0.30);

        border: 3px solid #ffffff;

        transition: transform .25s ease;
    }

    #pj-chat-btn:hover {
        transform: scale(1.08);
    }

    #pj-chat-btn .pulse {
        position: absolute;

        width: 68px;
        height: 68px;

        border-radius: 50%;

        border: 2px solid rgba(47, 79, 99, .55);

        animation: pulse 2s infinite;

        pointer-events: none;
    }

}

@media (max-width: 400px) {

    #pj-chat {
        width: calc(100vw - 16px);
        height: calc(100dvh - 16px);

        right: 8px;
        bottom: 8px;
        left: 8px;

        border-radius: 16px;
    }

    .pj-header {
        min-height: 64px;
        padding: 12px;
    }

    .pj-header h3 {
        font-size: 16px;
    }

    #pj-messages {
        padding: 12px;
    }

    .bubble {
        max-width: 92%;
        font-size: 14px;
    }

    .pj-footer {
        padding: 8px;
    }

    #pj-input {
        font-size: 14px;
    }

    #pj-send {
        width: 45px;
        height: 45px;
        min-width: 45px;
    }
}
