/* ===== СБРОС И БАЗОВЫЕ СТИЛИ ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #000000;
    --bg-light: #1a1a1a;
    --bg-lighter: #2a2a2a;
    --text: #ffffff;
    --text-light: #aaaaaa;
    --accent: #9370DB; /* СВЕТЛО-ФИОЛЕТОВЫЙ (было #8A2BE2) */
    --accent-hover: #A385E6; /* Светлее для ховера */
    --border: #333333;
    --user-msg: #2a2a2a;
    --ai-msg: #1a1a1a;
    --error: #ef4444;
    --success: #10b981;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ===== ШАПКА ===== */
.header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.menu-btn, .new-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: var(--bg-light);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-size: 16px;
}

.menu-btn:hover, .new-btn:hover {
    background: var(--bg-lighter);
}

.title {
    flex: 1;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 12px;
}

/* ===== БОКОВОЕ МЕНЮ (75% ширины) ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: -75%;
    width: 75%;
    height: 100vh;
    background: var(--bg-light);
    border-right: 1px solid var(--border);
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: none;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.close-btn:hover {
    background: var(--bg-lighter);
}

/* ===== СПИСОК ЧАТОВ ===== */
.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.empty-chats {
    text-align: center;
    color: var(--text-light);
    padding: 40px 20px;
    font-size: 14px;
}

.chat-item {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    border: 1px solid transparent;
}

.chat-item:hover {
    background: var(--bg-lighter);
    border-color: var(--border);
}

.chat-item.active {
    background: var(--bg-lighter);
    border-left: 3px solid var(--accent); /* СВЕТЛО-ФИОЛЕТОВЫЙ */
}

.chat-name {
    font-size: 14px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-preview {
    font-size: 12px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.delete-btn {
    opacity: 0;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: none;
    background: var(--error);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: opacity 0.2s;
}

.chat-item:hover .delete-btn {
    opacity: 1;
}

.delete-confirm {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 16px;
    z-index: 10;
}

.delete-confirm p {
    margin-bottom: 12px;
    text-align: center;
    color: var(--text);
}

.confirm-btns {
    display: flex;
    gap: 12px;
}

.confirm-btns button {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    min-width: 60px;
}

.confirm-yes {
    background: var(--error);
    color: white;
}

.confirm-no {
    background: var(--bg-lighter);
    color: var(--text);
}

.confirm-yes:hover, .confirm-no:hover {
    opacity: 0.9;
}

/* ===== ЭКРАН ПРИВЕТСТВИЯ ===== */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.welcome-img {
    width: 150px;
    height: 150px;
    object-fit: contain;
    margin-bottom: 24px;
    border-radius: 20px;
}

.welcome h2 {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-light);
}

/* ===== ОСНОВНОЙ КОНТЕНТ ===== */
.main {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    position: relative;
}

.chat {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ===== СООБЩЕНИЯ ===== */
.message {
    display: flex;
    max-width: 85%;
    animation: slideIn 0.3s;
}

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

/* Сообщения пользователя - справа */
.user-message {
    align-self: flex-end;
    margin-left: auto;
}

/* Сообщения AI - слева */
.ai-message {
    align-self: flex-start;
    margin-right: auto;
}

.message-content {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
    font-size: 14px;
}

.user-message .message-content {
    background: var(--user-msg);
    border-bottom-right-radius: 4px;
}

.ai-message .message-content {
    background: var(--ai-msg);
    border-bottom-left-radius: 4px;
}

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

/* Кнопка редактирования сообщения */
.edit-btn {
    position: absolute;
    top: -24px;
    right: 8px;
    opacity: 0;
    background: var(--bg-lighter);
    border: none;
    color: var(--text-light);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.user-message:hover .edit-btn {
    opacity: 1;
}

.edit-btn:hover {
    color: var(--text);
    background: var(--border);
}

/* ===== ИНДИКАТОР ПЕЧАТИ AI ===== */
.typing {
    display: none;
    align-self: flex-start;
    gap: 8px;
    padding: 12px 16px;
    background: var(--ai-msg);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    margin-top: 8px;
}

.typing.active {
    display: flex;
}

.dot {
    width: 8px;
    height: 8px;
    background: var(--text-light);
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* ===== ПАНЕЛЬ ВВОДА ===== */
.footer {
    border-top: 1px solid var(--border);
    background: var(--bg);
    padding: 12px 16px;
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

textarea {
    flex: 1;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    padding: 12px 16px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    outline: none;
    min-height: 40px;
    max-height: 120px;
    line-height: 1.5;
    transition: border-color 0.2s;
}

textarea:focus {
    border-color: var(--accent); /* СВЕТЛО-ФИОЛЕТОВЫЙ обводка при фокусе */
}

textarea::placeholder {
    color: var(--text-light);
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--accent); /* СВЕТЛО-ФИОЛЕТОВАЯ кнопка отправки */
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-size: 16px;
}

.send-btn:hover {
    background: var(--accent-hover); /* Светлее при наведении */
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== БЛОКИ КОДА ===== */
.code-block {
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-light);
}

.copy-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: var(--bg-lighter);
    color: var(--text);
}

.copy-btn.copied {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

pre {
    margin: 0;
    padding: 16px;
    background: var(--bg);
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.4;
}

code {
    font-family: 'Monaco', 'Courier New', monospace;
}

/* ===== УТИЛИТЫ ===== */
.hidden {
    display: none !important;
}

/* ===== ПОЛОСКА ПРОКРУТКИ ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 85%;
        left: -85%;
    }
    
    .message {
        max-width: 90%;
    }
    
    .welcome-img {
        width: 120px;
        height: 120px;
    }
    
    .welcome h2 {
        font-size: 18px;
    }
    
    .header, .footer {
        padding: 10px 12px;
    }
    
    .main {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100%;
        left: -100%;
    }
    
    .title {
        font-size: 14px;
    }
    
    .message-content {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .welcome-img {
        width: 100px;
        height: 100px;
    }
}

/* ===== ДОПОЛНИТЕЛЬНЫЕ СВЕТЛО-ФИОЛЕТОВЫЕ АКЦЕНТЫ ===== */
::selection {
    background: var(--accent); /* СВЕТЛО-ФИОЛЕТОВЫЙ при выделении текста */
    color: white;
}

/* Светло-фиолетовый градиент для текста (опционально) */
.accent-text {
    background: linear-gradient(90deg, var(--accent), #BA9FE6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Светло-фиолетовая тень для интерактивных элементов */
.interactive-shadow {
    box-shadow: 0 0 0 2px rgba(147, 112, 219, 0.2);
}

/* Фокус для доступности */
*:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Светло-фиолетовая полоса загрузки (если понадобится) */
.loading-bar {
    background: linear-gradient(90deg, var(--bg), var(--accent), var(--bg));
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}