/* =========================================
   0. DESIGN SYSTEM & VARIABLES
   ========================================= */
:root {
    /* Colors */
    --maira-primary: #111827;
    --maira-primary-hover: #374151;
    --maira-accent: #2563eb;
    --maira-bg-light: #f9fafb;
    --maira-bg-white: #ffffff;
    --maira-text-dark: #1f2937;
    --maira-text-muted: #6b7280;
    --maira-border: #e5e7eb;
    
    /* Shadows */
    --maira-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --maira-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --maira-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --maira-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Typography */
    --maira-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* =========================================
   1. WIDGET STYLES (Refined Floating Panel)
   ========================================= */

#maira-widget-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999999;
    font-family: var(--maira-font);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Launcher Button */
#maira-toggle-btn {
    background: var(--maira-primary);
    color: #fff;
    border: none;
    border-radius: 60px;
    padding: 14px 28px;
    box-shadow: var(--maira-shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative; 
    z-index: 1000000;
    overflow: hidden;
    font-weight: 500;
    font-size: 15px;
    letter-spacing: 0.01em;
}

#maira-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--maira-shadow-xl);
    background: var(--maira-primary-hover);
}

.maira-agent-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.2);
}

/* Slide-out Drawer */
#maira-chat-window {
    position: fixed;
    bottom: 100px; /* Floats above button */
    right: 24px;
    width: 380px;
    max-height: calc(100vh - 140px);
    height: 600px;
    background: var(--maira-bg-white);
    border-radius: 20px;
    box-shadow: var(--maira-shadow-xl);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--maira-border);
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999998;
}

/* Active State */
#maira-chat-window.maira-active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#maira-chat-window.maira-hidden {
    display: none; /* Fallback */
}

/* Header */
.maira-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--maira-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--maira-bg-white);
    border-radius: 20px 20px 0 0;
}

.maira-header span {
    font-weight: 600;
    color: var(--maira-text-dark);
    font-size: 16px;
}

.maira-actions button, .maira-actions a {
    background: transparent;
    border: none;
    color: var(--maira-text-muted);
    cursor: pointer;
    margin-left: 12px;
    transition: color 0.2s;
    padding: 4px;
    display: flex;
    align-items: center;
}

.maira-actions button:hover, .maira-actions a:hover {
    color: var(--maira-text-dark);
    background: var(--maira-bg-light);
    border-radius: 6px;
}

/* Body */
.maira-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-y: hidden; /* Manage scroll in inner containers */
    background: var(--maira-bg-light);
}

.maira-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Messages styling shared with dedicated page */
.maira-message {
    padding: 14px 18px;
    border-radius: 16px;
    max-width: 85%;
    line-height: 1.5;
    font-size: 14px;
    position: relative;
    animation: fadeIn 0.3s ease;
    box-shadow: var(--maira-shadow-sm);
}

.maira-message.bot {
    background: var(--maira-bg-white);
    color: var(--maira-text-dark);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--maira-border);
}

.maira-message.user {
    background: var(--maira-primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: var(--maira-shadow-md);
}

/* Input Area */
.maira-input-area {
    padding: 16px 20px;
    background: var(--maira-bg-white);
    border-top: 1px solid var(--maira-border);
    display: flex;
    gap: 10px;
    align-items: center;
}

#maira-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--maira-border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    background: var(--maira-bg-light);
    transition: all 0.2s;
}

#maira-input:focus {
    background: #fff;
    border-color: var(--maira-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#maira-send-btn {
    background: var(--maira-primary);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

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

/* =========================================
   2. DEDICATED PAGE (Enterprise / Minimalist)
   ========================================= */

/* Main Container (Full Width, Fixed Height) */
.maira-enterprise-container {
    display: flex;
    height: 85vh;
    min-height: 600px;
    background: var(--maira-bg-white);
    border: 1px solid var(--maira-border);
    border-radius: 12px;
    overflow: hidden;
    font-family: var(--maira-font);
    color: var(--maira-text-dark);
    margin: 40px auto;
    max-width: 1400px;
    width: 95%;
    box-shadow: var(--maira-shadow-md);
}

/* Sidebar (Left) */
.maira-enterprise-sidebar {
    width: 320px;
    background: var(--maira-bg-light);
    border-right: 1px solid var(--maira-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.maira-brand-header {
    padding: 24px;
    border-bottom: 1px solid var(--maira-border);
}

.maira-brand-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--maira-text-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.maira-badge {
    background: #dbeafe;
    color: #1e40af;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.maira-sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.maira-filter-group {
    margin-bottom: 24px;
}

.maira-filter-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--maira-text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.maira-filter-group input,
.maira-filter-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--maira-border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--maira-text-dark);
    background: #fff;
    transition: border-color 0.15s ease;
    box-sizing: border-box;
}

.maira-filter-group input:focus,
.maira-filter-group select:focus {
    outline: none;
    border-color: var(--maira-accent);
    box-shadow: 0 0 0 1px var(--maira-accent);
}

/* Main Chat Area (Right) */
.maira-enterprise-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    position: relative;
}

