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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a0000 0%, #000000 50%, #1a0000 100%);
    min-height: 100vh;
    color: #ffffff;
}

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

/* Login & Register */
.login-box {
    background: linear-gradient(145deg, #1a0000, #0d0d0d);
    border: 2px solid #cc0000;
    border-radius: 15px;
    padding: 40px;
    max-width: 450px;
    width: 100%;
    margin: auto;
    box-shadow: 0 10px 40px rgba(204, 0, 0, 0.3);
}

.login-box h1 {
    color: #ff0000;
    text-align: center;
    margin-bottom: 30px;
    font-size: 32px;
    text-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #ff3333;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    background: #0d0d0d;
    border: 2px solid #660000;
    border-radius: 8px;
    color: #ffffff;
    font-size: 16px;
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #ff0000;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.3);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    width: 100%;
    margin-bottom: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #cc0000, #ff0000);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 0, 0, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ff0000, #ff3333);
    box-shadow: 0 6px 20px rgba(255, 0, 0, 0.5);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    background: #660000;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

.btn-secondary {
    background: #1a1a1a;
    color: #ff3333;
    border: 2px solid #660000;
}

.btn-secondary:hover {
    background: #2a2a2a;
    border-color: #ff0000;
    box-shadow: 0 4px 15px rgba(255, 0, 0, 0.2);
}

.error-message {
    color: #ff6666;
    background: rgba(255, 0, 0, 0.1);
    padding: 12px;
    border-radius: 8px;
    margin-top: 15px;
    border-left: 4px solid #ff0000;
    display: none;
}

.error-message:not(:empty) {
    display: block;
}

.success-message {
    color: #66ff66;
    background: rgba(0, 255, 0, 0.1);
    padding: 12px;
    border-radius: 8px;
    margin-top: 15px;
    border-left: 4px solid #00ff00;
    display: none;
}

.success-message:not(:empty) {
    display: block;
}

/* Chat */
.chat-header {
    background: linear-gradient(135deg, #1a0000, #0d0d0d);
    border: 2px solid #cc0000;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(204, 0, 0, 0.3);
}

.chat-header h1 {
    color: #ff0000;
    font-size: 28px;
    text-shadow: 0 0 15px rgba(255, 0, 0, 0.5);
}

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

#user-info {
    color: #ff6666;
    font-size: 14px;
    padding: 8px 15px;
    background: rgba(255, 0, 0, 0.1);
    border-radius: 20px;
    border: 1px solid #660000;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: rgba(13, 13, 13, 0.5);
    border: 2px solid #660000;
    border-radius: 15px;
    margin-bottom: 20px;
    min-height: 400px;
}

.message {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 12px;
    animation: fadeIn 0.3s;
}

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

.message.user {
    background: linear-gradient(135deg, #660000, #990000);
    border-left: 4px solid #ff0000;
    margin-left: 20%;
    box-shadow: 0 2px 10px rgba(255, 0, 0, 0.2);
}

.message.assistant {
    background: linear-gradient(135deg, #1a1a1a, #0d0d0d);
    border-left: 4px solid #cc0000;
    margin-right: 20%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.message-role {
    font-weight: 600;
    margin-bottom: 8px;
    color: #ff3333;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.message-content {
    color: #ffffff;
    line-height: 1.6;
    word-wrap: break-word;
}

/* Markdown styling */
.message-content h1,
.message-content h2,
.message-content h3 {
    color: #ff3333;
    margin: 15px 0 10px 0;
    font-weight: 600;
}

.message-content h1 {
    font-size: 1.8em;
    border-bottom: 2px solid #660000;
    padding-bottom: 5px;
}

.message-content h2 {
    font-size: 1.5em;
}

.message-content h3 {
    font-size: 1.2em;
}

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

.message-content ul,
.message-content ol {
    margin: 10px 0;
    padding-left: 25px;
}

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

.message-content a {
    color: #ff6666;
    text-decoration: none;
    border-bottom: 1px solid #ff6666;
    transition: all 0.3s;
}

.message-content a:hover {
    color: #ff3333;
    border-bottom-color: #ff3333;
}

.message-content blockquote {
    border-left: 4px solid #ff0000;
    margin: 15px 0;
    padding: 10px 15px;
    background: rgba(255, 0, 0, 0.05);
    font-style: italic;
}

.message-content strong {
    color: #ff6666;
    font-weight: 600;
}

.message-content em {
    color: #ff9999;
}

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

.message-content pre {
    background: #1a1a1a;
    border: 2px solid #660000;
    border-radius: 8px;
    padding: 15px;
    overflow-x: auto;
    margin: 15px 0;
    box-shadow: 0 4px 10px rgba(255, 0, 0, 0.2);
}

.message-content pre code {
    background: none;
    color: #ffffff;
    padding: 0;
    font-size: 0.95em;
    line-height: 1.5;
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 15px 0;
}

.message-content table th,
.message-content table td {
    border: 1px solid #660000;
    padding: 10px;
    text-align: left;
}

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

.message-content table tr:nth-child(even) {
    background: rgba(255, 0, 0, 0.05);
}

.message-content hr {
    border: none;
    border-top: 2px solid #660000;
    margin: 20px 0;
}

/* Math formulas */
.message-content .MathJax {
    color: #ff9999 !important;
}

/* System messages */
.message.system .message-content {
    text-align: center;
    font-style: italic;
    color: #ff9999;
}

.chat-input-container {
    background: linear-gradient(135deg, #1a0000, #0d0d0d);
    border: 2px solid #cc0000;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(204, 0, 0, 0.3);
}

#message-input {
    width: 100%;
    padding: 15px;
    background: #0d0d0d;
    border: 2px solid #660000;
    border-radius: 10px;
    color: #ffffff;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 15px;
    transition: all 0.3s;
}

#message-input:focus {
    outline: none;
    border-color: #ff0000;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.3);
}

#send-btn {
    width: auto;
    min-width: 150px;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 10px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #0d0d0d;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #660000, #cc0000);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #cc0000, #ff0000);
}

/* Responsive */
@media (max-width: 768px) {
    .login-box {
        padding: 30px 20px;
    }

    .chat-header {
        flex-direction: column;
        gap: 15px;
    }

    .header-info {
        width: 100%;
        justify-content: space-between;
    }

    .message.user,
    .message.assistant {
        margin-left: 0;
        margin-right: 0;
    }
}
