* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInFromLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInFromRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
    color: #e4e4e4;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.container {
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(10px);
    padding: 0;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    height: 90vh;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    animation: fadeIn 0.6s ease;
}

.chat-header {
    background: linear-gradient(135deg, #6a5acd 0%, #4a90e2 100%);
    padding: 32px 24px;
    border-radius: 24px 24px 0 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: pulse 4s ease-in-out infinite;
}

h1 {
    color: #ffffff;
    font-size: 1.8em;
    font-weight: 600;
    letter-spacing: -0.5px;
    position: relative;
    z-index: 1;
}

.subtitle {
    color: #fff;
    font-size: 1.2em;
    margin-top: 10px;
    font-weight: 400;
    position: relative;
    z-index: 1;
}

.subtitle a {
    color: #fff;
}

#chatOutput {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#chatOutput::-webkit-scrollbar {
    width: 8px;
}
#chatOutput::-webkit-scrollbar-track {
    background: transparent;
}
#chatOutput::-webkit-scrollbar-thumb {
    background: rgba(106, 90, 205, 0.3);
    border-radius: 10px;
}
#chatOutput::-webkit-scrollbar-thumb:hover {
    background: rgba(106, 90, 205, 0.5);
}

.message {
    display: flex;
    gap: 12px;
    max-width: 80%;
    animation: fadeIn 0.4s ease;
}

.user-message {
    margin-left: auto;
    flex-direction: row-reverse;
    animation: slideInFromRight 0.4s ease;
}
.ai-message {
    margin-right: auto;
    animation: slideInFromLeft 0.4s ease;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.user-message .avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.ai-message .avatar {
    background: linear-gradient(135deg, #6a5acd 0%, #4a90e2 100%);
}

.message-content {
    padding: 14px 18px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
    position: relative;
    transition: transform 0.2s ease;
}
.message-content:hover {
    transform: translateY(-2px);
}
.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.ai-message .message-content {
    background: rgba(106, 90, 205, 0.15);
    color: #e4e4e4;
    border: 1px solid rgba(106, 90, 205, 0.3);
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.input-container {
    padding: 20px 24px 24px;
    background: rgba(15, 52, 96, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.input-area {
    display: flex;
    gap: 12px;
    background: rgba(26, 26, 46, 0.8);
    padding: 8px;
    border-radius: 16px;
    border: 1px solid rgba(106, 90, 205, 0.3);
    transition: all 0.3s ease;
}
.input-area:focus-within {
    border-color: #6a5acd;
    box-shadow: 0 0 20px rgba(106, 90, 205, 0.3);
}
#questionInput {
    flex-grow: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: #e4e4e4;
    font-size: 15px;
    resize: none;
    height: 45px;
    outline: none;
    font-family: inherit;
}
#questionInput::placeholder {
    color: rgba(228, 228, 228, 0.4);
}
#submitButton {
    background: linear-gradient(135deg, #6a5acd 0%, #4a90e2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(106, 90, 205, 0.3);
}
#submitButton:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(106, 90, 205, 0.4);
}
#submitButton:active {
    transform: translateY(0);
}
#submitButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.typing-indicator {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px 18px;
    background: rgba(106, 90, 205, 0.15);
    border: 1px solid rgba(106, 90, 205, 0.3);
    border-radius: 18px;
    max-width: fit-content;
    animation: slideInFromLeft 0.4s ease;
}
.typing-dots {
    display: flex;
    gap: 4px;
}
.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6a5acd;
    animation: pulse 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

.hidden {
    display: none;
}
.error-box {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 14px 18px;
    border-radius: 12px;
    margin: 0 24px 16px;
    text-align: center;
    font-size: 0.9em;
    animation: fadeIn 0.4s ease;
}

@media (max-width: 768px) {
    .container {
        height: 95vh;
        border-radius: 16px;
    }
    .chat-header {
        padding: 20px;
        border-radius: 16px 16px 0 0;
    }
    h1 { font-size: 1.5em; }
    .message { max-width: 85%; }
    .avatar {
        width: 36px;
        height: 36px;
        font-size: 1em;
    }
}
