/* ==========================================================================
   ANAI Chatbot - Gemini 2.0 / Assistant-UI Theme (v1.3.5)
   Color Palette: Celeste (#367CFF), Morado (#5D1EAF), Slate (#1E1F20)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
    --anai-celeste: #367CFF;
    --anai-celeste-hover: #2264DD;
    --anai-celeste-subtle: #EBF2FF;
    --anai-morado: #5D1EAF;
    --anai-morado-subtle: #F3EEFB;
    
    --anai-bg-main: #F8FAFD;
    --anai-bg-surface: #FFFFFF;
    --anai-bg-sidebar: #F0F4F9;
    --anai-bg-user-bubble: #E9EEF6;
    
    --anai-text-primary: #1F1F1F;
    --anai-text-secondary: #444746;
    --anai-text-muted: #747775;
    
    --anai-border-subtle: #E1E3E1;
    --anai-shadow-pill: 0 2px 6px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.04);
    --anai-shadow-pill-focus: 0 4px 16px rgba(54, 124, 255, 0.16), 0 1px 3px rgba(0, 0, 0, 0.08);
    --anai-shadow-popover: 0 8px 30px rgba(0, 0, 0, 0.12);
    
    --anai-font: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Reset & Scope */
.anai-react-root {
    width: 100%;
    height: 100%;
    min-height: 600px;
    font-family: var(--anai-font);
    color: var(--anai-text-primary);
    box-sizing: border-box;
    display: flex;
    position: relative;
    overflow: hidden;
    background-color: var(--anai-bg-main);
    background-image: 
        radial-gradient(at 20% 0%, rgba(93, 30, 175, 0.05) 0px, transparent 50%),
        radial-gradient(at 80% 10%, rgba(54, 124, 255, 0.06) 0px, transparent 50%);
}

.anai-react-root *,
.anai-react-root *::before,
.anai-react-root *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Inline vs Floating modes */
.anai-react-root[data-mode="inline"] {
    border-radius: 16px;
    border: 1px solid var(--anai-border-subtle);
    height: 650px;
}

.anai-react-root[data-mode="floating"] {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 440px;
    height: 660px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 48px);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    border: 1px solid var(--anai-border-subtle);
    z-index: 999999;
}

/* ==========================================================================
   SIDEBAR (GEMINI STYLE)
   ========================================================================== */
.anai-sidebar {
    width: 275px;
    min-width: 275px;
    background-color: var(--anai-bg-sidebar);
    border-right: 1px solid rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    padding: 16px 14px;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
    overflow-y: auto;
    z-index: 20;
    flex-shrink: 0;
}

.anai-sidebar.collapsed {
    width: 0;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-20px);
}

.anai-sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.anai-sidebar-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--anai-text-secondary);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.anai-sidebar-toggle-btn:hover {
    background-color: rgba(0, 0, 0, 0.06);
    color: var(--anai-text-primary);
}

.anai-new-chat-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: #E9EEF6;
    color: var(--anai-text-primary);
    border: none;
    border-radius: 28px;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.anai-new-chat-btn:hover {
    background-color: #DCE3EE;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.anai-new-chat-btn:active {
    transform: scale(0.98);
}

.anai-sidebar-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--anai-text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0 12px 8px;
}

.anai-threads-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
}

/* Thread Item Row with Action Buttons */
.anai-thread-item-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    border-radius: 20px;
    transition: background-color 0.15s ease;
    overflow: hidden;
}

.anai-thread-item-wrapper:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.anai-thread-item-wrapper.active {
    background-color: #DCE3EE;
}

.anai-thread-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font-size: 13.5px;
    color: var(--anai-text-primary);
    cursor: pointer;
    background: transparent;
    border: none;
    text-align: left;
    font-family: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.anai-thread-item-wrapper.active .anai-thread-btn {
    color: var(--anai-morado);
    font-weight: 600;
}

.anai-thread-actions {
    display: none;
    align-items: center;
    gap: 2px;
    padding-right: 6px;
    background: linear-gradient(90deg, transparent 0%, rgba(220, 227, 238, 0.95) 20%);
}

.anai-thread-item-wrapper:hover .anai-thread-actions {
    display: flex;
}

