/* Глобальные стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --assistant-bg: #f1f5f9;
    --user-bg: #dbeafe;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Заголовок */
.header {
    background: var(--surface);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo img {
    height: 60px;
    object-fit: contain;
}

.logo h1 {
    font-size: 24px;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.logo p {
    font-size: 14px;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Контейнер чата */
.chat-container {
    flex: 1;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* Сообщения */
.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

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

.message.user {
    display: flex;
    justify-content: flex-end;
}

.message.assistant {
    display: flex;
    justify-content: flex-start;
}

.message-content {
    max-width: 80%;
    padding: 15px 20px;
    border-radius: 12px;
    word-wrap: break-word;
}

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

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

.message-content p {
    margin-bottom: 10px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul, .message-content ol {
    margin-left: 20px;
    margin-top: 10px;
}

.message-content li {
    margin-bottom: 5px;
}

.message-sources {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
}

.source-tag {
    display: inline-block;
    background: var(--surface);
    padding: 4px 8px;
    border-radius: 4px;
    margin-right: 5px;
    margin-top: 5px;
}

.confidence-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    margin-left: 10px;
}

.confidence-high {
    background: #d1fae5;
    color: #065f46;
}

.confidence-medium {
    background: #fef3c7;
    color: #92400e;
}

.confidence-low {
    background: #fee2e2;
    color: #991b1b;
}

/* Индикатор печати */
.typing-indicator {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--secondary-color);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Форма ввода */
.chat-input-container {
    padding: 20px;
    border-top: 1px solid var(--border);
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    max-height: 150px;
    transition: border-color 0.2s;
}

#messageInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

.file-upload {
    text-align: center;
}

.file-label {
    display: inline-block;
    padding: 8px 16px;
    background: var(--background);
    border: 1px dashed var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.file-label:hover {
    background: var(--assistant-bg);
    border-color: var(--primary-color);
}

#fileInput {
    display: none;
}

/* Кнопки */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: var(--background);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--assistant-bg);
}

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

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

.modal-content {
    background: var(--surface);
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
}

.close {
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-secondary);
}

.close:hover {
    color: var(--text-primary);
}

.settings-group {
    margin: 20px 0;
}

.settings-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .message-content {
        max-width: 90%;
    }

    .input-group {
        flex-direction: column;
    }
}

/* Скроллбар */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--background);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Streaming cursor animation */
.cursor {
    animation: blink 1s infinite;
    font-weight: bold;
    color: var(--primary-color);
}

@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* Streaming text container */
.streaming-text {
    min-height: 20px;
}

/* Response time badge */
.response-time {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 8px;
    background: rgba(37, 99, 235, 0.1);
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--primary-color);
}
