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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 600;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background: #f8f9fa;
}

.message {
    display: flex;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

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

.message-avatar {
    font-size: 2em;
    margin-right: 15px;
    flex-shrink: 0;
}

.message-content {
    flex: 1;
    background: white;
    padding: 15px 20px;
    border-radius: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.bot-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    margin-right: 0;
    margin-left: 15px;
}

.user-message .message-content {
    background: #e3e8f0;
    color: #333;
}

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

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

.questions-container {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid rgba(255, 255, 255, 0.3);
}

.question-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.question-item h4 {
    margin-bottom: 10px;
    font-size: 1.1em;
}

.question-item ol {
    list-style: none;
    padding-left: 0;
}

.question-item li {
    padding: 8px;
    margin: 5px 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
}

.correct-answer {
    font-weight: bold;
    color: #90EE90;
}

.chat-input-container {
    padding: 20px 30px;
    background: white;
    border-top: 2px solid #e3e8f0;
}

#chat-form {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    padding: 15px;
    border: 2px solid #e3e8f0;
    border-radius: 12px;
    font-size: 1em;
    font-family: inherit;
    resize: none;
    transition: border-color 0.3s;
}

#message-input:focus {
    outline: none;
    border-color: #667eea;
}

#send-button {
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

#send-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.loading-spinner {
    display: inline-block;
}

.suggestions {
    padding: 20px 30px;
    background: #f8f9fa;
    border-top: 2px solid #e3e8f0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.suggestion-button {
    padding: 10px 20px;
    background: white;
    border: 2px solid #667eea;
    color: #667eea;
    border-radius: 20px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-button:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 10px;
    margin: 10px 0;
    border-left: 4px solid #c33;
}

/* Математические формулы KaTeX */
.message-content .katex {
    font-size: 1.1em;
    display: inline-block;
    margin: 0 2px;
}

.message-content .katex-display {
    margin: 1em 0;
    text-align: center;
    overflow-x: auto;
    overflow-y: hidden;
}

.message-content .katex-display > .katex {
    display: inline-block;
    text-align: initial;
}

/* Таблицы */
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.message-content table th,
.message-content table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.message-content table th {
    background: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

.message-content table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.message-content table tr:last-child td {
    border-bottom: none;
}

/* Блоки кода */
.message-content pre {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 15px 0;
}

.message-content code {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-content pre code {
    background: none;
    padding: 0;
}

/* Списки */
.message-content ul,
.message-content ol {
    margin: 10px 0;
    padding-left: 25px;
}

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

/* Заголовки */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 15px 0 10px 0;
    font-weight: 600;
}

/* Графики и диаграммы */
.message-content canvas {
    max-width: 100%;
    height: auto;
    margin: 15px 0;
    border-radius: 8px;
}

.chart-container {
    margin: 20px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        height: 100vh;
        border-radius: 0;
    }

    header h1 {
        font-size: 2em;
    }

    .chat-messages {
        padding: 20px;
    }

    #chat-form {
        flex-direction: column;
        align-items: stretch;
    }

    #send-button {
        width: 100%;
    }
}

