body {
    display: flex;
    margin: 0;
    font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", Segoe UI Symbol, "Noto Color Emoji";
    background-color: #ececec;
    color: #1f1f1f;
    font-size: 0.8rem;
    min-height: 100vh;
}

.container {
    display: flex;
    width: 100%;
}

.nav-section {
    height: calc(100vh - 50px);
    width: 260px;
    padding: 25px 30px;
    box-sizing: border-box;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.nav-section .new-chat-button {
    margin-top: 50px;
    width: 100%;
    padding: 10px 0;
    border: none;
    background-color: #444aee;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
    transition: 0.3s;
}

.nav-section .new-chat-button:hover {
    background-color: #7e82f6;
    transition: 0.3s;
}

.nav-section .new-chat-button i {
    margin-right: 10px;
}

.nav-section .Application-name {
    display: flex;
    align-items: center;
}

.nav-section .Application-name .image {
    width: 50px;
    height: auto;
}

.nav-section .Application-name .text {
    margin-left: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #3b8253;
}

.chat-section {
    flex-grow: 1;
    height: 100vh;
    padding: 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.chat-panel {
    background-color: #fff;
    width: 100%;
    height: 100%;
    border-radius: 15px;
    border: 1px solid #e8e8e8;
    padding: 25px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-panel .chat-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.chat-panel .chat-messages-panel {
    flex-grow: 1;
    overflow-y: auto;
    position: relative;
    padding-bottom: 95px;
}

.status-indicator-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 5px 0 10px 0;
    height: auto;
    margin-bottom: 5px;
    overflow: hidden;
    flex-shrink: 0;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.75rem;
    border: 1px solid transparent;
    transition: all 0.3s ease-in-out;
}

.status-badge.pending { background-color: #e0e0e0; color: #666; border-color: #d0d0d0; }
.status-badge.active { background-color: #e3f2fd; color: #1565c0; border-color: #90caf9; font-weight: 600; }
.status-badge.completed { background-color: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }
.status-badge.streaming { background-color: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }

.status-badge i { font-size: 0.8rem; }

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.fa-spinner { animation: spin 1.5s linear infinite; }

.chat-panel .chat-new-message {
    position: fixed;
    bottom: 40px;
    left: calc(260px + 15px + 25px);
    right: calc(15px + 25px);
    height: 75px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fff;
    padding: 0 10px;
    box-sizing: border-box;
    border-top: 1px solid #e8e8e8;
    border-radius: 0 0 15px 15px; /* Match panel if visually connected */
    z-index: 50;
}

.chat-panel .chat-new-message .message-input-field {
    height: 20px;
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 10px;
    padding: 10px;
    margin-right: 15px;
}

.chat-panel .chat-new-message .message-input-field:focus-visible {
    outline: #000 auto 1px;
    outline-offset: 5px;
}

.chat-panel .chat-new-message .message-send-button {
    width: 80px;
    height: 40px;
    background-color: #444aee;
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

.chat-panel .chat-new-message .message-send-button:hover, .chat-panel .chat-new-message .message-send-button:focus {
    outline: #000 auto 1px;
    outline-offset: 5px;
}

.mr-5 {
    margin-right: 5px;
}

.chat-panel .chat-messages-panel .options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    position: absolute;
    bottom: 85px; /* Above where chat-new-message would visually be if it wasn't fixed */
    left: 0;
    right: 0;
    padding: 0 10px; /* Align with messages padding */
}

.chat-panel .chat-messages-panel .card {
    background-color: #ececec;
    padding: 20px;
    border-radius: 10px;
    cursor: pointer;
    opacity: 1;
    transition: 0.3s;
}
.chat-panel .chat-messages-panel .card:hover {
    box-shadow: 0px 0px 10px 5px #c9c9c9;
}

.recent-chats-panel {
    margin-top: 40px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.recent-chats {
    list-style-type: none;
    padding-inline-start: 0px;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    margin-right: -10px; /* Offset scrollbar space if visible */
    padding-right: 10px; /* Counteract margin */
}

.recent-chats li {
    cursor: pointer;
    padding: 10px 12px;
    width: calc(100% - 24px);
    box-sizing: border-box;
}

.recent-chats li a {
    text-decoration: none;
    float: right;
    color: #fff;
    font-size: 1rem;
    margin-top: -1rem;
    display: none;
}

.recent-chats li:hover {
    background-color: #444aee;
    color: #fff;
    border-radius: 10px;
    opacity: 1;
    transition: 0.2s;
}

.recent-chats li.active_chat {
    background-color: #444aee;
    color: #fff;
    border-radius: 10px;
}

.recent-chats li:hover a {
    display: block;
}

h3 {
    font-size: 1.1rem;
    margin-block-start: 0.5em;
    margin-block-end: 0.5em;
}

#message-suggestions {
    display: block; /* Controlled by JS */
    height: 100%; /* To allow absolute positioning of .options */
}

.user-message {
    display: flex !important;
    justify-content: flex-end;
    margin-bottom: 25px !important;
    clear: both;
}

.assistant-message {
    display: flex !important;
    justify-content: flex-start;
    margin-bottom: 25px !important;
    clear: both;
}

.message-wrapper {
    max-width: 100%;
    display: flex;
    scrollbar-width: none;
}

.user-message .message-wrapper {
    flex-direction: row-reverse;
}

.chat-messages {
    display: none; /* Controlled by JS */
    padding: 0 10px;
}

.chat-messages img {
    width: 30px;
    height: 30px;
    padding: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chat-messages .user-message img {
    background-color: #a2a4f863;
    margin-left: 10px;
}

.chat-messages .assistant-message img {
    margin-right: 10px;
}

.message {
    padding: 10px 15px;
    border-radius: 10px;
    word-wrap: break-word;
}

.user-message .message {
    background-color: #a2a4f885;
}

.assistant-message .message {
    background: #ececec;
}

.message-timestamp {
    padding-top: 5px;
    color: #7e7e7e;
    display: block;
    font-size: 0.7rem;
    clear: both;
}

.user-message .message-timestamp {
    text-align: right;
    padding-right: 15px;
}
.assistant-message .message-timestamp {
    text-align: left;
    padding-left: 15px;
}

.bot-resources {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 16px;
    border-radius: 12px;
    margin-top: 16px;
    margin-bottom: 15px;
}

.bot-resources h6 {
    font-size: 14px;
    font-weight: bold;
    color: #374151;
    margin-block-start: 5px !important;
    margin-block-end: 10px !important;
}

.bot-resources ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.bot-resources li {
  margin-bottom: 10px;
}
.bot-resources li:last-child {
  margin-bottom: 0;
}

.bot-resources a {
    color: #2563eb;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.bot-resources a i {
    margin-right: 10px;
}

.bot-resources a:hover {
  text-decoration: underline;
}

.bot-resources svg {
  margin-right: 8px;
  color: #3b82f6;
  width: 16px;
  height: 16px;
}

.message.error-text {
    color: red;
    font-style: italic;
    background-color: #ffebee;
    border: 1px solid #e57373;
    padding: 10px 15px;
    border-radius: 5px;
    width: 100%;
    box-sizing: border-box;
}
.message-wrapper.error {
    justify-content: center;
    max-width: 90%;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.logout {
    margin-top: 20px !important;
    background-color: #e06b6b !important;
    flex-shrink: 0;
}

.logout:hover, .logout:active {
    background-color: #cb4040 !important;
}

body.login-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; background-color: #f0f2f5; font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", Segoe UI Symbol, "Noto Color Emoji"; padding: 20px; box-sizing: border-box;}
.login-container { background: #fff; padding: 40px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); width: 100%; max-width: 400px; text-align: center; box-sizing: border-box;}
.login-container h2 { margin-bottom: 20px; color: #333; }
.login-form button, .otp-form button {
    width: 50%;
    padding: 10px;
    background-color: #444aee;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 15px;
}
.login-form button:hover, .otp-form button:hover { background-color: #3a40d0; }
.error-message {
    color: white;
    text-align: center;
    background: #e06b6b;
    margin: 0 auto 10px auto;
    max-width: calc(100% - 40px);
    padding: 15px 0px;
    border-radius: 5px;
    font-size: 0.85rem;
}
.app-logo-login { width: 70px; margin-bottom: 15px; }
.form-title { font-size: 1.4rem; font-weight: 600; color: #3b8253; margin-bottom: 25px; }
.otp-info { font-size: 0.85rem; margin-bottom: 15px; color: #555; }
.login-form input, .otp-form input {
    width: calc(100% - 24px);
    border: 1px solid #ccc;
    border-radius: 10px;
    padding: 10px;
    margin: 8px 0;
    box-sizing: border-box;
}

.login-form input:focus-visible, .otp-form input:focus-visible {
    outline: #000 auto 1px;
    outline-offset: 5px;
}


@media (max-width: 1024px) {
    .nav-section {
        width: 220px;
        padding: 20px;
    }
    .nav-section .Application-name .text {
        font-size: 1.3rem;
    }
    .chat-panel .chat-new-message {
        left: calc(220px + 15px + 25px); /* nav_width + chat_section_padding + chat_panel_padding */
    }
    .recent-chats {
        margin-right: -5px;
        padding-right: 5px;
    }
}


@media (max-width: 768px) {
    body:not(.login-page) {
        display: block; /* Override flex for main app layout */
    }
    .container {
        flex-direction: column;
        height: auto;
    }

    .nav-section {
        width: 100%;
        height: auto;
        padding: 15px;
        box-sizing: border-box;
        flex-direction: column;
        /* position: sticky; top: 0; background: #ececec; z-index: 100; */ /* Alternative sticky nav */
    }
    .nav-section .Application-name {
        justify-content: flex-start;
    }
    .nav-section .Application-name .image {
        width: 40px;
    }
    .nav-section .Application-name .text {
        font-size: 1.4rem;
    }
    .nav-section .new-chat-button {
        margin-top: 20px;
    }
    .recent-chats-panel {
        margin-top: 20px;
        height: 150px; /* Fixed height for recent chats on mobile */
        flex-grow: 0; /* Don't let it grow indefinitely */
    }
    .recent-chats {
        height: 100%; /* Fill the fixed height panel */
        margin-right: 0;
        padding-right: 0;
    }
    .logout {
        margin-top: 15px !important;
    }

    .chat-section {
        width: 100%;
        height: calc(100vh - (/* approximate nav height */ 280px)); /* Adjust if nav height changes */
        padding: 10px;
        box-sizing: border-box;
        /* If nav is sticky, add margin-top here */
    }

    .chat-panel {
        padding: 15px;
        border-radius: 10px;
    }
    .chat-panel .chat-title {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }
    .chat-panel .chat-messages-panel {
         padding-bottom: 75px; /* Space for fixed input */
    }
    .chat-panel .chat-new-message {
        left: 0;
        right: 0;
        bottom: 0;
        height: auto;
        padding: 10px 15px;
        border-radius: 0;
        border-top: 1px solid #e0e0e0;
    }
    .chat-panel .chat-new-message .message-input-field {
        height: 18px;
        padding: 8px;
        font-size: 0.9rem;
        margin-right: 10px;
    }
    .chat-panel .chat-new-message .message-send-button {
        width: auto;
        padding: 8px 12px;
        height: auto;
        font-size: 0.9rem;
    }
    .chat-panel .chat-new-message .message-send-button i {
        margin-right: 5px;
    }

    .chat-panel .chat-messages-panel .options {
        grid-template-columns: 1fr;
        gap: 10px;
        position: static; /* Flow normally */
        padding: 0;
        margin-top: 10px;
        margin-bottom: 125px;
    }
    .chat-panel .chat-messages-panel .card {
        padding: 15px;
    }
    .chat-panel .chat-messages-panel .card h3 {
        font-size: 1rem;
    }
    .chat-panel .chat-messages-panel .card p {
        font-size: 0.85rem;
    }

    .message-wrapper {
        max-width: 100%;
    }
    .chat-messages {
        padding: 0;
    }

    .login-container {
        padding: 25px;
        margin: 0;
    }
    .app-logo-login {
        width: 60px;
    }
    .form-title {
        font-size: 1.3rem;
    }
    .login-form input, .otp-form input {
        padding: 12px;
        font-size: 0.95rem;
    }
    .login-form button, .otp-form button {
        width: 100%;
        padding: 12px;
    }
    .error-message {
        max-width: 100%;
        padding: 10px;
        font-size: 0.8rem;
    }
}


@media (max-width: 480px) {
    .nav-section .Application-name .image {
        width: 35px;
    }
    .nav-section .Application-name .text {
        font-size: 1.2rem;
        margin-left: 8px;
    }
    .nav-section .new-chat-button, .nav-section .logout {
        font-size: 0.9rem;
        padding: 8px 0;
    }
    .recent-chats-panel {
        height: 120px;
    }
    .chat-section {
         height: calc(100vh - (/* approximate nav height */ 260px)); /* Adjust if nav height changes */
    }

    .chat-panel .chat-title {
        font-size: 1.1rem;
    }
    .chat-panel .chat-new-message {
        padding: 8px 10px;
    }
    .chat-panel .chat-new-message .message-input-field {
        font-size: 0.85rem;
    }
    .chat-panel .chat-new-message .message-send-button {
        font-size: 0.85rem;
    }
    .chat-panel .chat-new-message .message-send-button .fa-paper-plane {
        margin-right: 3px;
    }
    .message-wrapper {
        max-width: 100%;
    }
    .login-container {
        padding: 20px;
    }
    .app-logo-login {
        width: 50px;
    }
    .form-title {
        font-size: 1.2rem;
    }
}

/* Edit Message Styles */
.edit-message-container {
    margin-top: 10px;
    padding: 15px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.edit-message-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.edit-message-input {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 10px;
    color: #1f1f1f;
    padding: 10px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s ease;
}

.edit-message-input:focus {
    outline: #000 auto 1px;
    outline-offset: 5px;
    border-color: #444aee;
}

.edit-message-input::placeholder {
    color: #7e7e7e;
}

.edit-message-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.edit-save-btn {
    background: #444aee;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    min-width: 140px;
    justify-content: center;
}

.edit-save-btn:hover:not(:disabled) {
    background: #7e82f6;
}

.edit-save-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.edit-cancel-btn {
    background: #ececec;
    color: #1f1f1f;
    border: 1px solid #ccc;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    min-width: 80px;
    justify-content: center;
}

.edit-cancel-btn:hover {
    background: #ddd;
}

.edit-message-btn {
    background: transparent;
    border: none;
    color: #7e7e7e;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 12px;
    transition: all 0.3s ease;
    margin-left: 8px;
}

.edit-message-btn:hover {
    background: #ececec;
    color: #1f1f1f;
}

.edit-message-btn i {
    margin-right: 4px;
}

.edit-saving {
    opacity: 0.7;
    pointer-events: none;
}

.edit-saving .edit-save-btn {
    background: #ccc;
}

/* Loading animation for save button */
.edit-save-btn .loading-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Message actions styling */
.message-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
}

/* Mobile responsiveness for edit interface */
@media (max-width: 768px) {
    .edit-message-container {
        padding: 12px;
        margin-top: 8px;
    }
    
    .edit-message-input {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 70px;
    }
    
    .edit-message-actions {
        flex-direction: column-reverse;
    }
    
    .edit-save-btn,
    .edit-cancel-btn {
        width: 100%;
        justify-content: center;
    }
    
    .edit-message-btn {
        font-size: 11px;
        padding: 2px 6px;
    }
}