:root {
    --primary-color: #2563eb;
    --primary-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    --bg-color: #f3f4f6;
    --chat-bg: #ffffff;
    --text-main: #1f2937;
    --text-secondary: #6b7280;
    --bubble-user-text: #ffffff;
    --bubble-bot-bg: #f3f4f6;
    --bubble-bot-text: #111827;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Global Reset for Safety */
* {
    box-sizing: border-box;
}



body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    color: var(--text-main);
}

#footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    padding: 10px 0;
    text-align: center;
    font-size: 0.75rem;
    /* Smaller text */
    color: #9ca3af;
    /* Lighter gray */
    pointer-events: none;
    z-index: 999;
    /* High z-index to ensure visibility */
    background: transparent;
    /* Ensure no white box blocking */
}

/* Responsive Wrapper */
.main-wrapper {
    width: 100%;
    max-width: 1000px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 20px;
    box-sizing: border-box;
}

/* Titles */
h1 {
    color: var(--text-main);
    margin: 0;
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.05rem;
    text-align: center;
    line-height: 1.2;
}

/* Chat Container Card */
#chat-container {
    width: 100%;
    max-width: 500px;
    background: var(--chat-bg);
    display: flex;
    flex-direction: column;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    height: 100%;
    transition: all 0.3s ease;
}

/* Layout for Larger Screens */
@media(min-width: 800px) {
    .main-wrapper {
        flex-direction: row;
        gap: 60px;
        padding: 40px;
    }

    h1 {
        text-align: right;
        flex: 1;
        font-size: 3.0rem;
        padding-top: 0;
        align-self: center;
    }

    #chat-container {
        flex: 1.2;
        max-width: 480px;
        height: 80vh;
        /* Floating card feel */
    }
}

/* Header */
#header {
    padding: 20px;
    font-weight: 600;
    font-size: 1.1rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid #e5e7eb;
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Messages Area */
#messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.message {
    padding: 12px 18px;
    border-radius: 20px;
    max-width: 85%;
    line-height: 1.6;
    font-size: 0.95rem;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

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

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

.user {
    align-self: flex-end;
    background: var(--primary-gradient);
    color: var(--bubble-user-text);
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-md);
}

.assistant {
    align-self: flex-start;
    background: var(--bubble-bot-bg);
    color: var(--bubble-bot-text);
    border-bottom-left-radius: 4px;
    border: 1px solid #e5e7eb;
}

/* Typing Indicator */
.typing {
    font-style: normal;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0 0 16px 24px;
    display: none;
    /* Controlled by JS */
    align-items: center;
    gap: 6px;
}

.typing::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.2);
        opacity: 1;
    }

    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
}

/* Input Area */
#input-area {
    padding: 20px;
    background: #fff;
    display: flex;
    gap: 12px;
    border-top: 1px solid #f3f4f6;
}

input {
    flex: 1;
    min-width: 0;
    /* Critical: Allows input to shrink below content size */
    width: 100%;
    /* Ensure it tries to fill flex item */
    padding: 14px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 999px;
    /* Pill shape */
    outline: none;
    font-size: 1rem;
    transition: border-color 0.2s;
    background: #f9fafb;
}

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

button {
    padding: 0 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: transform 0.1s, background 0.2s;
    box-shadow: var(--shadow-md);
    display: inline-block;
    /* Revert flex center */
    width: auto;
    /* Allow auto width */
    height: auto;
}

button:hover {
    transform: translateY(-1px);
    filter: brightness(110%);
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

/* Scrollbar polish */
#messages::-webkit-scrollbar {
    width: 6px;
}

#messages::-webkit-scrollbar-track {
    background: transparent;
}

#messages::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 20px;
}

