* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: url('background image.png') center center / cover no-repeat;
    background-color: #8c68a6;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.chat-container {
    width: 100%;
    max-width: 1400px;
    height: 90vh;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: linear-gradient(to right, #824D9E, #4F76B2);
    color: white;
    padding: 12px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.chat-controls {
    position: absolute;
    top: 16px;
    right: 24px;
    z-index: 10001;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-direction: row-reverse;
}

.history-dropdown {
    position: relative;
}

.history-button {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    color: #48166d;
    border: 1px solid #e0e0e0;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.history-button:hover {
    background: #f8f9fa;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.new-chat-button {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    color: #48166d;
    border: 1px solid #e0e0e0;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.new-chat-button:hover:not(:disabled) {
    background: #f8f9fa;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.new-chat-button:disabled {
    background: #f5f5f5;
    color: #ccc;
    border-color: #e0e0e0;
    cursor: not-allowed;
    opacity: 0.5;
}

.history-dropdown-content {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    width: 350px;
    max-height: 400px;
    overflow: hidden;
    z-index: 10000;
}

.history-dropdown-content.show {
    display: block;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.history-header span {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.clear-history-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
}

.clear-history-btn:hover {
    background: #c82333;
}

.history-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 8px;
}

.history-item {
    padding: 12px;
    margin-bottom: 4px;
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.history-item:hover {
    background: #e9ecef;
    transform: translateX(-2px);
}

.history-item-text {
    flex: 1;
    color: #333;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-delete {
    background: transparent;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.history-item-delete:hover {
    background: rgba(220, 53, 69, 0.1);
}

.no-history {
    text-align: center;
    color: #999;
    padding: 32px 16px;
    font-size: 14px;
}

.header-logo {
    width: 80px;
    height: 80px;
    object-fit: cover;
    background: transparent;
    border-radius: 50%;
    padding: 3px;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3)) brightness(1.1) contrast(1.1);
}

.header-text h1 {
    font-size: 26px;
    font-weight: 600;
    margin-bottom: 2px;
    line-height: 1.2;
}

.header-text p {
    font-size: 14px;
    opacity: 0.9;
    line-height: 1.3;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    position: relative;
}

.chat-messages::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('Bot image_new_1.png') center 30% / cover no-repeat;
    opacity: 0.9;
    z-index: 0;
}

.chat-messages > *:not(.chat-controls) {
    position: relative;
    z-index: 1;
}

.message {
    margin-bottom: 20px;
    display: flex;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    justify-content: flex-start;
}

.bot-message {
    justify-content: flex-start;
}

.message-content {
    max-width: 85%;
    padding: 16px 20px;
    border-radius: 12px;
    line-height: 1.6;
}

.user-message .message-content {
    background: #48166d;
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin-bottom: 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content p:empty {
    display: none;
}

.message-content ul {
    margin-left: 20px;
    margin-bottom: 12px;
}

.message-content li {
    margin-bottom: 6px;
}

.message-content strong {
    color: #48166d;
    font-weight: 700;
    font-size: 16px;
}

.bot-message .message-content h1,
.bot-message .message-content h2,
.bot-message .message-content h3 {
    color: #333;
    font-weight: 700;
    margin-top: 16px;
    margin-bottom: 12px;
}

.bot-message .message-content h1 {
    font-size: 20px;
}

.bot-message .message-content h2 {
    font-size: 18px;
}

.bot-message .message-content h3 {
    font-size: 16px;
}

.bot-message .message-content ol {
    margin-left: 0;
    margin-bottom: 12px;
    padding-left: 0;
    list-style-position: outside;
    list-style-type: decimal;
}

.bot-message .message-content ol > li {
    margin-left: 24px;
    margin-bottom: 12px;
    padding-left: 8px;
}

.bot-message .message-content ol > li > strong:first-child {
    display: block;
    margin-bottom: 6px;
    color: #48166d;
}

.bot-message .message-content ul > li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.message-images {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.message-image {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-image:hover {
    transform: scale(1.02);
}

.message-image img {
    width: 100%;
    height: auto;
    display: block;
}

.image-caption {
    padding: 8px;
    background: #f8f9fa;
    font-size: 12px;
    color: #666;
    text-align: center;
}

.welcome-message {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    height: 100%;
    padding-left: 0;
    padding-bottom: 20px;
}

.welcome-message h2 {
    color: #48166d;
    font-size: 26px;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
}

.welcome-message p {
    color: #666;
    font-size: 16px;
    font-weight: 400;
}

.quick-questions {
    display: flex;
    gap: 12px;
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.quick-question-btn {
    flex: 1;
    padding: 16px 20px;
    background: #e8e8e8;
    color: #4F76B2;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.quick-question-btn:hover {
    background: #d8d8d8;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.quick-question-btn:active {
    transform: scale(0.98);
}

.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    position: relative;
}

.input-icon {
    position: absolute;
    left: 16px;
    bottom: 14px;
    color: #48166d;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
}

#userInput {
    flex: 1;
    padding: 12px 16px 12px 48px;
    border: 2px solid #824D9E;
    border-radius: 24px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    transition: border-color 0.2s;
}

#userInput:focus {
    outline: none;
    border-color: #48166d;
}

.send-button {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: #824D9E;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(130, 77, 158, 0.4);
}

.send-button:active {
    transform: scale(0.95);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 32px 48px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 1000;
}

.thinking-animation {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.star {
    position: absolute;
    width: 0;
    height: 0;
    animation: sparkle 2s ease-in-out infinite;
}

.star::before {
    content: '✦';
    position: absolute;
    font-size: 24px;
    transform: translate(-50%, -50%);
}

.star-1 {
    top: 20%;
    left: 30%;
    animation-delay: 0s;
}

.star-1::before {
    color: #6B46C1;
    font-size: 32px;
}

.star-2 {
    top: 15%;
    right: 25%;
    animation-delay: 0.3s;
}

.star-2::before {
    color: #60D5F2;
    font-size: 28px;
}

.star-3 {
    bottom: 25%;
    left: 15%;
    animation-delay: 0.6s;
}

.star-3::before {
    color: #8B5CF6;
    font-size: 20px;
}

.star-4 {
    bottom: 20%;
    right: 20%;
    animation-delay: 0.9s;
}

.star-4::before {
    color: #60D5F2;
    font-size: 24px;
}

@keyframes sparkle {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.8) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.2) rotate(180deg);
    }
}

.loading-indicator p {
    color: #999;
    font-size: 16px;
    font-weight: 500;
    margin: 0;
}

.error-message {
    background: #fee;
    border: 1px solid #fcc;
    color: #c33;
    padding: 12px;
    border-radius: 8px;
    margin-top: 8px;
}

.citation {
    font-size: 12px;
    color: #666;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.citation-link {
    color: #667eea;
    text-decoration: none;
}

.citation-link:hover {
    text-decoration: underline;
}

/* Scrollbar styling */
.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;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    .chat-container {
        height: 100vh;
        border-radius: 0;
        max-width: 100%;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .chat-header {
        padding: 16px;
    }
    
    .header-logo {
        width: 40px;
        height: 40px;
    }
    
    .header-text h1 {
        font-size: 20px;
    }
}
