/* style.css - Minimalistic NeuroHub Style - Адаптировано для мобильных */
body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    color: #e0e0e0;
    background-color: #181818;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 100%;
    height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    transition: margin-left 0.25s ease-out;
}

.chat-list {
    width: 250px;
    border-right: 1px solid #2a2a2a;
    padding: 15px;
    display: flex;
    flex-direction: column;
    background-color: #212121;
    box-shadow: none;
    z-index: 2; /* Ensure sidebar is above chat window on mobile */
    position: relative;
    transition: width 0.25s ease-out, padding 0.25s ease-out, left 0.25s ease-out; /* Added left for mobile slide animation */
    left: 0;
    overflow-x: hidden; /*  Prevent horizontal scroll for collapsed sidebar content */
}

.chat-list.collapsed {
    width: 0;
    padding: 0;
    overflow: hidden;
    border-right: none;
    left: -250px; /* Slide off screen to the left when collapsed */
}

.chat-list.collapsed + .chat-window {
    margin-left: 0;
}

.chat-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.chat-list h2 {
    margin-top: 0;
    margin-bottom: 0;
    font-size: 1.2rem;
    color: #fff;
    font-weight: 500;
}

#toggle-sidebar-btn, #show-sidebar-btn {
    background-color: transparent;
    border: none;
    color: #757575;
    cursor: pointer;
    font-size: 1.1rem; /* Slightly larger icon for mobile touch */
    transition: color 0.2s ease-out;
    padding: 8px; /* Larger padding for touch target */
    border-radius: 3px;
    align-self: center;
}

#toggle-sidebar-btn:hover, #show-sidebar-btn:hover {
    color: #fff;
    background-color: #303030;
}

/*  Modified toggle button appearance */
#toggle-sidebar-btn {
    color: #fff; /*  White color for close icon when sidebar is open */
    background-color: #3a8bcd; /* Blue background to indicate active close state */
    border-radius: 50%; /* Circular shape */
    width: 28px; /*  Fixed width to maintain circular shape */
    height: 28px; /* Fixed height to maintain circular shape */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0; /* Reset padding to fit content within circle */
    font-size: 1rem; /* Adjust font size to fit circle */
}
#toggle-sidebar-btn:hover {
    background-color: #4375ad; /* Darker blue on hover */
    color: #fff; /* Keep white on hover */
}


#new-chat-btn {
    margin-bottom: 12px;
    font-size: 0.9rem;
    padding: 9px 15px;
}

#chat-list-ul {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    height: 0;
    flex-grow: 1;
}

#chat-list-ul li {
    padding: 8px 12px;
    border-bottom: 1px solid #303030;
    cursor: pointer;
    transition: background-color 0.2s ease-out;
    word-wrap: break-word;
    color: #ddd;
    font-size: 0.9rem;
}

#chat-list-ul li:last-child {
    border-bottom: none;
}

#chat-list-ul li:hover,
#chat-list-ul li.active {
    background-color: #2a2a2a;
}

.chat-window {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    background-color: #181818;
    margin-left: 0;
    transition: margin-left 0.25s ease-out;
}

.chat-window.sidebar-collapsed {
    margin-left: 0;
}


.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center; /* Center items vertically in header */
    margin-bottom: 15px;
    border-bottom: 1px solid #2a2a2a;
    padding-bottom: 8px;
    position: sticky; /* Stick the header to the top */
    top: 0;
    background-color: #181818; /* Ensure background for sticky header */
    z-index: 1; /*  Ensure header is above content */
}

.chat-header-title {
    display: flex;
    align-items: center; /* Align items in header title vertically */
}

.chat-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100% - 60px); /* Adjust max-width to account for buttons */
    font-weight: 500;
}

.model-name {
    font-size: 0.8rem;
    color: #9e9e9e;
    margin-left: 10px; /* Add some space between title and model name if they are on one line */
}


.chat-actions {
    display: flex;
    gap: 6px;
    align-items: center; /* Center actions vertically in header */
}

.chat-actions button {
    font-size: 1.2rem;
    margin-left: 0;
    color: #757575;
    transition: color 0.2s ease-out, background-color 0.2s ease-out;
    padding: 6px;
    border-radius: 3px;
    background-color: transparent; /* Make buttons in header transparent initially */
    border: none; /* Remove default button borders */
}


.chat-actions button:hover {
    color: #fff;
    background-color: #303030; /*  Provide background on hover for clarity */
}

#show-sidebar-btn {
    margin-right: 10px; /* Space between show sidebar button and title on mobile */
}


#message-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
    max-height: none;
}

.user-message, .ai-message {
    padding: 10px 15px;
    border-radius: 20px;
    margin-bottom: 10px;
    clear: both;
    word-wrap: break-word;
    max-width: 85%;
    font-size: 0.9rem;
    line-height: 1.3;
    white-space: pre-wrap; /*  to handle new lines correctly */
}