/* Mobile Tweaks (Placed at end to override defaults) */
@media (max-width: 480px) {
    .main-wrapper {
        padding: 10px;
    }

    #input-area {
        padding: 12px;
        gap: 8px;
        justify-content: space-between;
        /* Ensure spacing */
    }

    input {
        padding: 10px 16px;
        width: 70%;
        /* Widened to 70% */
        flex: initial;
        /* Disable flex grow to strictly obey width */
    }

    button {
        padding: 10px 16px;
        /* Adjust padding for mobile */
        width: auto;
        height: auto;
        flex-shrink: 0;
    }


    h1 {
        font-size: 1.8rem;
    }
}

/* =========================================
   UI Enhancements (Avatars, Markdown, Etc.)
   ========================================= */

/* Header Version Display */
#version-display {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: #e5e7eb;
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 8px;
    vertical-align: middle;
    font-weight: normal;
}

/* Message Layout with Avatar */
.message {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    /* Slightly reduced padding as we have structural spacing */
    max-width: 95%;
    /* Allow wider bubbles */
    align-items: flex-start;
}

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

.message.user .avatar {
    background: var(--primary-color);
    color: white;
}

.message.assistant .avatar {
    background: #e0e7ff;
    /* Light indigo */
    color: var(--primary-color);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
}

.content {
    display: flex;
    /* Fixes some layout issues with generated content */
    flex-direction: column;
    min-width: 0;
    /* Prevents overflow */
    word-wrap: break-word;
}

/* Markdown Content Styling */
.message.assistant .content {
    line-height: 1.6;
}

.message.assistant p {
    margin: 0 0 12px 0;
}

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

.message.assistant ul,
.message.assistant ol {
    margin: 0 0 12px 0;
    padding-left: 24px;
}

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

.message.assistant pre {
    background: #0d1117;
    /* GitHub Dark bg */
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    color: #c9d1d9;
}

.message.assistant code {
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    background: rgba(0, 0, 0, 0.05);
    /* Inline code bg */
    padding: 2px 4px;
    border-radius: 4px;
}

.message.assistant pre code {
    background: transparent;
    /* Let pre handle bg */
    padding: 0;
    color: inherit;
    font-size: 0.85rem;
}

.message.assistant blockquote {
    border-left: 4px solid var(--primary-color);
    margin: 8px 0;
    padding-left: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Override bubble colors for better readability with complex content */
.assistant {
    background: #ffffff;
    /* White bg for assistant to read code better? Or keep gray */
    /* Let's keep the gray but ensure code blocks pop */
    background: var(--bubble-bot-bg);
}

/* Adjust Message Bubble radius for avatar look */
.message {
    /* Test Comment */
    border-radius: 12px;
    /* Gentler radius since avatars add roundness */
}
/* Schedule Template Styles */
.schedule-card {
    background: #fff;
    border: 1px solid #e0e7ff;
    border-radius: 12px;
    padding: 16px;
    margin-top: 10px;
    box-shadow: var(--shadow-md);
    color: var(--text-main);
}

.schedule-card h3 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.date-selector {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.date-item {
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 8px;
}

.date-item:last-child {
    border-bottom: none;
}

.date-item strong {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.slots {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.slot-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    background: #f3f4f6;
    color: var(--text-main);
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: none;
}

.slot-btn:hover {
    background: #e0e7ff;
    border-color: var(--primary-color);
    transform: none;
}

.slot-btn.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

#booking-form input {
    border-radius: 8px;
    padding: 10px;
    font-size: 0.9rem;
    background: #fdfdfd;
}

#booking-form button {
    border-radius: 8px;
    padding: 12px;
    background: var(--primary-gradient);
}

/* Generic Extension Container Styles */
.chatbot-extension-container {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    margin: 12px 0;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    width: 100%;
}

.extension-header {
    background: #f8fafc;
    padding: 8px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    display: flex;
    align-items: center;
}

.extension-body {
    padding: 16px;
}

/* Modifying old schedule-card to fit inside generic container */
.schedule-card {
    border: none;
    margin-top: 0;
    padding: 0;
    box-shadow: none;
}
