/* Reset and base layout */
html, body {
    margin: 0;
    padding: 0;
    background-color: #0b1e2d;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
}

/* Use dynamic viewport height to avoid iOS 100vh bugs */
body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1rem;
    overflow: hidden;
}

/* Container that fits the screen */
#chat-container {
    background-color: #ffffff;
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
    max-width: 900px;
    width: 100%;
    height: 100dvh; /* responsive height */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header styling */
.chat-header {
    color: #0b1e2d;
    font-size: 1.25rem;
    font-weight: bold;
}

/* Chat area */
#chat-box {
    flex: 1;
    overflow-y: auto;
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1px solid #dee2e6;
    margin-bottom: 0.5rem;
}

/* Chat messages */
.user-msg, .bot-msg {
    margin-bottom: 1rem;
}

.user-msg {
    text-align: right;
}

.user-msg div {
    background-color: #d1e7dd;
    color: #0f5132;
    border-radius: 1rem 1rem 0 1rem;
}

.bot-msg {
    text-align: left;
}

.bot-msg div {
    background-color: #e2e3e5;
    color: #41464b;
    border-radius: 1rem 1rem 1rem 0;
}

.user-msg div, .bot-msg div {
    display: inline-block;
    padding: 0.75rem 1rem;
    max-width: 80%;
    font-weight: 500;
    word-wrap: break-word;
}

/* Input area fixed at bottom */
#chat-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: white;
    position: sticky;
    bottom: 0;
    z-index: 10;
    border-top: 1px solid #ccc;
}

#chat-form .form-control {
    flex: 1;
    border-radius: 0.5rem 0 0 0.5rem;
    padding: 0.75rem;
}

#chat-form .btn {
    border-radius: 0 0.5rem 0.5rem 0;
    padding: 0.75rem 1rem;
    background-color: #0d6efd;
    color: white;
    border: none;
}

/* Modal content */
.modal-content {
    color: #000000;
}

/* Dark Mode Support */
body.dark-mode {
    background-color: #121212;
    color: #f8f9fa;
}

body.dark-mode #chat-container {
    background-color: #1e1e1e;
    color: #f8f9fa;
}

body.dark-mode #chat-box {
    background-color: #2a2a2a;
    border-color: #444;
}

body.dark-mode .bot-msg div {
    background-color: #343a40;
    color: #f8f9fa;
}

body.dark-mode .user-msg div {
    background-color: #0d6efd;
    color: #ffffff;
}

body.dark-mode #message-input {
    background-color: #1c1c1c;
    color: #ffffff;
    border-color: #555;
}

body.dark-mode .form-control::placeholder {
    color: #bbbbbb;
}

body.dark-mode .btn {
    border-color: #999;
}

body.dark-mode .btn-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.chat-title {
    color: #222;
}
body.dark-mode .chat-title {
    color: #f0f0f0;
}

.dark-mode .modal-content {
    background-color: #2c2c2c;
    color: #fff;
}

.dark-mode .form-control,
.dark-mode .form-select {
    background-color: #3c3c3c;
    color: #fff;
    border-color: #555;
}

.dark-mode .form-control::placeholder {
    color: #bbb;
}

.assistant-message {
    background-color: var(--assistant-bg, #e5e5e5);
    color: var(--assistant-text, #000);
    padding: 10px 12px;
    margin: 8px;
    border-radius: 10px;
    max-width: 80%;
    align-self: flex-start;
    font-size: 0.95rem;
    line-height: 1.4;
}

body.dark-mode .assistant-message {
    background-color: #3a3a3a;
    color: #f0f0f0;
}

/* Responsive improvements */
@media screen and (max-width: 600px) {
    #chat-container {
        border-radius: 0;
        padding: 1rem 0.5rem;
    }

    .chat-header {
        font-size: 1.1rem;
    }

    #chat-form .form-control {
        font-size: 1rem;
    }

    #chat-form .btn {
        font-size: 1rem;
    }

    .user-msg div, .bot-msg div {
        max-width: 90%;
        font-size: 0.95rem;
    }
}

body.dark-mode #chat-form {
    background-color: #1c1c1c;
    border-top: 1px solid #333;
}

body.dark-mode .form-control {
    background-color: #2a2a2a;
    color: #f8f9fa;
    border-color: #444;
}

body.dark-mode .form-control::placeholder {
    color: #999;
}

body.dark-mode .btn {
    background-color: #0d6efd;
    color: white;
}