.user-message {
    background-color: #3a8bcd;
    color: #fff;
    align-self: flex-end;
    float: right;
}

.ai-message {
    background-color: #2a2a2a;
    color: #ddd;
    align-self: flex-start;
    float: left;
}

/* Style for bold text formatting */
.ai-message b, .user-message b {
    font-weight: bold; /* Make **text** bold */
}


.input-area {
    display: flex;
    align-items: center;
    border-top: 1px solid #2a2a2a;
    padding-top: 10px;
    background-color: #181818; /*  Match background with main content for consistent look */
}

#message-input {
    flex-grow: 1;
    padding: 10px;
    border-radius: 3px;
    border: 1px solid #303030;
    background-color: #2a2a2a;
    color: #e0e0e0;
    resize: none;
    margin-right: 8px;
    min-height: 40px;
    max-height: 100px;
    overflow-y: auto;
    font-size: 0.9rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

#message-input::placeholder {
    color: #666;
}

/* --- Button Styles - Minimalistic --- */
.button {
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.9rem;
    text-align: center;
    transition: background-color 0.2s ease-out, color 0.2s ease-out, border-color 0.2s ease-out;
    box-shadow: none;
    font-weight: 500;
}

.primary-button {
    background-color: #5893d8;
    color: #fff;
}

.primary-button:hover {
    background-color: #4375ad;
}

.secondary-button {
    background-color: transparent;
    color: #bbb;
    border-color: #555;
}

.secondary-button:hover {
    color: #fff;
    border-color: #fff;
    background-color: #303030;
}

.send-button {
    padding: 10px 16px;
}

.save-button, .cancel-button {
    padding: 9px 15px;
    font-size: 0.9rem;
}


.delete-button {
    background-color: #d9534f;
    color: #fff;
}

.delete-button:hover {
    background-color: #c9302c;
}

.chat-action-button {
    background-color: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    margin-left: 0;
    color: #757575;
    transition: color 0.2s ease-out, background-color 0.2s ease-out;
    padding: 6px;
    border-radius: 3px;
}

.chat-action-button:hover {
    color: #fff;
    background-color: #303030;
}


/* --- Modal Styles - Minimalistic --- */
.modal {
    display: none;
    position: fixed;
    z-index: 3; /* Ensure modals are above sidebar on mobile */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
}

.modal-content {
    background-color: #212121;
    margin: 15% auto; /*  Increased margin on top for mobile view */
    padding: 20px;
    border: 1px solid #303030;
    width: 90%; /* Increased modal width on mobile */
    max-width: 600px; /*  Adjust max-width if needed */
    border-radius: 5px;
    box-shadow: 0 3px 5px rgba(0,0,0,0.3);
    color: #e0e0e0;
}

.close-button {
    color: #999;
    position: absolute;
    top: 5px;
    right: 8px;
    font-size: 24px;
    font-weight: normal;
    text-shadow: none;
}

