:root {
    --primary-color: #0088cc;
    --secondary-color: #4CAF50;
    --danger-color: #ff4757;
    --bg-color: #f5f5f5;
    --card-color: #ffffff;
    --text-color: #333333;
    --border-color: #e0e0e0;
    --user-msg-bg: #DCF8C6;
    --bot-msg-bg: #F1F0F0;
    --streaming-color: #e3f2fd;
    --system-msg-bg: #e3f2fd;
    --system-msg-border: #bbdefb;
    --system-msg-color: #1565c0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    touch-action: manipulation;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100vw;
}

.app-header {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    z-index: 10;
}

.menu-btn, .profile-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-btn:hover, .profile-btn:hover {
    background-color: rgba(255,255,255,0.1);
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

/* Переключатель режимов */
.mode-switch {
    background-color: rgba(255, 255, 255, 0);
    padding: 8px 16px;
    display: flex;
    justify-content: center;
    gap: 20px;
    border-bottom: 1px solid rgb(0, 0, 0);
}

.mode-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 16px;
    transition: all 0.3s ease;
    font-size: 13px;
    font-weight: 500;
}

.mode-label:hover {
    background-color: rgba(255, 255, 255, 0);
}

.mode-label input[type="radio"] {
    margin-right: 6px;
    accent-color: white;
}

.mode-label span {
    color: rgb(0, 0, 0);
}

.mode-label input[type="radio"]:checked + span {
    color: rgb(0, 0, 0);
    font-weight: 600;
}

