* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: #0b1120;
    color: #e5e7eb;
    font-family: Arial, Helvetica, sans-serif;
    min-height: 100vh;
}

.app {
    display: flex;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
}

/* sidebar */
.sidebar {
    width: 290px;
    min-width: 290px;
    background: linear-gradient(180deg, #0f172a, #111827);
    border-right: 1px solid #1f2937;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
}

.brand h2 {
    font-size: 20px;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.brand p {
    color: #94a3b8;
    font-size: 14px;
}

.new-chat-btn {
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    width: 100%;
}

.new-chat-btn:hover {
    background: #1d4ed8;
}

.developers {
    margin-top: auto;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #1f2937;
    border-radius: 14px;
    padding: 16px;
}

.developers h3 {
    margin-bottom: 10px;
    font-size: 16px;
    color: #38bdf8;
}

.developers ul {
    list-style: none;
    line-height: 1.9;
    color: #dbeafe;
    font-size: 14px;
}

/* main area */
.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    background: #020617;
}

.topbar {
    padding: 24px 28px;
    border-bottom: 1px solid #1f2937;
    background: rgba(2, 6, 23, 0.95);
}

.topbar h1 {
    font-size: 28px;
    margin-bottom: 6px;
    line-height: 1.2;
}

.topbar p {
    color: #94a3b8;
    font-size: 15px;
    line-height: 1.5;
}

/* chat area */
.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: 0;
    scroll-behavior: smooth;
}

.message-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
}

.user-row {
    justify-content: flex-end;
}

.bot-row {
    justify-content: flex-start;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.bot-avatar {
    background-image: url("/static/bot_icon.png");
}

.user-avatar {
    background-image: url("/static/user_icon.png");
}

.message {
    max-width: 70%;
    padding: 14px 18px;
    border-radius: 18px;
    line-height: 1.6;
    word-break: break-word;
    overflow-wrap: anywhere;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    font-size: 15px;
}

.message.user {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
}

.message.bot {
    background: #111827;
    border: 1px solid #1f2937;
    color: #e5e7eb;
}

/* input area */
.chat-form {
    flex-shrink: 0;
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #1f2937;
    background: #0b1120;
}

.chat-form input {
    flex: 1;
    min-width: 0;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #334155;
    background: #111827;
    color: white;
    font-size: 15px;
    outline: none;
}

.chat-form input:focus {
    border-color: #38bdf8;
}

.chat-form button {
    background: linear-gradient(135deg, #38bdf8, #2563eb);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px 22px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    flex-shrink: 0;
}

.chat-form button:hover {
    opacity: 0.95;
}

.chat-form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.typing {
    opacity: 0.8;
    font-style: italic;
}

/* large tablets / small laptops */
@media (max-width: 1200px) {
    .sidebar {
        width: 250px;
        min-width: 250px;
        padding: 20px;
    }

    .topbar {
        padding: 22px 24px;
    }

    .chat-box {
        padding: 24px;
    }

    .chat-form {
        padding: 18px 20px;
    }

    .message {
        max-width: 76%;
    }
}

/* tablets */
@media (max-width: 900px) {
    .sidebar {
        display: none;
    }

    .topbar {
        padding: 20px;
    }

    .topbar h1 {
        font-size: 24px;
    }

    .topbar p {
        font-size: 14px;
    }

    .chat-box {
        padding: 20px;
        gap: 16px;
    }

    .message {
        max-width: 82%;
        font-size: 14px;
        padding: 13px 16px;
    }

    .avatar {
        width: 38px;
        height: 38px;
    }

    .chat-form {
        padding: 16px 18px;
    }

    .chat-form input {
        font-size: 14px;
        padding: 13px 14px;
    }

    .chat-form button {
        padding: 13px 18px;
        font-size: 14px;
    }
}

/* phones */
@media (max-width: 600px) {
    .topbar {
        padding: 16px;
    }

    .topbar h1 {
        font-size: 22px;
    }

    .topbar p {
        font-size: 13px;
    }

    .chat-box {
        padding: 16px;
        gap: 14px;
    }

    .message-row {
        gap: 10px;
    }

    .avatar {
        width: 34px;
        height: 34px;
    }

    .message {
        max-width: 88%;
        padding: 12px 14px;
        border-radius: 16px;
        font-size: 14px;
        line-height: 1.5;
    }

    .chat-form {
        padding: 14px 16px;
        gap: 10px;
    }

    .chat-form input {
        padding: 12px 14px;
        font-size: 14px;
        border-radius: 10px;
    }

    .chat-form button {
        padding: 12px 16px;
        font-size: 14px;
        border-radius: 10px;
    }
}

/* very small phones */
@media (max-width: 420px) {
    .topbar {
        padding: 14px;
    }

    .topbar h1 {
        font-size: 20px;
    }

    .chat-box {
        padding: 14px;
    }

    .message {
        max-width: 92%;
        font-size: 13px;
        padding: 11px 13px;
    }

    .avatar {
        width: 30px;
        height: 30px;
    }

    .chat-form {
        padding: 12px 14px;
    }

    .chat-form input {
        padding: 11px 12px;
        font-size: 13px;
    }

    .chat-form button {
        padding: 11px 14px;
        font-size: 13px;
    }
}

/* ===== Markdown styling for AI responses ===== */

.message.bot p {
    margin-bottom: 10px;
}

.message.bot ul,
.message.bot ol {
    margin-left: 20px;
    margin-bottom: 10px;
}

.message.bot li {
    margin-bottom: 6px;
}

.message.bot strong {
    color: #38bdf8;
}

.message.bot h1,
.message.bot h2,
.message.bot h3 {
    margin-top: 10px;
    margin-bottom: 8px;
}

.message.bot code {
    background: #1e293b;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 13px;
}


.chat-box::-webkit-scrollbar {
    width: 8px;
}

.chat-box::-webkit-scrollbar-thumb {
    background: #1f2937;
    border-radius: 8px;
}