.close-button:hover,
.close-button:focus {
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

.modal-content h2 {
    color: #fff;
    font-size: 1.4rem;
    margin-bottom: 15px;
    font-weight: 500;
}

.modal-content label,
.modal-content input,
.modal-content textarea,
.modal-content .button {
    display: block;
    margin-bottom: 15px;
    width: calc(100% - 22px);
    padding: 10px;
    border-radius: 3px;
    border: 1px solid #303030;
    background-color: #2a2a2a;
    color: #e0e0e0;
    box-sizing: border-box;
    font-size: 0.9rem;
}

.modal-content textarea {
    min-height: 120px;
    resize: vertical;
}

.modal-buttons {
    text-align: right;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}


/* Адаптивность - медиа запросы для мобильных - Minimalistic Style adjustments*/
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    .container {
        flex-direction: column;
        height: auto;
        min-height: 95vh;
        width: 100%;
        margin-left: 0 !important;
    }

    .chat-list {
        position: fixed; /* Sidebar is fixed on top in mobile view */
        top: 0;
        left: -250px; /* Initially hidden off-screen */
        width: 250px;
        max-height: 100vh; /* Occupy full viewport height */
        height: 100vh;
        border-bottom: none;
        border-right: 1px solid #2a2a2a; /*  Keep right border for distinction when visible */
        overflow-y: auto;
        padding: 15px;
        z-index: 1000; /* High z-index to overlay other content */
        background-color: #212121; /*  Ensure background color covers fully */
    }

    .chat-list.collapsed {
        left: -250px; /*  Remain off-screen when collapsed */
        width: 0; /*  Collapse width for smooth transition */
        padding: 0; /* Collapse padding too */
    }
    .chat-list.slide-in { /* Class to slide in the sidebar */
        left: 0; /* Slide in from left to be visible */
    }


    .chat-list-header {
        margin-bottom: 8px;
    }


    .chat-list h2 {
        font-size: 1.1rem;
    }

    #toggle-sidebar-btn, #show-sidebar-btn {
        font-size: 1rem;
        padding: 6px;
    }
     /* Modified mobile toggle button position */
    #toggle-sidebar-btn {
        position: absolute; /* Position it absolutely within chat list */
        top: 10px;
        right: 10px;
        z-index: 1001; /* Ensure it is above the sidebar content */
        /* Styles remain from general definition for circle button */
    }


    #new-chat-btn {
        margin-bottom: 10px;
        font-size: 0.8rem;
        padding: 8px 12px;
    }

    #chat-list-ul li {
        padding: 6px 10px;
        font-size: 0.8rem;
    }


    .chat-window {
        padding: 15px;
        margin-left: 0 !important;
    }

    .chat-header {
        margin-bottom: 12px;
        padding-bottom: 6px;
        position: fixed; /* Header stays fixed on top on mobile */
        top: 0;
        left: 0;
        right: 0;
        z-index: 100; /* Ensure header is above chat content */
        background-color: #181818; /* Ensure header background on mobile */
    }

    .chat-header h2 {
        font-size: 1.2rem;
        max-width: calc(100% - 80px); /*  Adjust width for smaller screens and buttons */
    }

    .model-name {
        font-size: 0.7rem;
    }

    .chat-actions button {
        font-size: 1rem;
        padding: 5px;
    }

    #message-area {
        margin-bottom: 8px;
        padding-top: 60px; /* Add padding below fixed header to avoid overlap */
    }

    .user-message, .ai-message {
        padding: 8px 12px;
        font-size: 0.85rem;
        border-radius: 18px;
        margin-bottom: 8px;
    }

    .input-area {
        padding-top: 8px;
        margin-top: auto; /* Input area sticks to the bottom */
        padding-bottom: 10px; /*  Padding at the bottom of input area for spacing */
    }

    #message-input {
        padding: 8px;
        font-size: 0.9rem;
        min-height: 35px;
    }


    .modal-content {
        width: 95%;
        margin-top: 20%; /* Adjust modal top margin for mobile */
        padding: 15px;
    }
    .modal-content h2 {
        font-size: 1.3rem;
        margin-bottom: 12px;
    }

    .modal-content label,
    .modal-content input,
    .modal-content textarea,
    .modal-content .button {
        padding: 8px;
        margin-bottom: 12px;
        font-size: 0.8rem;
    }


    .modal-buttons button {
        padding: 8px 12px;
    }


    .close-button {
        font-size: 22px;
        top: 3px;
        right: 5px;
    }

    .button {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    #show-sidebar-btn {
        display: inline-flex !important; /* Always show on mobile to open sidebar */
        align-items: center; /* Center icon vertically */
    }
    #toggle-sidebar-btn {
        display: none; /* Hide default toggle on mobile, use show-sidebar-btn instead */
    }

    .chat-list.collapsed #toggle-sidebar-btn {
        display: none; /*  Ensure toggle button is hidden when collapsed on mobile */
    }
    .chat-list:not(.collapsed) #toggle-sidebar-btn {
        display: flex; /* Show only when sidebar is not collapsed on mobile */
    }

}

/* Для очень маленьких экранов (320px и меньше) - еще более строгая адаптация*/
@media (max-width: 320px) {
    body {
        font-size: 12px;
    }
    .chat-list {
        max-height: 100vh;
        padding: 10px;
    }

     .chat-list-header {
        margin-bottom: 6px;
    }

    .chat-list h2 {
        font-size: 1rem;
    }

    #toggle-sidebar-btn, #show-sidebar-btn {
        font-size: 0.9rem;
        padding: 5px;
    }

    #new-chat-btn {
        margin-bottom: 8px;
        font-size: 0.7rem;
        padding: 6px 10px;
    }

    #chat-list-ul li {
        padding: 5px 8px;
        font-size: 0.7rem;
    }

     .chat-window {
        padding: 10px;
    }

    .chat-header {
        margin-bottom: 10px;
        padding-bottom: 5px;
    }

    .chat-header h2 {
        font-size: 1.1rem;
    }
    .model-name {
        font-size: 0.6rem;
        margin-top: 2px;
    }

     .chat-actions button {
        font-size: 0.9rem;
        padding: 4px;
    }


    .user-message, .ai-message {
        padding: 6px 10px;
        font-size: 0.8rem;
        border-radius: 16px;
        margin-bottom: 6px;
    }

    .input-area {
        padding-top: 6px;
    }

    #message-input {
        padding: 6px;
        font-size: 0.8rem;
        min-height: 30px;
    }

    .modal-content {
        margin-top: 15%;
        padding: 10px;
    }
    .modal-content h2 {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }
    .modal-content label,
    .modal-content input,
    .modal-content textarea,
    .modal-content .button {
        margin-bottom: 10px;
        padding: 6px;
        font-size: 0.7rem;
    }
     .modal-buttons button {
        padding: 6px 10px;
    }

    .close-button {
        font-size: 20px;
        top: 2px;
        right: 3px;
    }

     .button {
        padding: 6px 10px;
        font-size: 0.7rem;
    }
}