.anai-thread-action-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--anai-text-secondary);
    transition: all 0.15s ease;
}

.anai-thread-action-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: var(--anai-text-primary);
}

.anai-thread-action-btn.delete:hover {
    background-color: #FEE2E2;
    color: #EF4444;
}

.anai-rename-input {
    width: 100%;
    padding: 8px 12px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--anai-text-primary);
    background: #FFFFFF;
    border: 1px solid var(--anai-celeste);
    border-radius: 12px;
    outline: none;
}

/* ==========================================================================
   MAIN CHAT WORKSPACE
   ========================================================================= */
.anai-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    position: relative;
    overflow: hidden;
}

.anai-topbar {
    height: 52px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.anai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 60px 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Compact Greeting / Welcome Screen (Requested) */
.anai-welcome-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    margin-top: 12vh;
    padding: 0 20px;
    animation: anaiFadeIn 0.3s ease-out;
}

.anai-welcome-heading {
    font-size: 24px; /* Scaled down as requested */
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--anai-text-primary);
    margin-bottom: 8px;
    background: linear-gradient(135deg, #1E1F20 20%, var(--anai-morado) 70%, var(--anai-celeste) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.anai-welcome-subtext {
    font-size: 14px;
    color: var(--anai-text-muted);
    max-width: 440px;
    line-height: 1.5;
}

/* Message Stream */
.anai-messages-container {
    width: 100%;
    max-width: 820px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 20px;
}

.anai-message-row {
    display: flex;
    gap: 14px;
    width: 100%;
    align-items: flex-start !important;
}

.anai-message-row.user {
    justify-content: flex-end;
}

.anai-message-row.bot {
    justify-content: flex-start;
}

.anai-bot-avatar {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    max-width: 32px !important;
    max-height: 32px !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    align-self: flex-start !important;
    margin-top: 4px !important;
    object-fit: cover !important;
    display: block !important;
}

.anai-message-bubble {
    font-size: 15.5px;
    line-height: 1.6;
    color: var(--anai-text-primary);
    word-break: break-word;
}

.anai-message-row.user .anai-message-bubble {
    background-color: var(--anai-bg-user-bubble);
    padding: 12px 20px;
    border-radius: 24px;
    max-width: 80%;
}

.anai-message-row.bot .anai-message-bubble {
    background: transparent;
    padding: 4px 0;
    max-width: 90%;
}

/* Markdown formatting */
.anai-message-bubble p { margin-bottom: 12px; }
.anai-message-bubble p:last-child { margin-bottom: 0; }
.anai-message-bubble ul, .anai-message-bubble ol { margin: 8px 0 12px 24px; }
.anai-message-bubble li { margin-bottom: 4px; }
.anai-message-bubble code {
    background-color: #ECEFF4;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13.5px;
}
.anai-message-bubble pre {
    background-color: #1E293B;
    color: #F8FAFC;
    padding: 14px 18px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 12px 0;
    font-family: monospace;
    font-size: 13.5px;
}
.anai-message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 14px;
}
.anai-message-bubble th, .anai-message-bubble td {
    border: 1px solid var(--anai-border-subtle);
    padding: 8px 12px;
    text-align: left;
}
.anai-message-bubble th {
    background: #F1F5F9;
    font-weight: 600;
}

/* Typing Dots */
.anai-typing-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    color: var(--anai-text-muted);
    font-size: 13.5px;
}

.anai-typing-dots-wave {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.anai-typing-dots-wave span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--anai-celeste);
    animation: anaiDotWave 1.3s infinite ease-in-out both;
}

.anai-typing-dots-wave span:nth-child(1) { animation-delay: -0.32s; }
.anai-typing-dots-wave span:nth-child(2) { animation-delay: -0.16s; }

@keyframes anaiDotWave {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1.1); opacity: 1; }
}

/* ==========================================================================
   FLOATING PILL COMPOSER (BOTTOM BAR & SCROLLBAR DESIGN)
   ========================================================================== */
.anai-composer-container {
    width: 100%;
    padding: 0 20px 24px;
    display: flex;
    justify-content: center;
    background: transparent;
    z-index: 10;
}

