/* OEM Intel - Premium Glassmorphism UI */

/* ===========================================
   DYNAMIC VIEWPORT HEIGHT - Mobile Fix
   =========================================== */
/* The --vh CSS variable is set by JavaScript to handle:
   - Mobile browser chrome (address bar hiding/showing)
   - Virtual keyboard opening/closing
   - Orientation changes
   
   Usage: height: calc(var(--vh, 1vh) * 100);
   Or:    height: var(--viewport-height, 100vh);
*/
:root {
    --vh: 1vh;
    /* Fallback, JS will override */
    --viewport-height: 100vh;
    /* Fallback, JS will override */
}

/* Smooth viewport transitions - prevents jarring jumps */
@media (max-width: 768px) {

    /* Only apply overscroll-behavior to doubt-solver page, not globally */
    .doubt-solver-page {
        /* Prevent overscroll bounce that causes jitter */
        overscroll-behavior: none;
    }

    /* Ensure body/html can scroll on other pages (when doubt-solver-active class is NOT on body) */
    body:not(.doubt-solver-active) {
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    /* Ensure html can scroll when body doesn't have doubt-solver-active */
    html {
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    /* Only restrict scrolling on doubt-solver page itself */
    body.doubt-solver-active .doubt-solver-page {
        overscroll-behavior: none;
    }

    /* Smooth height transitions for viewport changes */
    .doubt-solver-page {
        transition: height 0.15s ease-out,
            min-height 0.15s ease-out,
            max-height 0.15s ease-out;
    }

    /* When keyboard is open, adjust layout */
    body.keyboard-open .doubt-solver-page {
        /* Use the JS-calculated height which accounts for keyboard */
        height: var(--viewport-height, 100dvh) !important;
    }

    /* Ensure messages area scrolls properly with keyboard */
    body.keyboard-open .doubt-solver-messages,
    body.keyboard-open .doubt-solver-chat-messages {
        /* Reduce padding at bottom when keyboard is open */
        padding-bottom: 0.25rem !important;
    }

    /* Input area stays visible above keyboard */
    body.keyboard-open .doubt-solver-input-area,
    body.keyboard-open .doubt-solver-input-wrap {
        position: sticky !important;
        bottom: 0 !important;
        /* Ensure it's above everything */
        z-index: 9999 !important;
    }
}

/* Preloading state - prevents flash during eager initialization */
.doubt-solver-page.preloading {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* CRITICAL FIX: Remove GPU promotion that causes "wobbly paper" feel */
/* The .page class has will-change and transform which causes floaty scrolling */
.doubt-solver-page.active {
    will-change: auto !important;
    transform: none !important;
    backface-visibility: visible !important;
}

/* ===========================================
   HIDE FLOATING SUPPORT/WHATSAPP BUTTON 
   on doubt-solver page (GLOBAL - all screen sizes)
   =========================================== */
body.doubt-solver-active .floating-chat-button,
body.doubt-solver-active #support-widget-button,
body.doubt-solver-active #support-widget-container {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Also hide footer when doubt-solver is active */
body.doubt-solver-active footer {
    display: none !important;
}

/* Ensure all child elements are visible when page is active */
.doubt-solver-page.active * {
    visibility: visible;
}

/* Ensure input area is always visible and properly positioned on mobile when active */
@media (max-width: 768px) {

    .doubt-solver-page.active .doubt-solver-input-area,
    .doubt-solver-page.active .doubt-solver-input-wrap {
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* Page Layout */
.doubt-solver-page {
    height: calc(100vh - 70px) !important;
    /* Subtract header height */
    overflow: hidden;
    /* Simple solid background - matches other pages, no "container" feel */
    background: var(--bg-primary, #0f172a);
}

.doubt-solver-chat-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
}

/* Header */
.doubt-solver-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 10;
    transition: all 0.3s ease;
}

/* Collapsed header state - after first message */
.doubt-solver-chat-header.header-collapsed {
    padding: 0.5rem 1rem;
    justify-content: flex-end;
    min-height: 0;
}

.doubt-solver-chat-header.header-collapsed .doubt-solver-chat-title {
    display: none;
}

.doubt-solver-chat-header.header-collapsed .doubt-solver-category-select {
    padding: 0.35rem 1.5rem 0.35rem 0.75rem;
    font-size: 0.8rem;
    background-size: 0.8rem;
}

.doubt-solver-chat-title {
    font-size: 1.25rem;
    font-weight: 600;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.doubt-solver-chat-title .doubt-solver-title-icon {
    font-size: 1.1em;
    line-height: 1;
    -webkit-text-fill-color: initial;
}

.doubt-solver-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.doubt-solver-category-select {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.5rem 2rem 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
}

.doubt-solver-category-select:hover {
    background-color: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
}

.doubt-solver-category-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.doubt-solver-books-pill {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.doubt-solver-books-visible {
    opacity: 1;
    pointer-events: auto;
}

/* Chat Main Area */
.doubt-solver-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    min-height: 0;
    /* Critical for nested flex scrolling */
}

.doubt-solver-messages {
    flex: 1;
    overflow-y: auto;
    /* Reduced bottom padding to push input area closer to bottom edge */
    padding: 1.5rem 1.5rem 0.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
    min-height: 0;
    /* Critical for nested flex scrolling */
}

/* Scrollbar */
.doubt-solver-messages::-webkit-scrollbar {
    width: 6px;
}

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

.doubt-solver-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.doubt-solver-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Message Bubbles */
.chat-msg-wrap {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

.chat-msg-user {
    align-self: flex-end;
}

.chat-msg-assistant {
    align-self: flex-start;
}

.chat-msg-row {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.chat-msg-user .chat-msg-row {
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 600;
}

.chat-avatar-user {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(56, 189, 248, 0.3);
}

.chat-avatar-assistant {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--accent-primary);
}

.chat-avatar svg {
    width: 1.25rem;
    height: 1.25rem;
}

.chat-bubble {
    padding: 1rem 1.25rem;
    border-radius: 1.25rem;
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
}

.chat-bubble-user {
    background: var(--gradient-primary);
    /* Use theme gradient */
    color: white;
    border-bottom-right-radius: 0.25rem;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.2);
}

.chat-bubble-assistant {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-bottom-left-radius: 0.25rem;
    backdrop-filter: blur(8px);
}

/* Citations – pill style so multi-digit/range labels don't get cramped */
.doubt-solver-citation {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.2rem;
    height: 1.2rem;
    padding: 0 0.25rem;
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-primary);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 999px; /* pill instead of perfect circle */
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
    vertical-align: super;
    margin-left: 2px;
    cursor: help;
    transition: all 0.2s ease;
}

.doubt-solver-citation:hover {
    background: var(--accent-primary);
    color: white;
    transform: scale(1.02);
}

/* Formatting for Assistant Response */
.msg-text p {
    margin-bottom: 0.75rem;
}

.msg-text p:last-child {
    margin-bottom: 0;
}

.msg-text ul,
.msg-text ol {
    margin: 0.5rem 0 0.5rem 1.5rem;
}

.msg-text li {
    margin-bottom: 0.25rem;
}

.msg-text strong {
    color: #fff;
    font-weight: 600;
}

.msg-text em {
    font-style: italic;
    color: var(--text-secondary);
}

/* Markdown heading styles */
.ds-heading {
    color: #fff;
    font-weight: 600;
    margin: 1rem 0 0.5rem 0;
}

h3.ds-heading {
    font-size: 1.1rem;
}

h4.ds-heading {
    font-size: 1rem;
}

h5.ds-heading {
    font-size: 0.95rem;
}

/* Markdown list styles */
.ds-list {
    list-style-position: outside;
    margin: 0.5rem 0 0.5rem 1.5rem !important;
    padding: 0;
}

.ds-list li {
    margin-bottom: 0.25rem;
    line-height: 1.5;
}

/* Typing Indicator */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 1rem;
    min-height: 3rem;
    align-items: center;
}

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

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

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

@keyframes typingBounce {

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

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

/* Input Area - seamless with page, pushed to bottom edge */
.doubt-solver-input-area {
    padding: 0.5rem 1.5rem;
    /* Reduce bottom padding so input hugs bottom edge more on desktop */
    padding-bottom: 0.25rem;
    background: var(--bg-primary, #0f172a);
    border-top: none;
    position: relative;
    z-index: 20;
    flex-shrink: 0;
    /* Prevent input from being pushed off screen */
}

.doubt-solver-input-row {
    display: flex;
    gap: 0.75rem;
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 1rem;
    padding: 0.5rem;
    backdrop-filter: blur(12px);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
    transition: all 0.3s ease;
}

.doubt-solver-input-row:focus-within {
    border-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2), 0 2px 16px rgba(0, 0, 0, 0.35);
    background: rgba(30, 41, 59, 0.98);
}

.doubt-solver-input {
    flex: 1;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    color: #f8fafc;
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 1rem;
    appearance: none;
    -webkit-appearance: none;
}

.doubt-solver-input:focus,
.doubt-solver-input:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.doubt-solver-input::placeholder {
    color: #94a3b8;
    opacity: 1;
}

.doubt-solver-send {
    background: var(--gradient-primary);
    border: none;
    border-radius: 0.75rem;
    width: 3rem;
    height: 3rem;
    /* match input height roughly */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.doubt-solver-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.4);
}

.doubt-solver-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Starter Chips (empty state) */
.doubt-solver-chips-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    /* Slightly tighter bottom padding so chips sit lower on desktop */
    padding: 0.75rem 1.5rem 0.25rem;
    max-width: 800px;
    margin: 0 auto;
    justify-content: center;
}

.doubt-solver-chip {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(30, 41, 59, 0.6);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.doubt-solver-chip:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
    color: var(--text-primary);
}

/* Related questions below answer */
.doubt-solver-related-wrap {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.doubt-solver-related-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.doubt-solver-related-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(30, 41, 59, 0.5);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.doubt-solver-related-btn:hover {
    background: rgba(56, 189, 248, 0.1);
    border-color: rgba(56, 189, 248, 0.3);
    color: var(--text-primary);
}

/* Share button */
.doubt-solver-share-wrap {
    margin-top: 0.75rem;
}

.doubt-solver-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(30, 41, 59, 0.5);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.doubt-solver-share-btn:hover {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-primary);
}

/* Compact source drawer */
.doubt-solver-sources-compact .doubt-solver-sources-toggle {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.doubt-solver-sources-icon {
    display: flex;
    align-items: center;
    opacity: 0.8;
}

.doubt-solver-sources-compact .doubt-solver-sources-list {
    padding: 0.5rem 1rem 0.75rem;
}

/* Sources Panel (Collapsible) - Compact to maximize reading area */
.doubt-solver-sources-wrap {
    margin: 0 1.5rem 0.25rem;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0.75rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.doubt-solver-sources-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
}

.doubt-solver-sources-toggle:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.sources-chevron {
    transition: transform 0.3s ease;
}

.doubt-solver-sources-open .sources-chevron {
    transform: rotate(180deg);
}

.doubt-solver-sources-list {
    display: none;
    padding: 0 1rem 1rem;
    animation: slideDown 0.3s ease;
}

.doubt-solver-sources-open .doubt-solver-sources-list {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

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

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

.doubt-solver-source-item {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-size: 0.85rem;
    cursor: default;
    transition: all 0.2s ease;
}

.doubt-solver-source-item:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
}

.source-num {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    line-height: 1.25rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border-radius: 4px;
    margin-right: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.source-label {
    color: var(--text-primary);
    font-weight: 500;
}

.doubt-solver-source-has-text {
    cursor: pointer;
}

.doubt-solver-source-text-wrap {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: none;
}

.doubt-solver-source-expanded .doubt-solver-source-text-wrap {
    display: block;
}

.doubt-solver-source-snippet {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 0.8rem;
    line-height: 1.4;
    max-height: 150px;
    overflow-y: auto;
}

.doubt-solver-source-hint {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--accent-primary);
    text-align: right;
    opacity: 0.8;
}

/* Share Page (public read-only view) */
.share-page {
    min-height: calc(100vh - 100px);
    background: var(--bg-primary);
}

.share-page-layout {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.share-page-header {
    margin-bottom: 2rem;
}

.share-back-link {
    display: inline-block;
    font-size: 0.9rem;
    color: var(--accent-primary);
    text-decoration: none;
    margin-bottom: 0.5rem;
    transition: opacity 0.2s;
}

.share-back-link:hover {
    opacity: 0.85;
}

.share-page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.share-page-content {
    min-height: 200px;
}

.share-loading,
.share-error {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.share-chat-view {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.share-cta {
    margin-top: 2rem;
    text-align: center;
}

.share-cta .btn {
    padding: 0.75rem 2rem;
}

/* Pulse animation for NEW badge */
@keyframes pulse {

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

    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {

    /* Hide footer on doubt solver page - use JavaScript to add class */
    body.doubt-solver-active footer {
        display: none !important;
    }

    .doubt-solver-chat-layout {
        height: calc(100vh - 120px);
        /* Adjust for mobile navbar */
    }

    .chat-msg-wrap {
        max-width: 90%;
    }

    .doubt-solver-input-area {
        padding: 1rem;
    }
}

/* Source Badge - Shows answer quality/source */
.doubt-solver-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-radius: 999px;
    margin-bottom: 0.75rem;
    animation: badgeFadeIn 0.4s ease;
}

@keyframes badgeFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

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

.doubt-solver-source-badge .badge-icon {
    font-size: 0.85rem;
}

.doubt-solver-source-badge.badge-kb {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.08));
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.doubt-solver-source-badge.badge-general {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(139, 92, 246, 0.08));
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.25);
}

.doubt-solver-source-badge.badge-model {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(56, 189, 248, 0.08));
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.25);
}

/* Progress Status Bar */
.doubt-solver-progress-status {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    margin: 0 1.5rem 0.5rem;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 0.85;
    }

    50% {
        opacity: 1;
    }
}