.maira-chat-stream {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Welcome State */
.maira-welcome-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    padding-bottom: 60px; /* Space for input */
}

/* Hide welcome state when chat starts */
.maira-enterprise-main.chat-active .maira-welcome-state {
    display: none;
}

.maira-welcome-state h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--maira-text-dark);
    margin-bottom: 40px;
}

.maira-quick-prompts {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 800px;
}

.maira-prompt-card {
    background: #fff;
    border: 1px solid var(--maira-border);
    border-radius: 12px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 220px;
    text-align: left;
    box-shadow: var(--maira-shadow-sm);
}

.maira-prompt-card:hover {
    border-color: #9ca3af;
    box-shadow: var(--maira-shadow-md);
    transform: translateY(-2px);
}

.maira-prompt-card .emoji {
    font-size: 20px;
}

.maira-prompt-card .text {
    font-size: 14px;
    font-weight: 500;
    color: var(--maira-text-dark);
    line-height: 1.4;
}

/* Input Area (Bottom Fixed) */
.maira-input-wrapper {
    padding: 24px 40px;
    background: #fff;
    border-top: 1px solid var(--maira-bg-light);
}

.maira-input-box {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.maira-input-box input {
    width: 100%;
    padding: 16px 50px 16px 20px;
    font-size: 16px;
    border: 1px solid var(--maira-border);
    border-radius: 12px;
    box-shadow: var(--maira-shadow-sm);
    transition: all 0.2s;
    outline: none;
    box-sizing: border-box;
}

.maira-input-box input:focus {
    border-color: var(--maira-accent);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.maira-input-box button {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--maira-primary);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.maira-input-box button:hover {
    background: var(--maira-primary-hover);
}

.maira-input-box button svg {
    width: 20px;
    height: 20px;
}

/* Product Cards Grid */
.maira-product-grid {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 4px;
    margin-top: 12px;
    /* Hide scrollbar but allow scroll */
    scrollbar-width: thin; 
}

.maira-product-card {
    background: #fff;
    border: 1px solid var(--maira-border);
    border-radius: 12px;
    padding: 12px;
    min-width: 200px; /* Fixed width for horizontal scroll */
    max-width: 200px;
    display: flex;
    flex-direction: column; /* Stack vertical */
    gap: 12px;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.maira-product-card:hover {
    box-shadow: var(--maira-shadow-lg);
    border-color: #d1d5db;
    transform: translateY(-2px);
}

.maira-product-card img {
    width: 100%;
    height: 140px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--maira-bg-light);
}

.maira-product-info h4 {
    font-size: 14px;
    margin: 0 0 4px 0;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.maira-product-info .price {
    font-weight: 700;
    color: var(--maira-text-dark);
}

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

/* Mobile Responsive */
@media (max-width: 800px) {
    .maira-enterprise-container {
        flex-direction: column;
        height: auto;
        min-height: 80vh;
        border: none;
        width: 100%;
        margin: 0;
        border-radius: 0;
        box-shadow: none; /* remove shadow on mobile full width */
    }

    .maira-enterprise-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--maira-border);
    }

    .maira-sidebar-scroll {
        display: none; /* Hide filters on mobile initially or use accordion */
    }
    
    .maira-brand-header {
        cursor: pointer; /* Hint that it might toggle filters */
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
    }

    .maira-chat-stream {
        padding: 20px 16px;
        min-height: 400px;
    }
    
    .maira-input-wrapper {
        padding: 16px;
        position: sticky;
        bottom: 0;
        border-top: 1px solid var(--maira-border);
        /* Ensure it sits above other content */
        z-index: 10;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .maira-input-box input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}
