/* General formatting */
body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 95%;
    overflow: hidden; /* prevents double scroll */
    background: #111;
    color: #eee;
    font-family: sans-serif;
}

.container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.chat-box {
    background: #181818;
    padding: 15px;
    border-radius: 8px;
    max-height: 60vh;
    flex: 1;               /* fills all remaining space */
    overflow-y: auto;      /* scrolls properly */
    min-height: 0;         /* prevents overflow bugs */
}

.msg {
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 6px;
}

.msg.user {
    background: #1f3b5d;
    text-align: right;
}

.msg.assistant {
    background: #2f2f2f;
}

textarea {
    width: 100%;
    max-width: 100%;
    height: 80px;
    background: #101010;
    color: #eee;
    border: 1px solid #444;
    border-radius: 6px;
}

button {
    margin-top: 10px;
    padding: 10px 20px;
    background: #ffcf22;
    border: none;
    border-radius: 6px;
    font-weight: bold;
}

a {
    color: #ff8080;
}

/* Modern chat bubble styling */
.msg {
    margin-bottom: 12px;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    max-width: 85%;
    word-wrap: break-word;
    display: inline-block;
}

/* User bubble (right side) */
.msg.user {
    background: linear-gradient(135deg, #1f3b5d, #2a4f7a);
    color: #e8f0ff;
    margin-left: auto;
    text-align: left;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Assistant bubble (left side) */
.msg.assistant {
    background: #2a2a2a;
    color: #eee;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.scroll-top-btn {
    position: sticky;
    bottom: 80px; /* sits ABOVE the sticky input bar */
    float: right;
    margin-right: 10px;
    padding: 8px 12px;
    background: #ffcf22;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.55;
    z-index: 999;
}

.scroll-top-btn:hover {
    opacity: 1;
}

/* Mobile layout */
@media (max-width: 600px) {

    form {
        width: 100%;
        max-width: 100%;
        position: sticky;
        bottom: 0;
        background: #111;
        padding: 10px;
        box-shadow: 0 -2px 6px rgba(0,0,0,0.4);
        display: flex;
        flex-direction: column;
        gap: 8px;
        z-index: 999;
        box-sizing: border-box;
    }

    textarea {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        height: 45px;
        font-size: 15px;
        padding: 8px 10px;
        overflow: hidden;
        resize: none;
        background: #1c1c1c;
        color: #eee;
        border: none;
        border-radius: 22px; 
        resize: none;
    }

    button {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        font-size: 18px;
        padding: 14px;
    }

    .chat-box {
        max-height: calc(100vh - 110px); /* prevent overlap  */

        /* space for sticky bar */
        overflow-y: auto;
        padding-bottom: 20px;
        /* prevent overlap */
    }

    .msg {
        max-width: 90%;
        padding: 14px 18px;
        font-size: 16px;
        border-radius: 20px;
    }

    .msg.user {
        border-bottom-right-radius: 6px;
    }

    .msg.assistant {
        border-bottom-left-radius: 6px;
    }
    
    .scroll-top-btn {
        bottom: 90px; /* slightly higher on phones */
        padding: 6px 10px;
        font-size: 13px;
    }

}