.doubt-solver-progress-status.connecting {
    border-color: rgba(251, 191, 36, 0.3);
}

.doubt-solver-progress-status.searching {
    border-color: rgba(56, 189, 248, 0.3);
}

.doubt-solver-progress-status.generating {
    border-color: rgba(34, 197, 94, 0.3);
}

.doubt-solver-progress-status.processing {
    border-color: rgba(139, 92, 246, 0.3);
}

.progress-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spinnerSpin 0.8s linear infinite;
}

@keyframes spinnerSpin {
    to {
        transform: rotate(360deg);
    }
}

.progress-text {
    flex: 1;
}

/* Remaining Questions Badge - Compact to maximize reading area */
.doubt-solver-remaining-badge {
    display: none;
    padding: 0.35rem 1rem;
    margin: 0.25rem 1.5rem 0.5rem;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    position: relative;
    z-index: 5;
}

.doubt-solver-remaining-badge .remaining-count {
    font-weight: 600;
    color: var(--accent-primary);
}

.doubt-solver-remaining-badge.low {
    border-color: rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.1);
}

.doubt-solver-remaining-badge.low .remaining-count {
    color: #fbbf24;
}

/* Upgrade Modal */
.doubt-solver-upgrade-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.upgrade-modal-content {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.upgrade-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upgrade-modal-content h3 {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.upgrade-modal-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.upgrade-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.upgrade-actions .btn {
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.upgrade-actions .upgrade-btn {
    background: var(--gradient-primary);
    border: none;
    color: white;
}

.upgrade-actions .upgrade-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.upgrade-actions .close-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
}

.upgrade-actions .close-btn:hover {
    border-color: rgba(255, 255, 255, 0.4);
    color: var(--text-primary);
}

/* Retry Button */
.doubt-solver-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
    cursor: pointer;
    transition: all 0.2s;
}

.doubt-solver-retry-btn:hover {
    background: rgba(251, 191, 36, 0.2);
    border-color: rgba(251, 191, 36, 0.5);
}

/* Error Bubble */
.chat-bubble-error {
    border-color: rgba(239, 68, 68, 0.3) !important;
    background: rgba(239, 68, 68, 0.1) !important;
}

.chat-bubble-error .error-content {
    color: #fca5a5;
}

/* =========================================
   MOBILE RESPONSIVE - POLISHED UI
   ========================================= */
@media (max-width: 768px) {

    /* Page - fill mobile viewport completely */
    /* Uses JS-calculated --vh variable for accurate viewport height */
    /* Falls back to 100dvh, then 100vh for older browsers */
    .doubt-solver-page {
        /* Primary: Use JS-calculated viewport height (most accurate with keyboard) */
        height: calc(var(--viewport-height, 100dvh) - 70px) !important;
        min-height: calc(var(--viewport-height, 100dvh) - 70px) !important;
        max-height: calc(var(--viewport-height, 100dvh) - 70px) !important;
        overflow: hidden !important;
        position: fixed !important;
        /* Start BELOW the main navbar so it never overlaps or hides it */
        top: 70px !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        padding-top: 0 !important;
        /* CRITICAL: Solid background to prevent content bleed-through */
        background-color: var(--bg-primary, #0f172a) !important;
        /* Layer above other page content */
        z-index: 100 !important;
        /* Prevent layout shift during viewport changes */
        contain: layout size style;
    }

    /* Layout - full width edge-to-edge, no container feel */
    .doubt-solver-chat-layout {
        max-width: 100%;
        width: 100%;
        padding: 0;
        margin: 0;
        height: 100% !important;
        min-height: 100% !important;
        max-height: 100% !important;
        /* Remove any background that creates container feel */
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }

    /* HEADER - COMPLETELY HIDDEN on mobile to maximize chat space */
    .doubt-solver-chat-header {
        display: none !important;
        height: 0 !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
    }


    /* Title - inline, smaller */
    .doubt-solver-chat-title {
        font-size: 0.9rem;
        width: auto;
        text-align: left;
        white-space: nowrap;
    }

    .doubt-solver-header-right {
        width: auto;
        flex-shrink: 0;
    }

    /* Category - small filter icon style */
    .doubt-solver-category-select {
        font-size: 0.8rem;
        padding: 0.35rem 1.25rem 0.35rem 0.5rem;
        max-width: 120px;
        background-size: 0.8rem;
        background-position: right 0.4rem center;
    }

    /* Chat main area - flex container for messages + input */
    .doubt-solver-chat-main {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    /* MESSAGES - Flex grow to fill available space */
    .doubt-solver-messages {
        flex: 1 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        /* Top padding so first message isn't behind navbar, minimal bottom padding for more reading space */
        padding: 0.75rem 0.5rem 0.15rem 0.5rem !important;
    }

    /* Also target alternate class name */
    .doubt-solver-chat-messages {
        flex: 1 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        /* Top padding so first message isn't behind navbar, minimal bottom padding for more reading space */
        padding: 0.75rem 0.5rem 0.15rem 0.5rem !important;
    }

    .chat-msg-wrap {
        max-width: 98% !important;
        margin-bottom: 0.5rem !important;
    }

    .chat-msg-row {
        gap: 0.4rem !important;
    }

    .chat-bubble {
        padding: 0.75rem 0.85rem !important;
        font-size: 0.9rem !important;
        line-height: 1.6 !important;
        border-radius: 1rem !important;
        /* NATIVE CHAT FEEL - Remove card/glass effects */
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    /* Assistant messages - visible but not card-like */
    .chat-bubble-assistant {
        background: rgba(30, 41, 59, 0.8) !important;
        border: none !important;
        box-shadow: none !important;
    }

    /* User messages - cleaner appearance */
    .chat-bubble-user {
        box-shadow: none !important;
    }

    /* ============================================
       MOBILE ANSWER FORMATTING - SCANNABLE DESIGN
       ============================================ */

    /* Base text alignment */
    .chat-bubble .msg-text {
        text-align: left !important;
    }

    /* NUMBERED LISTS - Clean hierarchy with visual spacing */
    .chat-bubble ol {
        margin: 0.75rem 0 !important;
        padding-left: 0 !important;
        list-style: none !important;
        counter-reset: step-counter !important;
    }

    .chat-bubble ol>li {
        position: relative !important;
        padding-left: 1.5rem !important;
        margin-bottom: 0.9rem !important;
        line-height: 1.55 !important;
        border-left: 2px solid rgba(59, 130, 246, 0.3) !important;
        padding-bottom: 0.25rem !important;
    }

    .chat-bubble ol>li::before {
        content: counter(step-counter) !important;
        counter-increment: step-counter !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 1.25rem !important;
        font-weight: 700 !important;
        color: #60a5fa !important;
        font-size: 0.85rem !important;
    }

    /* BULLET LISTS - Compact sub-points */
    .chat-bubble ul {
        margin: 0.4rem 0 !important;
        padding-left: 1rem !important;
        list-style: none !important;
    }

    .chat-bubble ul>li {
        position: relative !important;
        padding-left: 0.9rem !important;
        margin-bottom: 0.4rem !important;
        line-height: 1.5 !important;
        font-size: 0.88rem !important;
    }

    .chat-bubble ul>li::before {
        content: "•" !important;
        position: absolute !important;
        left: 0 !important;
        color: #94a3b8 !important;
        font-weight: bold !important;
    }

    /* NESTED LISTS - Shallow indent for mobile */
    .chat-bubble li>ul,
    .chat-bubble li>ol {
        margin-top: 0.3rem !important;
        margin-bottom: 0.3rem !important;
        padding-left: 0.8rem !important;
    }

    .chat-bubble li>ul>li {
        margin-bottom: 0.25rem !important;
        font-size: 0.85rem !important;
        color: #cbd5e1 !important;
    }

    /* HEADINGS - Clear visual breaks */
    .chat-bubble h1,
    .chat-bubble h2,
    .chat-bubble h3 {
        font-size: 0.95rem !important;
        font-weight: 700 !important;
        color: #f8fafc !important;
        margin: 1rem 0 0.5rem 0 !important;
        padding-bottom: 0.25rem !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    }

    .chat-bubble h1:first-child,
    .chat-bubble h2:first-child,
    .chat-bubble h3:first-child {
        margin-top: 0 !important;
    }

    .chat-bubble h4,
    .chat-bubble h5,
    .chat-bubble h6 {
        font-size: 0.9rem !important;
        font-weight: 600 !important;
        color: #e2e8f0 !important;
        margin: 0.75rem 0 0.35rem 0 !important;
    }

    /* BOLD TEXT - Standout for key terms */
    .chat-bubble strong,
    .chat-bubble b {
        font-weight: 700 !important;
        color: #f1f5f9 !important;
    }

    /* PARAGRAPHS - Breathing room */
    .chat-bubble p {
        margin: 0.5rem 0 !important;
    }

    .chat-bubble p:first-child {
        margin-top: 0 !important;
    }

    .chat-bubble p:last-child {
        margin-bottom: 0 !important;
    }

    /* CODE - Inline code styling */
    .chat-bubble code {
        font-size: 0.82rem !important;
        font-family: 'SF Mono', Monaco, 'Courier New', monospace !important;
        background: rgba(0, 0, 0, 0.25) !important;
        padding: 0.15rem 0.35rem !important;
        border-radius: 0.25rem !important;
        color: #fbbf24 !important;
    }

    /* EMPHASIS - Subtle highlight */
    .chat-bubble em,
    .chat-bubble i {
        font-style: italic !important;
        color: #a5b4fc !important;
    }

    /* BLOCKQUOTES - Visual callout */
    .chat-bubble blockquote {
        margin: 0.5rem 0 !important;
        padding: 0.5rem 0.75rem !important;
        border-left: 3px solid #3b82f6 !important;
        background: rgba(59, 130, 246, 0.1) !important;
        border-radius: 0 0.5rem 0.5rem 0 !important;
        font-size: 0.88rem !important;
    }

    /* HORIZONTAL RULE - Section break */
    .chat-bubble hr {
        margin: 0.75rem 0 !important;
        border: none !important;
        border-top: 1px solid rgba(255, 255, 255, 0.15) !important;
    }



    /* Source badge - compact */
    .doubt-solver-source-badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.4rem;
        margin-bottom: 0.25rem;
    }

    /* Avatar - smaller */
    .chat-avatar {
        width: 26px !important;
        height: 26px !important;
        min-width: 26px !important;
        flex-shrink: 0;
    }

    /* INPUT AREA - Fixed at bottom, seamless with page */
    .doubt-solver-input-area {
        flex-shrink: 0 !important;
        position: relative !important;
        bottom: auto !important;
        /* Slight top margin to push whole control cluster a bit lower */
        margin-top: 0.35rem !important;
        /* MAXIMIZE WIDTH: Very small side padding (4px) to mimic ChatGPT */
        padding: 0.5rem 0.25rem !important;
        /* Minimal bottom padding, only safe area inset */
        padding-bottom: calc(0.25rem + env(safe-area-inset-bottom, 0px)) !important;
        /* Seamless background - matches page */
        background: var(--bg-primary, #0f172a) !important;
        /* Subtle separator, not card-like */
        border-top: none !important;
        z-index: 100 !important;
        box-sizing: border-box !important;
    }

    /* Force pill shape and max width for the internal row */
    .doubt-solver-input-row {
        border-radius: 2rem !important;
        /* Pill shape */
        padding: 0.35rem 0.5rem !important;
        /* Compact internal padding */
        width: 100% !important;
    }

    /* Also target alternate class name */
    .doubt-solver-input-wrap {
        flex-shrink: 0 !important;
        position: relative !important;
        bottom: auto !important;
        /* Keep in sync with .doubt-solver-input-area */
        margin-top: 0.35rem !important;
        padding: 0.5rem 0.75rem !important;
        padding-bottom: calc(0.25rem + env(safe-area-inset-bottom, 0px)) !important;
        /* Seamless background - matches page */
        background: var(--bg-primary, #0f172a) !important;
        /* Subtle separator, not card-like */
        border-top: none !important;
        z-index: 100 !important;
        box-sizing: border-box !important;
    }

    /* Push sources & chips slightly lower as a block */
    .doubt-solver-sources-wrap {
        margin-top: 0.4rem !important;
    }

    #doubt-solver-chips-wrap {
        margin-top: 0.35rem !important;
    }

    .doubt-solver-input {
        font-size: 0.9rem;
        padding: 0.65rem 0.75rem;
        border-radius: 1.25rem;
        min-height: 42px;
    }

    .doubt-solver-send-btn {
        padding: 0.5rem 0.75rem;
        min-width: 42px;
        height: 42px;
        border-radius: 50%;
    }

    /* Hide WhatsApp when input is focused (for other pages) */
    body.input-focused .floating-chat-button,
    body.input-focused #support-widget-button {
        display: none !important;
    }


    /* SOURCES toggle - more compact */
    .doubt-solver-sources-toggle {
        font-size: 0.75rem !important;
        padding: 0.3rem 0.6rem !important;
    }

    .doubt-solver-sources-wrap {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        margin: 0.25rem 0 !important;
        max-height: 200px;
        /* Increased from 120px to show all 5 sources */
    }

    .doubt-solver-source-item {
        font-size: 0.8rem !important;
        padding: 0.4rem 0.5rem !important;
    }

    /* RELATED QUESTIONS - Compact */
    .doubt-solver-related-wrap {
        flex-direction: column;
        align-items: stretch;
        gap: 0.3rem !important;
        margin-top: 0.5rem !important;
    }

    .doubt-solver-related-btn {
        width: 100%;
        text-align: left;
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem !important;
    }

    /* CHIPS - Compact */
    .doubt-solver-chips {
        padding: 0.25rem 0.5rem;
        gap: 0.35rem;
        flex-wrap: wrap;
    }

    .doubt-solver-chip {
        font-size: 0.75rem;
        padding: 0.35rem 0.6rem;
    }

    /* Progress status - smaller, positioned above input, not below messages */
    .doubt-solver-progress-status {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
        margin: 0 0.5rem 0.5rem !important;
        position: fixed;
        bottom: calc(60px + env(safe-area-inset-bottom, 0));
        left: 0;
        right: 0;
        z-index: 99;
        background: rgba(15, 23, 42, 0.98) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
    }

    /* Remaining badge - inline */
    .doubt-solver-remaining-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }

    /* Welcome message styling */
    .chat-msg-wrap:first-child .chat-bubble {
        font-size: 0.85rem !important;
    }

    /* CHATGPT STYLE MATCH: Remove card look for assistant messages on mobile */
    .chat-bubble-assistant {
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        backdrop-filter: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    /* Allow full width for text */
    .chat-msg-assistant {
        max-width: 100% !important;
        padding-right: 0.5rem !important;
        /* Minimal buffer */
    }

    /* Ensure text color is readable and strong */
    .chat-bubble-assistant .msg-text {
        color: #f8fafc !important;
        /* Slate-50 - Higher contrast */
        font-weight: 400 !important;
        line-height: 1.7 !important;
        /* More breathing room */
        font-size: 1rem !important;
        /* 16px - ChatGPT standard */
        letter-spacing: 0.01em;
    }

    /* Improve paragraph spacing */
    .chat-bubble-assistant .msg-text p {
        margin-bottom: 1.25rem !important;
        /* More space between paragraphs */
    }

    /* Improve list spacing */
    .chat-bubble-assistant .msg-text li {
        margin-bottom: 0.5rem !important;
        padding-left: 0.25rem;
    }
}

@media (max-width: 480px) {
    .doubt-solver-chat-header {
        padding: 0.4rem 0.5rem;
    }

    .doubt-solver-chat-title {
        font-size: 0.85rem;
    }

    .doubt-solver-category-select {
        font-size: 0.75rem;
        max-width: 100px;
        padding: 0.3rem 1rem 0.3rem 0.4rem;
    }

    .chat-bubble {
        padding: 0.4rem 0.55rem !important;
        font-size: 0.85rem !important;
    }

    /* Force readable font for assistant even on small screens */
    .chat-bubble-assistant {
        font-size: 1rem !important;
        padding: 0 !important;
        /* Keep stripped padding */
    }

    .chat-avatar {
        width: 24px !important;
        height: 24px !important;
        min-width: 24px !important;
    }

    .doubt-solver-input-area,
    .doubt-solver-input-wrap {
        padding: 0.4rem 0.25rem !important;
    }

    .doubt-solver-input {
        font-size: 0.85rem;
        padding: 0.5rem 0.6rem;
        min-height: 38px;
    }

    .doubt-solver-send-btn,
    .doubt-solver-send {
        min-width: 38px;
        width: 38px;
        height: 38px;
    }
}