* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Боковая панель */
.sidebar {
    width: 300px;
    background: #ffffff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.sidebar.visible {
    transform: translateX(0);
}

.sidebar:not(.visible) {
    transform: translateX(-100%);
    position: fixed;
    height: 100%;
    z-index: 100;
}

.sidebar-header {
    padding: 20px 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    align-items: center;
    background: #fafafa;
}

.new-chat-btn {
    flex: 1;
    padding: 10px 15px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background: #0056b3;
}

.hide-sidebar-btn {
    padding: 8px 12px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
}

.hide-sidebar-btn:hover {
    background: #e0e0e0;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.history-item {
    padding: 12px 15px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid #e8e8e8;
}

.history-item:hover {
    background: #f5f5f5;
    border-color: #d0d0d0;
}

.history-item.active {
    background: #e3f2fd;
    border-color: #007bff;
}

.history-title {
    font-weight: 500;
    margin-bottom: 5px;
    color: #333;
}

.history-date {
    font-size: 11px;
    color: #999;
}

/* Основная область */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    overflow: hidden;
}

.top-bar {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 15px;
    background: #ffffff;
}

.top-bar h3 {
    flex: 1;
    margin: 0;
    font-size: 20px;
    color: #333;
}

.show-sidebar-btn {
    padding: 8px 12px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
}

.log-chat-btn {
    padding: 8px 15px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.log-chat-btn:hover {
    background: #e0e0e0;
}

#chat {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    margin: 0;
}

#inputArea {
    margin: 15px 20px;
    padding: 15px;
    border: 2px dashed transparent;
    transition: background 0.3s;
    background: #fafafa;
    border-radius: 12px;
}

#inputArea.drag-over {
    background: #e0f0ff;
    border-color: #007bff;
}

#messageRow {
    margin-bottom: 10px;
}

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

#messageInput {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 40px;
    max-height: 150px;
    line-height: 1.4;
    overflow-y: auto;
}

#messageInput:focus {
    outline: none;
    border-color: #007bff;
}

.voice-btn {
    padding: 10px 15px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-btn:hover:not(:disabled) {
    background: #e0e0e0;
}

.voice-btn.recording {
    background: #ff4444;
    color: white;
    border-color: #cc0000;
}

.voice-btn.hidden {
    display: none;
}

#sendButton {
    padding: 10px 15px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    height: 40px;
}

#sendButton:hover:not(:disabled) {
    background: #0056b3;
}

#fileRow {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

#fileInput {
    display: none;
}

#fileButton {
    padding: 8px 15px;
    cursor: pointer;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
}

#fileList {
    color: #666;
    font-size: 0.9em;
}

.file-item {
    display: inline-block;
    background: #e0e0e0;
    padding: 2px 8px;
    border-radius: 12px;
    margin: 2px;
    font-size: 0.85em;
}

.file-item.warning {
    background: #ffcccc;
}

#voiceStatus {
    color: #666;
    font-size: 0.9em;
    margin-left: 10px;
}

#status {
    font-style: italic;
    color: #666;
    margin: 10px 20px;
    min-height: 1.5em;
}

#footer {
    font-size: 10px;
    color: #999;
    margin: 0 20px 10px 20px;
    min-height: 1.5em;
}


#uploadProgress {
    height: 3px;
    background: #007bff;
    width: 0;
    transition: width 0.3s;
    margin: 0 20px;
}

.message {
    margin: 12px 0;
    padding: 12px 16px;
    border-radius: 12px;
    word-break: break-word;
    max-width: 80%;
}

.user {
    margin-left: auto;
    background: #007bff;
    color: white;
}

.assistant {
    margin-right: auto;
    background: #f0f0f0;
    color: #333;
}

.system {
    margin: 12px auto;
    background: #e8f5e9;
    color: #2e7d32;
    text-align: center;
    max-width: 90%;
}

.error {
    margin: 12px auto;
    background: #ffebee;
    color: #c62828;
    text-align: center;
    max-width: 90%;
}

.wait {
    background: #f5f5f5;
    color: #666;
    font-style: italic;
}

.files-attachment {
    font-size: 0.85em;
    margin-top: 8px;
    padding: 8px;
    background: rgba(0,0,0,0.05);
    border-radius: 6px;
}

.file-preview {
    display: inline-block;
    margin: 5px;
    text-align: center;
    vertical-align: top;
}

.file-preview img {
    max-width: 80px;
    max-height: 80px;
    border-radius: 6px;
    object-fit: cover;
}

button {
    font-family: inherit;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 80%;
    max-width: 800px;
    max-height: 80%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h4 {
    margin: 0;
    color: #333;
}

.close-modal-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    padding: 5px;
}

.close-modal-btn:hover {
    color: #333;
}

.log-id {
    padding: 10px 20px;
    background: #f5f5f5;
    font-family: monospace;
    font-size: 12px;
    color: #666;
    border-bottom: 1px solid #e0e0e0;
}

.log-content {
    flex: 1;
    overflow: auto;
    padding: 20px;
    margin: 0;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    background: #f5f5f5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 100;
        transform: translateX(-100%);
    }
    
    .sidebar.visible {
        transform: translateX(0);
    }
    
    .message {
        max-width: 95%;
    }
    
    .input-wrapper {
        flex-wrap: wrap;
    }
    
    #messageInput {
        min-width: 100%;
        order: 1;
    }
    
    .voice-btn {
        order: 2;
        flex: 1;
    }
    
    #sendButton {
        order: 3;
        flex: 1;
    }
}