/* style.css */
:root {
    --primary-color: #0d8abc;
    --primary-hover: #0b739e;
    --bg-color: #f3f4f6;
    --msg-user-bg: #e1eff6;
    --msg-bot-bg: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: #e5e7eb;
    /* Background for demo purposes */
    color: var(--text-main);
}

/* Chat Widget Container */
.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Floating Action Button */
.chat-fab {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(13, 138, 188, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    opacity: 1;
    transform: scale(1);
}

.chat-fab:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05);
}

.chat-fab.hidden {
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
    position: absolute;
}

/* Chat Container */
.chat-container {
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 48px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: bottom right;
    opacity: 1;
    transform: scale(1);
    margin-bottom: 20px;
}

.chat-container.hidden {
    opacity: 0;
    transform: scale(0.5) translateY(20px);
    pointer-events: none;
    position: absolute;
    bottom: 60px;
}

.chat-header {
    background-color: var(--primary-color);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

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

.avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.chat-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-header .status {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-header .status::before {
    content: "";
    display: block;
    width: 8px;
    height: 8px;
    background-color: #10b981;
    /* Green dot */
    border-radius: 50%;
}

.close-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out;
}

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

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

.message-content {
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
    word-wrap: break-word;
}

.user-message .message-content {
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    background-color: var(--msg-bot-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Markdown styling inside bot messages */
.bot-message .message-content {
    line-height: 1.6;
}

.bot-message .message-content p {
    margin-bottom: 12px;
}

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

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

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

.bot-message .message-content ul,
.bot-message .message-content ol {
    margin: 8px 0 12px 24px;
    padding: 0;
}

.bot-message .message-content li {
    margin-bottom: 4px;
}

.bot-message .message-content code {
    background: #f1f5f9;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    color: #e11d48;
}

.bot-message .message-content pre {
    background: #1e293b;
    color: #f8fafc;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    font-family: monospace;
    font-size: 0.9em;
}

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

.bot-message .message-content h1,
.bot-message .message-content h2,
.bot-message .message-content h3,
.bot-message .message-content h4 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.bot-message .message-content h3 {
    font-size: 1.1rem;
}

.bot-message .message-content h4 {
    font-size: 1rem;
}

.bot-message .message-content blockquote {
    border-left: 3px solid #cbd5e1;
    padding-left: 12px;
    margin: 12px 0;
    color: #475569;
    font-style: italic;
}

.bot-message .message-content a {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Input area */
.chat-input-area {
    padding: 16px 20px;
    background-color: #ffffff;
    border-top: 1px solid var(--border-color);
}

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

#user-input {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    min-height: 76px;
    max-height: 120px;
    /* limits auto-grow height before scrolling */
    line-height: 1.4;
    overflow-y: auto;
}

#user-input:focus {
    border-color: var(--primary-color);
}

#user-input::-webkit-scrollbar {
    width: 6px;
}

#user-input::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

#send-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    flex-shrink: 0;
    /* Prevents button from shrinking in flex container */
}

#send-btn:hover {
    background-color: var(--primary-hover);
}

#send-btn:active {
    transform: scale(0.95);
}

/* Disable states */
#send-btn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

#user-input:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
}

/* Scrollbar styling for chat area */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

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

/* Typing Indicator Animation */
.typing-indicator .message-content {
    display: flex;
    gap: 4px;
    padding: 16px;
}

.typing-indicator .dot {
    width: 8px;
    height: 8px;
    background-color: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

.typing-indicator .dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    .chat-container {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 16px;
    }

    .chat-widget {
        bottom: 16px;
        right: 16px;
    }
}