* { box-sizing: border-box; }
body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; 
    margin: 0; 
    padding: 0; 
    background: #1a1a1a; 
    color: #e0e0e0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}
.header { 
    background: #2d2d2d; 
    padding: 12px 20px; 
    border-bottom: 1px solid #404040;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header h1 { 
    margin: 0; 
    font-size: 18px; 
    font-weight: 600;
    color: #e0e0e0;
}
.clear-btn {
    background: #5a1e1e;
    border: 1px solid #7a2e2e;
    color: #ff6b6b;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}
.clear-btn:hover {
    background: #6a2e2e;
}
.chat-container { 
    flex: 1; 
    display: flex; 
    flex-direction: column;
    max-width: 100%;
    margin: 0 auto;
    background: #1a1a1a;
}
.chat-history { 
    flex: 1; 
    overflow-y: auto; 
    padding: 0;  /* Убрали боковые отступы 20px */
    background: #1a1a1a;
}
.message { 
    margin: 12px 0; 
    padding: 8px 0;  /* Убрали боковые отступы */
    border-radius: 0; /* Убрали скругления */
    max-width: 100%;  /* Теперь на всю ширину */
    line-height: 1.4;
}
.user { 
    background: #404040; 
    margin: 12px 16px 12px auto; /* Отступы только справа */
    padding: 12px 16px; 
    border-radius: 12px; 
    width: 70%;
    border-bottom-right-radius: 4px;
}
.bot { 
    background: #1a1a1a;  /* Фон как у всего чата */
    margin: 12px 0;       /* Только вертикальные отступы */
    padding: 12px 16px;   /* Добавили обратно боковые отступы */
    border-bottom: 1px solid #2d2d2d; /* Разделитель вместо рамки */
    border-top: 1px solid #2d2d2d;
}
.input-area { 
    background: #2d2d2d; 
    padding: 16px; 
    border-top: 1px solid #404040;
    flex-shrink: 0;
}
.input-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}
.message-input { 
    flex: 1; 
    padding: 12px 16px; 
    background: #404040; 
    border: 1px solid #555; 
    border-radius: 8px; 
    color: #e0e0e0;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    min-height: 44px;
    max-height: 120px;
}
.message-input:focus {
    outline: none;
    border-color: #2d5baf;
}
.message-input::placeholder {
    color: #999;
}
.send-btn { 
    padding: 12px 20px; 
    background: #2d5baf; 
    color: white; 
    border: none; 
    border-radius: 8px; 
    cursor: pointer; 
    font-weight: 500;
    min-width: 80px;
    height: 44px;
}
.send-btn:hover { 
    background: #1e4a9e; 
}
.send-btn:disabled { 
    background: #555; 
    cursor: not-allowed; 
}
.file-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    align-items: center;
}
.file-input {
    flex: 1;
}
.file-btn {
    padding: 8px 16px;
    background: #404040;
    color: #e0e0e0;
    border: 1px solid #555;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.file-btn:hover {
    background: #4a4a4a;
}
.typing { 
    color: #999; 
    font-style: italic; 
}
.message strong {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: #aaa;
}
.hidden-file-input {
    display: none;
}
.file-list {
    margin-top: 12px;
    padding: 12px;
    background: #2d2d2d;
    border: 1px solid #404040;
    border-radius: 8px;
    font-size: 13px;
}

.file-list-header {
    font-weight: 600;
    margin-bottom: 8px;
    color: #e0e0e0;
    font-size: 12px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    margin: 4px 0;
    background: #404040;
    border-radius: 4px;
    border: 1px solid #555;
}

.file-name {
    flex: 1;
    color: #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 8px;
}

.file-size {
    color: #999;
    font-size: 11px;
    margin-right: 8px;
    min-width: 50px;
    text-align: right;
}

.remove-file-btn {
    background: transparent;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    transition: background 0.2s;
}

.remove-file-btn:hover {
    background: #5a1e1e;
}

/* Обновляем file-input для множественного выбора */
.hidden-file-input {
    display: none;
}

.file-btn {
    padding: 8px 16px;
    background: #404040;
    color: #e0e0e0;
    border: 1px solid #555;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.file-btn:hover {
    background: #4a4a4a;
}

.file-btn:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
}

/* Стили для блоков кода как в андроид-приложении */
.message-content {
    white-space: pre-line;
    word-wrap: break-word;
    line-height: 1.5;
}

.code-block {
    position: relative;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    margin: 6px 0;  /* Было 12px - уменьшили вдвое */
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;  /* Было 8px 12px - уменьшили вертикальные */
    background: #2d2d2d;
    border-bottom: 1px solid #333;
    font-size: 12px;
    color: #888;
}
.copy-btn {
    background: #404040;
    border: 1px solid #555;
    color: #e0e0e0;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: #4a4a4a;
}

.copy-btn.copied {
    background: #2d5b2d;
    border-color: #3d6b3d;
    color: #90ee90;
}

.code-container {
    position: relative;
    overflow-x: auto;
    background: #1e1e1e;
}

.code-container pre {
    margin: 0;
    padding: 8px 12px;  /* Было 12px - уменьшили вертикальные отступы */
    background: transparent !important;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.4;
}
.code-container code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    background: transparent !important;
    white-space: pre !important;
    display: block;
}

/* Улучшаем внешний вид подсветки */
.hljs {
    background: #1e1e1e !important;
    color: #d4d4d4;
}

.hljs-keyword { color: #569cd6; }
.hljs-built_in { color: #4ec9b0; }
.hljs-type { color: #4ec9b0; }
.hljs-literal { color: #569cd6; }
.hljs-number { color: #b5cea8; }
.hljs-string { color: #ce9178; }
.hljs-comment { color: #6a9955; }
.hljs-function { color: #dcdcaa; }
.hljs-params { color: #9cdcfe; }
.hljs-title { color: #dcdcaa; }
.hljs-variable { color: #9cdcfe; }
.hljs-attr { color: #9cdcfe; }
.hljs-tag { color: #569cd6; }
.hljs-name { color: #569cd6; }
.hljs-meta { color: #9cdcfe; }
.hljs-symbol { color: #569cd6; }
.hljs-bullet { color: #d7ba7d; }

/* Стили для inline кода */
.message-content code:not(.hljs) {
    background: #2d2d2d;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    color: #e0e0e0;
    border: 1px solid #404040;
}

/* Стили для скроллбара в чате */
.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track {
    background: #2d2d2d;
}

.chat-history::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Стили для скроллбара в блоках кода */
.code-container::-webkit-scrollbar {
    height: 8px;
}

.code-container::-webkit-scrollbar-track {
    background: #2d2d2d;
    border-radius: 0 0 4px 4px;
}

.code-container::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

.code-container::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Подсветка строк кода */
.hljs {
    padding: 0 !important;
}

/* Убираем лишние отступы в подсветке */
.hljs-ln {
    border-collapse: collapse;
}

.hljs-ln td {
    padding: 0;
    border: none;
}

.hljs-ln-numbers {
    text-align: right;
    padding-right: 12px !important;
    padding-left: 8px !important;
    color: #6a737d;
    background: #252526;
    border-right: 1px solid #333;
    user-select: none;
}

.hljs-ln-code {
    padding-left: 12px !important;
    padding-right: 12px !important;
    white-space: pre;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .message {
        max-width: 95%;
    }
    
    .code-container pre {
        font-size: 12px;
        padding: 10px;
    }
    
    .code-header {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .copy-btn {
        padding: 3px 6px;
        font-size: 10px;
    }
}