/* General Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    background-color: #f4f6f9;
    color: #333;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

button {
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s, border-color 0.2s;
}

button:hover {
    opacity: 0.9;
}

/* Login Page */
.login-container {
    padding: 40px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-container h2 {
    text-align: center;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box;
}

#login-form button {
    width: 100%;
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.error-message {
    color: #dc3545;
    text-align: center;
    margin-top: 15px;
    min-height: 20px;
}


/* Main App Layout */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    height: 60px;
    background-color: #fff;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

header h1 {
    font-size: 20px;
}

#logout-button {
    background-color: #dc3545;
    color: white;
}

.main-container {
    overflow: hidden; /* Prevent scrolling on the main container */
}

.sidebar {
    background-color: #f8f9fa; /* A slightly different color to distinguish sidebars */
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 57px); /* Full height minus header */
    overflow-y: auto;
}

.sidebar h2 {
    font-size: 18px;
    margin-top: 0;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

/* Bots List - now uses Bootstrap's nav-pills */
#bots-list .nav-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #333;
}

#bots-list .nav-link.active {
    background-color: #007bff;
    color: white;
}

#bots-list .nav-link:not(.active):hover {
    background-color: #e9ecef;
}

#add-bot-button {
    line-height: 1;
}

.delete-bot-button {
    background: none;
    border: none;
    color: #dc3545;
    opacity: 0.5;
    padding: 0 5px;
    font-size: 1.2rem;
    line-height: 1;
}
.delete-bot-button:hover {
    opacity: 1;
}

#bots-list .nav-link.active .delete-bot-button {
    color: white;
}

/* Chat Container */
.chat-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    height: calc(100vh - 57px); /* Header height (56px + 1px border) */
}

#chat-header {
    padding: 1rem; /* Use rem for spacing */
    border-bottom: 1px solid #e0e0e0;
    background: #fcfcfc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Не сжимается */
}

#chat-header h2 {
    margin: 0;
    font-size: 18px;
}

.bot-name-input {
    border: none;
    font-size: 18px;
    font-weight: bold;
    padding: 4px;
    border-radius: 4px;
}

.bot-name-input:focus {
    outline: 1px solid #007bff;
}

#save-bot-name-button {
    background-color: #28a745;
    color: white;
    margin-left: 10px;
}

/* Табы чата */
#main-tabs-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#tab-chat {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

#chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Важно для правильной работы flex */
}

.message {
    padding: 10px 15px;
    border-radius: 18px;
    margin-bottom: 10px;
    max-width: 70%;
    line-height: 1.5;
    word-wrap: break-word;
}

.user-message {
    background-color: #007bff;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.bot-message {
    background-color: #e9ecef;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.system-message {
    font-size: 0.65rem;
    color: #6c757d;
    text-align: right;
    align-self: stretch;
    background-color: transparent;
    max-width: 100%;
    opacity: 0.7;
    padding: 0 10px;
    box-sizing: border-box;
}

.message .message-content {
    white-space: pre-wrap;
}

.message .message-time {
    font-size: 0.6rem;
    color: #888;
    margin-top: 5px;
    opacity: 0.7;
    text-align: right;
}

.user-message .message-time {
    color: #f1f1f1;
}

#chat-input-container {
    display: flex;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background-color: #fff;
    flex-shrink: 0; /* Не сжимается */
}

#chat-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    resize: none;
    margin-right: 10px;
    min-height: 40px;
    max-height: 120px;
    font-family: inherit;
}

#send-button {
    background-color: #007bff;
    color: white;
    align-self: flex-end;
    min-height: 40px;
}

/* Knowledge Base Sidebar */
#knowledge-sidebar {
    border-right: none;
    border-left: 1px solid #e0e0e0;
}

#documents-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
    word-break: break-all;
}

#documents-list .doc-name {
    flex-grow: 1;
    margin-right: 10px;
}

#upload-container {
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    margin-top: 20px;
}
#upload-button {
    width: 100%;
    margin-top: 10px;
    background-color: #17a2b8;
    color: white;
}

.delete-doc-button {
    background: none;
    border: none;
    color: #dc3545;
    padding: 0 5px;
    opacity: 0.7;
}
.delete-doc-button:hover {
    opacity: 1;
}