.anai-composer-pill {
    width: 100%;
    max-width: 820px;
    background-color: var(--anai-bg-surface);
    border: 1px solid var(--anai-border-subtle);
    border-radius: 32px;
    box-shadow: var(--anai-shadow-pill);
    display: flex;
    align-items: center;
    padding: 8px 12px 8px 14px;
    gap: 10px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
    min-height: 56px;
}

.anai-composer-pill:focus-within {
    border-color: var(--anai-celeste);
    box-shadow: var(--anai-shadow-pill-focus);
}

.anai-action-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--anai-text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
}

.anai-action-btn:hover {
    background-color: rgba(0, 0, 0, 0.06);
    color: var(--anai-text-primary);
}

.anai-action-btn:active {
    transform: scale(0.95);
}

.anai-action-btn.send {
    background-color: var(--anai-celeste);
    color: #FFFFFF;
}

.anai-action-btn.send:hover {
    background-color: var(--anai-celeste-hover);
    color: #FFFFFF;
}

.anai-action-btn.send:disabled {
    background-color: #E2E8F0;
    color: #94A3B8;
    cursor: not-allowed;
    transform: none;
}

.anai-action-btn.mic.recording {
    background-color: rgba(239, 68, 68, 0.12);
    color: #EF4444;
    animation: anaiMicPulse 1.4s infinite;
}

@keyframes anaiMicPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Auto-growing Textarea with Custom Scrollbar (2-3 lines limit) */
.anai-composer-input {
    flex: 1;
    border: none !important;
    outline: none !important;
    background: transparent;
    font-family: inherit;
    font-size: 15.5px;
    color: var(--anai-text-primary);
    resize: none !important; /* Removes manual resize handle */
    padding: 8px 4px;
    line-height: 1.45;
    min-height: 24px;
    max-height: 72px; /* Limits to ~2.5 - 3 lines */
    overflow-y: auto;
}

.anai-composer-input::placeholder {
    color: var(--anai-text-muted);
}

/* Custom Scrollbar inside textarea */
.anai-composer-input::-webkit-scrollbar {
    width: 4px;
}
.anai-composer-input::-webkit-scrollbar-track {
    background: transparent;
}
.anai-composer-input::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
}
.anai-composer-input::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* Popover Menu (+) */
.anai-popover-menu {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 8px;
    background-color: var(--anai-bg-surface);
    border-radius: 16px;
    box-shadow: var(--anai-shadow-popover);
    border: 1px solid var(--anai-border-subtle);
    padding: 8px;
    min-width: 240px;
    z-index: 100;
    animation: anaiPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes anaiPopIn {
    from { opacity: 0; transform: translateY(8px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.anai-popover-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--anai-text-primary);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.anai-popover-item:hover {
    background-color: var(--anai-celeste-subtle);
    color: var(--anai-celeste);
}

/* ==========================================================================
   INTERACTIVE QUIZ MODULE (MODES, PROGRESSION, RESULTS CARD)
   ========================================================================== */
.anai-quiz-container {
    background-color: var(--anai-bg-surface);
    border: 1px solid var(--anai-border-subtle);
    border-radius: 18px;
    padding: 20px;
    margin-top: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.04);
}

.anai-quiz-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--anai-border-subtle);
}

.anai-quiz-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.anai-quiz-badge {
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--anai-celeste-subtle);
    color: var(--anai-celeste);
    text-transform: uppercase;
}

.anai-quiz-step-tag {
    font-size: 12px;
    font-weight: 600;
    color: var(--anai-text-muted);
}

.anai-quiz-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--anai-morado);
    margin-bottom: 4px;
}

.anai-quiz-desc {
    font-size: 13px;
    color: var(--anai-text-muted);
}

