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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    background-color: #f5f5f5;
    min-height: 100vh;
}

main {
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

main h1 {
    color: #333;
    margin-bottom: 1rem;
}

main p {
    color: #666;
}

/* Chatbot Widget */
#chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: #007bff;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chatbot-toggle::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background: linear-gradient(45deg, #ffd700, #ffed4e, #ffd700, #ffed4e);
    background-size: 300% 300%;
    animation: goldGlow 2s ease-in-out infinite;
    z-index: -1;
}

@keyframes goldGlow {
    0%, 100% {
        background-position: 0% 50%;
        opacity: 0.8;
    }
    50% {
        background-position: 100% 50%;
        opacity: 1;
    }
}

.chatbot-toggle:hover {
    transform: scale(1.05);
    background: #0056b3;
}

.chatbot-toggle svg {
    width: 28px;
    height: 28px;
}

.chatbot-toggle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chatbot-window-hidden {
    display: none !important;
}

#chatbot-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 360px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none; /* Hidden by default */
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

#chatbot-window:not(.chatbot-window-hidden) {
    display: flex; /* Show when not hidden */
}

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

#chatbot-header {
    background: #007bff;
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none; /* Prevent text selection while dragging */
}

.chatbot-title {
    font-weight: 600;
    font-size: 16px;
}

.chatbot-status {
    font-size: 12px;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
}

#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
}

.message.bot-message {
    align-self: flex-start;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.bot-avatar {
    background: #007bff;
    color: white;
}

.user-avatar {
    background: #28a745;
    color: white;
}

.message-content {
    background: #f0f0f0;
    padding: 12px 16px;
    border-radius: 16px;
    border-top-left-radius: 4px;
}

.message.user-message .message-content {
    background: #007bff;
    color: white;
    border-radius: 16px;
    border-top-right-radius: 4px;
    border-top-left-radius: 16px;
}

.message-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
}

/* Markdown styling in bot messages */
.bot-message .message-content h1,
.bot-message .message-content h2,
.bot-message .message-content h3,
.bot-message .message-content h4,
.bot-message .message-content h5,
.bot-message .message-content h6 {
    margin: 0.5em 0 0.3em 0;
    font-weight: 600;
    line-height: 1.3;
}

.bot-message .message-content h1 { font-size: 1.4em; }
.bot-message .message-content h2 { font-size: 1.3em; }
.bot-message .message-content h3 { font-size: 1.2em; }
.bot-message .message-content h4 { font-size: 1.1em; }
.bot-message .message-content h5 { font-size: 1em; }
.bot-message .message-content h6 { font-size: 0.9em; }

.bot-message .message-content ul,
.bot-message .message-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.bot-message .message-content li {
    margin: 0.3em 0;
}

.bot-message .message-content p {
    margin: 0.5em 0;
}

.bot-message .message-content p:first-child {
    margin-top: 0;
}

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

.bot-message .message-content strong {
    font-weight: 600;
}

.bot-message .message-content em {
    font-style: italic;
}

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

.bot-message .message-content pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5em 0;
}

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

.bot-message .message-content blockquote {
    border-left: 3px solid #007bff;
    padding-left: 12px;
    margin: 0.5em 0;
    color: #666;
}

.bot-message .message-content a {
    color: #007bff;
    text-decoration: underline;
}

.bot-message .message-content a:hover {
    color: #0056b3;
}

.bot-message .message-content hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 0.8em 0;
}

.bot-message .message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5em 0;
    font-size: 0.9em;
}

.bot-message .message-content th,
.bot-message .message-content td {
    border: 1px solid #ddd;
    padding: 6px 8px;
    text-align: left;
}

.bot-message .message-content th {
    background: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

#chatbot-input-container {
    padding: 12px 16px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    background: white;
}

#chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#chatbot-input:focus {
    border-color: #007bff;
}

#chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #007bff;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#chatbot-send:hover {
    background: #0056b3;
}

#chatbot-send svg {
    width: 20px;
    height: 20px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

.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);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* Resize handle */
.chatbot-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    font-size: 16px;
    line-height: 16px;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    z-index: 10;
    padding: 2px;
}

.chatbot-resize-handle:hover {
    color: #007bff;
}

/* Responsive */
@media (max-width: 480px) {
    #chatbot-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
    }

    /* Disable resize on mobile */
    .chatbot-resize-handle {
        display: none;
    }
}