/* Стили для системных сообщений */
.system-message {
    background: var(--system-msg-bg);
    border: 1px solid var(--system-msg-border);
    border-radius: 12px;
    padding: 10px 15px;
    margin: 10px 15px;
    text-align: center;
    font-size: 14px;
    color: var(--system-msg-color);
    animation: fadeIn 0.3s ease;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.sidebar {
    width: 280px;
    background-color: var(--card-color);
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 5;
    transform: translateX(-100%);
}

.sidebar.active {
    transform: translateX(0);
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 16px;
    margin: 0;
    color: var(--primary-color);
}

.new-chat-btn {
    padding: 8px 12px;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    background-color: #45a049;
    transform: translateY(-1px);
}

.chat-list {
    padding: 8px 0;
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    margin: 4px 8px;
    background-color: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.chat-item:hover {
    background-color: #f0f0f0;
}

.chat-item.active {
    background-color: #e3f2fd;
    border-left: 3px solid var(--primary-color);
    font-weight: 600;
    color: var(--primary-color);
}

.chat-content {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.delete-chat-btn {
    background: none;
    border: none;
    color: var(--danger-color);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.delete-chat-btn:hover {
    opacity: 1;
    background-color: rgba(255, 71, 87, 0.1);
}

.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    position: relative;
}

.messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 80px;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    max-width: 500px;
    margin: 0 auto;
}

.welcome-message h3 {
    font-size: 20px;
    margin-bottom: 16px;
    color: var(--primary-color);
}

.welcome-message p {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.mode-explanation {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 20px 0;
}

.mode-option {
    padding: 15px;
    margin: 12px 0;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    background-color: #f8f9fa;
    transition: all 0.2s ease;
}

.mode-option:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.mode-option strong {
    color: var(--primary-color);
    font-size: 14px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.4;
    font-size: 14px;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.user {
    align-self: flex-end;
    background-color: var(--user-msg-bg);
    border-bottom-right-radius: 5px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.bot {
    align-self: flex-start;
    background-color: var(--bot-msg-bg);
    border-bottom-left-radius: 5px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

/* Улучшенные стили для структурированных сообщений в режиме плана */
.bot strong {
    color: var(--primary-color);
    display: block;
    margin: 10px 0 5px 0;
    font-size: 15px;
}

.bot ul {
    margin: 5px 0;
    padding-left: 20px;
}

.bot li {
    margin: 3px 0;
    line-height: 1.4;
}

/* Стили для потокового вывода */
.bot.streaming {
    background-color: var(--streaming-color);
    border-left: 3px solid var(--primary-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { border-left-color: var(--primary-color); }
    50% { border-left-color: #4fc3f7; }
    100% { border-left-color: var(--primary-color); }
}

.typing-indicator {
    display: inline-flex;
    color: #666;
    font-style: italic;
}

.typing-indicator::after {
    content: '...';
    animation: typing 1.5s infinite;
}

@keyframes typing {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background-color: var(--card-color);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
    z-index: 10;
}

#userInput {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    transition: all 0.2s ease;
    background-color: white;
}

#userInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 136, 204, 0.1);
}

.send-btn {
    width: 44px;
    height: 44px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.send-btn:hover {
    background-color: #0077b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.send-btn:active {
    transform: scale(0.95);
}

.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--card-color);
    margin: 20% auto;
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close:hover {
    color: black;
    background-color: #f0f0f0;
}

.profile-info {
    margin-bottom: 24px;
}

.profile-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.profile-item:last-child {
    border-bottom: none;
}

.label {
    font-weight: 500;
    color: var(--primary-color);
}

.value {
    font-weight: 400;
    color: var(--text-color);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

.btn-primary {
    padding: 12px 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background-color: #0077b3;
    transform: translateY(-1px);
}

.btn-danger {
    padding: 12px 20px;
    background-color: var(--danger-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background-color: #ff3742;
    transform: translateY(-1px);
}

.btn-secondary {
    padding: 12px 20px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
}

/* Анимации для плавного появления */
@keyframes streamText {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.streaming {
    animation: streamText 0.3s ease-out;
}

/* Адаптивность */
@media (max-width: 768px) {
    .app-header {
        padding: 10px 12px;
    }
    
    .app-title {
        font-size: 16px;
        max-width: 50%;
    }
    
    .mode-switch {
        padding: 6px 12px;
        gap: 10px;
    }
    
    .mode-label {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .sidebar {
        width: 260px;
    }
    
    .messages {
        padding: 12px;
        padding-bottom: 70px;
    }
    
    .welcome-message {
        padding: 30px 15px;
    }
    
    .mode-explanation {
        padding: 15px;
    }
    
    .mode-option {
        padding: 12px;
    }
    
    .input-area {
        padding: 8px 12px;
    }
    
    #userInput {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .send-btn {
        width: 40px;
        height: 40px;
    }
    
    .modal-content {
        margin: 30% auto;
        padding: 20px;
    }
    
    .chat-item {
        padding: 10px 12px;
    }
    
    .delete-chat-btn {
        font-size: 16px;
        padding: 2px 6px;
    }
    
    .message {
        max-width: 90%;
        font-size: 13px;
    }
    
    .system-message {
        margin: 8px 12px;
        padding: 8px 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .mode-switch {
        flex-direction: column;
        gap: 5px;
    }
    
    .mode-label {
        justify-content: center;
    }
    
    .welcome-message h3 {
        font-size: 18px;
    }
    
    .mode-option strong {
        font-size: 13px;
    }
    
    .bot strong {
        font-size: 14px;
    }
}

/* Плавные переходы для всех интерактивных элементов */
.chat-item, .message, .send-btn, .new-chat-btn, .mode-label, .btn-primary, .btn-danger, .btn-secondary {
    transition: all 0.2s ease;
}

/* Кастомный скроллбар */
.messages::-webkit-scrollbar {
    width: 6px;
}

.messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.chat-list::-webkit-scrollbar {
    width: 4px;
}

.chat-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.chat-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Улучшенное форматирование для структурированных ответов */
.bot .subdivision-section,
.bot .technics-section,
.bot .plan-section {
    margin: 8px 0;
}

.bot .section-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 5px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 3px;
}

.bot .item-list {
    margin-left: 10px;
}

.bot .list-item {
    margin: 2px 0;
    position: relative;
    padding-left: 12px;
}

.bot .list-item::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary-color);
}
/* Добавьте эти стили в конец вашего style.css */

/* Улучшенные стили для структурированных сообщений */
.bot .section-title {
    font-weight: 700;
    color: var(--primary-color);
    margin: 15px 0 8px 0;
    padding-bottom: 5px;
    border-bottom: 2px solid var(--primary-color);
    font-size: 16px;
}

.bot .stage-title {
    font-weight: 600;
    color: #2c5530;
    margin: 12px 0 8px 0;
    padding: 8px 12px;
    background-color: #f8fff9;
    border-left: 4px solid #4CAF50;
    border-radius: 4px;
    font-size: 15px;
}

.bot .sub-stage {
    margin: 8px 0 8px 15px;
    padding: 6px 0;
}

.bot .sub-stage strong {
    color: #d35400;
    font-weight: 600;
}

.bot .list-item {
    margin: 4px 0;
    padding-left: 8px;
    line-height: 1.4;
}

.bot .numbered-item {
    margin: 6px 0;
    padding: 4px 8px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid var(--primary-color);
}

/* Сохраняем оригинальные стили для обычных сообщений */
.message.bot:not(.streaming) {
    background-color: var(--bot-msg-bg);
    border-bottom-left-radius: 5px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Улучшаем визуальное разделение секций */
.bot .section-title + .list-item,
.bot .section-title + .numbered-item {
    margin-top: 8px;
}

/* Анимация появления структурированного контента */
.bot .section-title,
.bot .stage-title,
.bot .sub-stage,
.bot .list-item,
.bot .numbered-item {
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}