/* Mode Selection Box */
.anai-quiz-mode-box {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.anai-quiz-mode-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: 14px;
    border: 1px solid var(--anai-border-subtle);
    background-color: var(--anai-bg-main);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.anai-quiz-mode-btn:hover {
    border-color: var(--anai-celeste);
    background-color: var(--anai-celeste-subtle);
    transform: translateY(-1px);
}

.anai-quiz-mode-icon {
    font-size: 24px;
}

.anai-quiz-mode-btn strong {
    display: block;
    font-size: 14.5px;
    color: var(--anai-text-primary);
    margin-bottom: 2px;
}

.anai-quiz-mode-btn small {
    display: block;
    font-size: 12.5px;
    color: var(--anai-text-muted);
}

/* Progress Bar */
.anai-quiz-progress-bar {
    width: 100%;
    height: 6px;
    background-color: #E2E8F0;
    border-radius: 6px;
    margin: 14px 0 16px;
    overflow: hidden;
}

.anai-quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--anai-celeste) 0%, var(--anai-morado) 100%);
    border-radius: 6px;
    transition: width 0.3s ease;
}

.anai-quiz-question-box {
    margin-bottom: 16px;
}

.anai-quiz-q-text {
    font-weight: 600;
    font-size: 15px;
    color: var(--anai-text-primary);
    margin-bottom: 14px;
    line-height: 1.45;
}

.anai-quiz-options-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.anai-quiz-opt-btn {
    padding: 12px 16px;
    border-radius: 12px;
    border: 1.5px solid var(--anai-border-subtle);
    background-color: var(--anai-bg-main);
    font-family: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--anai-text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.anai-quiz-opt-btn:hover:not(:disabled) {
    border-color: var(--anai-celeste);
    background-color: var(--anai-celeste-subtle);
}

.anai-quiz-opt-bullet {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #E2E8F0;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.anai-quiz-opt-btn.selected {
    border-color: var(--anai-celeste);
    background-color: var(--anai-celeste-subtle);
}

.anai-quiz-opt-btn.selected .anai-quiz-opt-bullet {
    background: var(--anai-celeste);
    color: #FFFFFF;
}

.anai-quiz-opt-btn.correct {
    background-color: #DCFCE7 !important;
    border-color: #22C55E !important;
    color: #15803D !important;
    font-weight: 600;
}

.anai-quiz-opt-btn.correct .anai-quiz-opt-bullet {
    background: #22C55E !important;
    color: #FFFFFF !important;
}

.anai-quiz-opt-btn.wrong {
    background-color: #FEE2E2 !important;
    border-color: #EF4444 !important;
    color: #B91C1C !important;
}

.anai-quiz-opt-btn.wrong .anai-quiz-opt-bullet {
    background: #EF4444 !important;
    color: #FFFFFF !important;
}

.anai-quiz-explanation-box {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    background-color: #F8FAFC;
    font-size: 13.5px;
    color: var(--anai-text-secondary);
    border-left: 4px solid var(--anai-celeste);
    line-height: 1.45;
}

.anai-quiz-footer-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

.anai-quiz-next-btn {
    padding: 10px 20px;
    border-radius: 24px;
    background: linear-gradient(135deg, var(--anai-celeste) 0%, var(--anai-morado) 100%);
    color: #FFFFFF;
    border: none;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(54, 124, 255, 0.25);
}

.anai-quiz-next-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(54, 124, 255, 0.35);
}

/* Results / Score Card */
.anai-quiz-results-card {
    text-align: center;
    padding: 24px 16px;
    animation: anaiFadeIn 0.3s ease-out;
}

.anai-quiz-score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--anai-celeste) 0%, var(--anai-morado) 100%);
    color: #FFFFFF;
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 14px;
    box-shadow: 0 8px 24px rgba(93, 30, 175, 0.2);
}

.anai-quiz-results-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--anai-text-primary);
    margin-bottom: 6px;
}

.anai-quiz-results-stats {
    font-size: 14px;
    color: var(--anai-text-muted);
    margin-bottom: 20px;
}

.anai-quiz-retry-btn {
    padding: 10px 22px;
    border-radius: 24px;
    background-color: #E9EEF6;
    color: var(--anai-text-primary);
    border: none;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
}

.anai-quiz-retry-btn:hover {
    background-color: #DCE3EE;
}

/* Animations */
@keyframes anaiFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .anai-sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }
    .anai-welcome-heading {
        font-size: 20px;
    }
    .anai-chat-body {
        padding: 50px 14px 14px;
    }
    .anai-composer-container {
        padding: 0 12px 14px;
    }
}