.download-doc-button {
    background: none;
    border: none;
    padding: 0 5px;
    margin-right: 10px;
    opacity: 0.7;
    cursor: pointer;
    font-size: 1.1em;
}

.download-doc-button:hover {
    opacity: 1;
}

/* Toggle Switch (восстановлено) */

#channels-section { padding: 10px; }

.chat-message.assistant .message-content {
    background-color: #f1f0f0;
    color: #000;
    align-self: flex-start;
}

.chat-message.system {
    font-size: 0.8rem;
    color: #6c757d;
    text-align: center;
    margin: 10px 0;
}

/* .chat-message .message-time {
    font-size: 0.75rem;
    color: #888;
    margin-top: 5px;
    text-align: right;
} */

#bot-settings-container h5 {
    margin-top: 1rem;
}

.rotate-180 {
  transform: rotate(180deg);
  transition: transform 0.2s;
}

.form-switch.form-switch-sm .form-check-input {
  height: 0.8em;
  width: 1.5em;
  min-height: unset;
  border-radius: 1em;
}

/* Диалоги (новая вкладка) */
#dialogs-list {
    background: #fff;
    min-height: 200px;
    border-right: 1px solid #e0e0e0;
}
/* .dialog-item.bg-light {
    background: #f4f6f9 !important;
} */
.dialog-item.selected {
    background: #e9ecef !important;
}
.dialog-item:hover {
    background: #f0f0f0;
}
#dialog-header-info {
    font-size: 1.1rem;
}
#dialog-bot-toggle {
    min-width: 120px;
}
#dialog-messages {
    background: #f8f9fa;
    min-height: 200px;
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
#dialog-input-container {
    display: flex;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background-color: #fff;
    flex-shrink: 0;
    position: static;
    min-height: unset;
    /* z-index: auto; */
    box-shadow: none;
}
/* Аватар */
.dialog-item .rounded-circle {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    background: #007bff;
    color: #fff;
}
/* Сообщения */
#dialog-messages .user-message {
    background: #007bff;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    margin-left: auto;
    margin-right: 0;
    max-width: 70%;
}
#dialog-messages .bot-message {
    background: #e9ecef;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    margin-right: auto;
    margin-left: 0;
    max-width: 70%;
}
#dialog-messages .message {
    padding: 10px 15px;
    border-radius: 18px;
    margin-bottom: 10px;
    line-height: 1.5;
    word-wrap: break-word;
    display: inline-block;
}

#dialog-messages .message .message-content {
    white-space: pre-wrap;
}
/* #dialog-messages .message-time {
    font-size: 0.85rem;
    color: #222;
    margin-top: 5px;
    opacity: 0.8;
    text-align: right;
    font-weight: 500;
}  */

/* Индикатор новых сообщений */
.new-message-indicator {
    animation: pulse 2s infinite;
    transition: all 0.3s ease;
}

.new-message-indicator:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.indicator-content {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

@keyframes pulse {
    0% {
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }
    50% {
        box-shadow: 0 2px 8px rgba(0,123,255,0.4);
    }
    100% {
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }
}

.clear-dialog-icon {
    color: #fd7e14; /* Оранжевый Bootstrap warning */
    cursor: pointer;
    font-size: 1.3rem;
    margin-right: 8px;
    transition: color 0.2s, transform 0.2s;
}
.clear-dialog-icon:hover {
    color: #ff9800;
    transform: scale(1.15);
}

.delete-dialog-icon {
    color: #dc3545; /* Красный Bootstrap danger */
    cursor: pointer;
    font-size: 1.3rem;
    transition: color 0.2s, transform 0.2s;
}
.delete-dialog-icon:hover {
    color: #b71c1c;
    transform: scale(1.15);
}

/* Стили для кнопки "Очистить историю" в тест-чате */
#clear-history-button {
    color: #fd7e14; /* Оранжевый Bootstrap warning */
    border-color: #fd7e14;
    transition: all 0.2s ease;
}

#clear-history-button:hover {
    color: #fff;
    background-color: #fd7e14;
    border-color: #fd7e14;
    transform: scale(1.05);
}

#clear-history-button:focus {
    color: #fff;
    background-color: #fd7e14;
    border-color: #fd7e14;
    box-shadow: 0 0 0 0.2rem rgba(253, 126, 20, 0.25);
}