/* Pleias AI Chat Widget Styles */

/* Global Scrollbar Styling - Match Theme */
:root {
    --scrollbar-color: #ddd;
    --red-bright: #c83e4d;
}

[data-bs-theme="dark"] {
    --scrollbar-color: #373537;
}

/* Global scrollbar styling */
* {
    scrollbar-color: var(--scrollbar-color) transparent;
    scrollbar-width: thin;
}

/* Hover and focus scrollbar styling */
*:hover, *:focus-within {
    scrollbar-color: var(--red-bright) transparent;
}

/* WebKit scrollbar styling for browsers that support it */
*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--scrollbar-color);
    border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--red-bright);
}

/* Dark Mode Styles */
[data-bs-theme="dark"] {
    /* Dark mode color variables */
    --dark-bg-primary: #1a1a1a;
    --dark-bg-secondary: #2d2d2d;
    --dark-bg-tertiary: #3a3a3a;
    --dark-text-primary: #ffffff;
    --dark-text-secondary: #cccccc;
    --dark-text-muted: #999999;
    --dark-border: #404040;
    --dark-hover-bg: #404040;
}

/* Chat Container Dark Mode */
/* Only apply background to container when chat is active */
[data-bs-theme="dark"] .pleias-chat-container.active,
[data-bs-theme="dark"] .pleias-chat-widget {
    background-color: var(--dark-bg-primary);
    color: var(--dark-text-primary);
}

/* Info Modal Dark Mode */
[data-bs-theme="dark"] .pleias-info-modal {
    background-color: var(--dark-bg-primary);
    color: var(--dark-text-primary);
}

[data-bs-theme="dark"] .pleias-info-modal-header {
    border-bottom: 1px solid var(--dark-border);
}

[data-bs-theme="dark"] .pleias-info-modal-content p,
[data-bs-theme="dark"] .pleias-info-modal-content li {
    color: var(--dark-text-secondary);
}

/* Chat Messages Container Dark Mode */
[data-bs-theme="dark"] .pleias-chat-messages-container {
    background-color: var(--dark-bg-secondary);
}

[data-bs-theme="dark"] .pleias-chat-messages {
    background-color: var(--dark-bg-secondary);
}

/* Analysis Panel Dark Mode */
[data-bs-theme="dark"] .pleias-analysis-panel {
    background-color: var(--dark-bg-primary);
    border-left: 1px solid var(--dark-border);
}

[data-bs-theme="dark"] .pleias-analysis-header {
    background-color: var(--dark-bg-tertiary);
    border-bottom: 1px solid var(--dark-border);
    color: var(--dark-text-primary);
}

[data-bs-theme="dark"] .pleias-analysis-close {
    color: var(--dark-text-muted);
}

[data-bs-theme="dark"] .pleias-analysis-close:hover {
    background-color: var(--dark-hover-bg);
    color: var(--dark-text-primary);
}

[data-bs-theme="dark"] .pleias-analysis-content {
    background-color: var(--dark-bg-primary);
    color: var(--dark-text-secondary);
}

/* Message Styles Dark Mode */
[data-bs-theme="dark"] .pleias-message.ai .pleias-message-content {
    background-color: var(--dark-bg-tertiary);
    color: var(--dark-text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .pleias-message.ai .pleias-message-content h1,
[data-bs-theme="dark"] .pleias-message.ai .pleias-message-content h2,
[data-bs-theme="dark"] .pleias-message.ai .pleias-message-content h3 {
    color: var(--dark-text-primary);
}

[data-bs-theme="dark"] .pleias-message-time {
    color: var(--dark-text-muted);
}

[data-bs-theme="dark"] .pleias-message.user .pleias-message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Analysis Buttons Dark Mode */
[data-bs-theme="dark"] .pleias-show-analysis,
[data-bs-theme="dark"] .pleias-hide-analysis {
    background-color: var(--dark-bg-tertiary);
    border: 1px solid var(--dark-border);
    color: var(--dark-text-secondary);
}

[data-bs-theme="dark"] .pleias-show-analysis:hover,
[data-bs-theme="dark"] .pleias-hide-analysis:hover {
    background-color: var(--dark-hover-bg);
    border-color: var(--red-bright);
    color: var(--red-bright);
}

[data-bs-theme="dark"] .pleias-message-actions {
    border-top: 1px solid var(--dark-border);
}

/* Input Container Dark Mode */
[data-bs-theme="dark"] .pleias-chat-input-container {
    background-color: var(--dark-bg-primary);
    border-top: 1px solid var(--dark-border);
}

[data-bs-theme="dark"] .pleias-chat-input {
    background-color: var(--dark-bg-tertiary);
    border: 1px solid var(--dark-border);
    color: var(--dark-text-primary);
}

[data-bs-theme="dark"] .pleias-chat-input:focus {
    background-color: var(--dark-bg-secondary);
}

[data-bs-theme="dark"] .pleias-chat-input::placeholder {
    color: var(--dark-text-muted);
}

/* System Messages Dark Mode */
[data-bs-theme="dark"] .pleias-message.system .pleias-message-content {
    background-color: var(--dark-bg-tertiary);
    color: var(--dark-text-muted);
}

[data-bs-theme="dark"] .pleias-message.system.error .pleias-message-content {
    background-color: #4a1f1f;
    color: #ff9999;
}

/* Sources Section Dark Mode */
[data-bs-theme="dark"] .pleias-source-item {
    background-color: var(--dark-bg-secondary);
    border: 1px solid var(--dark-border);
    color: var(--dark-text-secondary);
}

[data-bs-theme="dark"] .pleias-source-header {
    color: var(--red-bright);
}

[data-bs-theme="dark"] .pleias-source-content {
    color: var(--dark-text-muted);
}

[data-bs-theme="dark"] .pleias-source-link {
    color: #6db4ee;
}

[data-bs-theme="dark"] .pleias-source-link:hover {
    background-color: rgba(109, 180, 238, 0.1);
    color: #8cc4f0;
}

[data-bs-theme="dark"] .pleias-no-sources {
    color: var(--dark-text-muted);
}

/* Analysis Duration Dark Mode */
[data-bs-theme="dark"] .pleias-analysis-duration {
    background-color: var(--dark-bg-tertiary);
    color: var(--dark-text-muted);
}

/* Debug Info Dark Mode */
[data-bs-theme="dark"] .pleias-debug-info {
    background: rgba(255, 193, 7, 0.15);
    border: 1px solid rgba(255, 193, 7, 0.4);
    color: #ffc107;
}

[data-bs-theme="dark"] .pleias-debug-info strong {
    color: #ffcd39;
}

/* Formatted Prompt Dark Mode */
[data-bs-theme="dark"] .pleias-formatted-prompt {
    background-color: var(--dark-bg-secondary);
    border: 1px solid var(--dark-border);
    color: var(--dark-text-secondary);
}

/* Analysis Sections Dark Mode */
[data-bs-theme="dark"] .pleias-analysis-section,
[data-bs-theme="dark"] .pleias-sidebar-analysis-section {
    border-top: 1px solid var(--dark-border);
}

[data-bs-theme="dark"] .pleias-analysis-section h4 {
    color: var(--dark-text-primary);
}

[data-bs-theme="dark"] .pleias-analysis-section p,
[data-bs-theme="dark"] .pleias-collapsible-content p {
    color: var(--dark-text-secondary);
}

/* Collapsible Headers Dark Mode */
[data-bs-theme="dark"] .pleias-collapsible-header {
    color: var(--dark-text-primary);
}

[data-bs-theme="dark"] .pleias-collapsible-header:hover {
    color: var(--red-bright);
}

/* Reference Links Dark Mode */
[data-bs-theme="dark"] .pleias-ref {
    background-color: var(--dark-bg-tertiary);
    color: var(--red-bright);
}

[data-bs-theme="dark"] .pleias-ref:hover {
    background-color: var(--red-bright);
    color: var(--dark-text-primary);
}

/* Tooltip Dark Mode */
[data-bs-theme="dark"] .pleias-tooltip {
    background-color: var(--dark-bg-tertiary);
    color: var(--dark-text-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .pleias-tooltip::after {
    border-bottom: 6px solid var(--dark-bg-tertiary);
}

/* Loading Overlay Dark Mode */
[data-bs-theme="dark"] .pleias-page-loading-overlay {
    background: rgba(26, 26, 26, 0.9);
}

[data-bs-theme="dark"] .pleias-page-loader {
    background: var(--dark-bg-primary);
    color: var(--dark-text-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .pleias-page-loader p {
    color: var(--dark-text-secondary);
}

/* Fullscreen Overlay Dark Mode */
[data-bs-theme="dark"] .pleias-fullscreen-overlay {
    background-color: rgba(0, 0, 0, 0.4);
}

/* Font Size Accessibility Styles */
/* Font Size 1 - Smallest */
[data-fontsize="1"] .pleias-chat-widget,
[data-fontsize="1"] .pleias-info-modal {
    font-size: 12px;
}

[data-fontsize="1"] .pleias-chat-header {
    font-size: 12px;
}

[data-fontsize="1"] .pleias-message-content {
    font-size: 11px;
}

[data-fontsize="1"] .pleias-chat-input {
    font-size: 12px;
}

/* Font Size 2 - Small */
[data-fontsize="2"] .pleias-chat-widget,
[data-fontsize="2"] .pleias-info-modal {
    font-size: 13px;
}

[data-fontsize="2"] .pleias-chat-header {
    font-size: 13px;
}

[data-fontsize="2"] .pleias-message-content {
    font-size: 12px;
}

[data-fontsize="2"] .pleias-chat-input {
    font-size: 13px;
}

/* Font Size 3 - Default (no changes needed, base styles apply) */

/* Font Size 4 - Large */
[data-fontsize="4"] .pleias-chat-widget,
[data-fontsize="4"] .pleias-info-modal {
    font-size: 16px;
}

[data-fontsize="4"] .pleias-chat-header {
    font-size: 16px;
}

[data-fontsize="4"] .pleias-message-content {
    font-size: 15px;
}

[data-fontsize="4"] .pleias-chat-input {
    font-size: 16px;
}

/* Font Size 5 - Largest */
[data-fontsize="5"] .pleias-chat-widget,
[data-fontsize="5"] .pleias-info-modal {
    font-size: 18px;
}

[data-fontsize="5"] .pleias-chat-header {
    font-size: 18px;
}

[data-fontsize="5"] .pleias-message-content {
    font-size: 17px;
}

[data-fontsize="5"] .pleias-chat-input {
    font-size: 18px;
}

/* Additional elements for larger font sizes */
[data-fontsize="4"] .pleias-info-modal-header h3,
[data-fontsize="5"] .pleias-info-modal-header h3 {
    font-size: 1.2em;
}

[data-fontsize="4"] .pleias-analysis-header,
[data-fontsize="5"] .pleias-analysis-header {
    font-size: 1em;
}

/* Font Size Increase Toggle Styles (match theme behavior) */
.font-size-increase .pleias-chat-widget,
.font-size-increase .pleias-info-modal {
    font-size: 1.15em; /* 15% increase like theme */
}

.font-size-increase .pleias-chat-header {
    font-size: 1.15em;
}

.font-size-increase .pleias-message-content,
.font-size-increase .pleias-message-content p,
.font-size-increase .pleias-message.ai .pleias-message-content,
.font-size-increase .pleias-message.ai .pleias-message-content p,
.font-size-increase .pleias-message.user .pleias-message-content {
    font-size: 1.15em !important;
}

.font-size-increase .pleias-chat-input {
    font-size: 1.15em;
}

.font-size-increase .pleias-analysis-content {
    font-size: 1.15em;
}

/* Also apply to message text elements */
.font-size-increase .pleias-message.ai .pleias-message-content h1,
.font-size-increase .pleias-message.ai .pleias-message-content h2,
.font-size-increase .pleias-message.ai .pleias-message-content h3,
.font-size-increase .pleias-message.ai .pleias-message-content strong,
.font-size-increase .pleias-message.ai .pleias-message-content li {
    font-size: 1.15em;
}

/* Dyslexic Font Styles (OpenDyslexic font family) */
.fontfam-dyslexic .pleias-chat-widget,
.fontfam-dyslexic .pleias-info-modal {
    font-family: "OpenDyslexic", Arial, sans-serif !important;
}

.fontfam-dyslexic .pleias-chat-header {
    font-family: "OpenDyslexic", Arial, sans-serif !important;
}

.fontfam-dyslexic .pleias-message-content {
    font-family: "OpenDyslexic", Arial, sans-serif !important;
}

.fontfam-dyslexic .pleias-chat-input {
    font-family: "OpenDyslexic", Arial, sans-serif !important;
}

.fontfam-dyslexic .pleias-analysis-content {
    font-family: "OpenDyslexic", Arial, sans-serif !important;
}

/* Regular font explicitly set for consistency */
.fontfam-regular .pleias-chat-widget,
.fontfam-regular .pleias-info-modal {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body #backToTop {
    bottom: 101px;
    background: rgba(0,0,0,0.5);
}

/* Fullscreen Overlay */
.pleias-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.3);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
    backdrop-filter: blur(2px);
}

.pleias-fullscreen-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Info Modal Styles */
.pleias-info-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pleias-info-modal-overlay.active {
    opacity: 1;
}

.pleias-info-modal {
    background-color: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.pleias-info-modal-overlay.active .pleias-info-modal {
    transform: scale(1);
}

.pleias-info-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e9ecef;
    background-color: var(--red);
    color: white;
    border-radius: 12px 12px 0 0;
}

.pleias-info-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.pleias-info-modal-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

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

.pleias-info-modal-close svg {
    width: 20px;
    height: 20px;
}

.pleias-info-modal-content {
    padding: 24px;
}

.pleias-info-section {
    margin-bottom: 24px;
}

.pleias-info-section:last-child {
    margin-bottom: 0;
}

.pleias-info-section h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--red);
}

.pleias-info-section p {
    margin: 0 0 12px 0;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

.pleias-info-section ul {
    margin: 0;
    padding-left: 20px;
}

.pleias-info-section li {
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

.pleias-info-section li:last-child {
    margin-bottom: 0;
}

/* Chat Toggle Button */
.pleias-chat-toggle {
    position: fixed;
    bottom: 16px;
    right: 20px;
    width: 64px;
    height: 64px;
    background-color: var(--red);
    border-radius: 32px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 9998;
    animation: pleiasTogglePulse 2s infinite;
    
    /* Safari viewport fix - ensure button stays in viewport */
    max-bottom: calc(100vh - 80px);
    max-right: calc(100vw - 84px);
}

.pleias-chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.pleias-chat-toggle .pleias-toggle-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.pleias-chat-toggle.active {
    transform: scale(0.9);
}

/* Chat Container Layout */
.pleias-chat-container {
    position: fixed;
    right: 20px;
    bottom: 16px;
    z-index: 10000;
    pointer-events: none;
}

.pleias-chat-container.active {
    pointer-events: auto;
}

/* Safari viewport fixes - only apply when NOT in fullscreen mode */
@supports (-webkit-appearance: none) {
    /* Safari-specific fixes for viewport changes - exclude fullscreen */
    .pleias-chat-container:not(.fullscreen-active) {
        /* Ensure container never goes off-screen */
        max-right: calc(100vw - 400px); /* Account for widget width */
        max-bottom: calc(100vh - 500px); /* Account for widget height */
    }
    
    .pleias-chat-toggle {
        /* More aggressive positioning constraints for Safari */
        right: min(20px, calc(100vw - 84px));
        bottom: min(16px, calc(100vh - 80px));
    }
    
    /* Force recalculation on viewport changes - exclude fullscreen elements */
    @media screen and (orientation: landscape), screen and (orientation: portrait) {
        .pleias-chat-container:not(.fullscreen-active),
        .pleias-chat-toggle {
            transform: translateZ(0); /* Force hardware acceleration and recalc */
        }
    }
}

/* Chat Widget */
.pleias-chat-widget {
    width: 504px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background-color: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(100vh);
    transition: all 0.3s ease-in-out;
    pointer-events: auto;
    position: relative;
    transform-origin: bottom right;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Expand chat widget when analysis panel is active */
.pleias-chat-widget.analysis-expanded {
    width: 864px !important;
}

/* Fullscreen mode - 90% of screen width */
.pleias-chat-widget.fullscreen {
    width: 90vw !important;
    height: 90vh !important;
    max-height: 90vh !important;
    position: fixed !important;
    top: 5vh !important;
    left: 5vw !important;
    right: 5vw !important;
    bottom: 5vh !important;
    transform: translateY(0) !important;
    transform-origin: center !important;
    z-index: 10001 !important;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Fullscreen mode with analysis expanded */
.pleias-chat-widget.fullscreen.analysis-expanded {
    width: 90vw !important;
}

/* Fullscreen icon toggle handled by JavaScript */

/* Double analysis panel width in fullscreen mode */
.pleias-chat-widget.fullscreen .pleias-analysis-panel.active {
    width: 600px !important;
}

.pleias-chat-container.active .pleias-chat-widget {
    transform: translateY(0);
}

/* Messages Container with Split View */
.pleias-chat-messages-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    background-color: #fafafa;
}

/* Chat Messages - Left Side */
.pleias-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    transition: all 0.3s ease-in-out;
    min-width: 0; /* Allow flex shrinking */
}

/* Analysis Panel - Right Side (Hidden by default) */
.pleias-analysis-panel {
    width: 0;
    background-color: white;
    border-left: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease-in-out;
    opacity: 0;
    pointer-events: none;
}

.pleias-analysis-panel.active {
    width: 300px;
    opacity: 1;
    pointer-events: auto;
}

.pleias-analysis-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    flex-shrink: 0;
}

.pleias-analysis-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pleias-analysis-close {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    width: 24px;
    height: 24px;
}

.pleias-analysis-close:hover {
    background-color: #e9ecef;
    color: #495057;
}

.pleias-analysis-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background-color: white;
}




/* Analysis Duration */
.pleias-analysis-duration {
    color: #6c757d;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 16px;
    padding: 8px 12px;
    background-color: #e9ecef;
    border-radius: 4px;
    text-align: center;
}

/* Chat header */
.pleias-chat-header {
    /* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
    background-color: var(--red);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pleias-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 40px;
}

.pleias-header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex: 1;
}

.pleias-header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pleias-logo {
    height: 32px;
    width: 32px;
    object-fit: contain;
    display: block;
}

.pleias-title {
    font-size: 14px;
    font-weight: 500;
}

.pleias-chat-close,
.pleias-chat-clear,
.pleias-chat-info,
.pleias-chat-fullscreen {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    width: 32px;
    height: 32px;
}

.pleias-chat-close:hover,
.pleias-chat-clear:hover,
.pleias-chat-info:hover,
.pleias-chat-fullscreen:hover {
    background: rgba(255, 255, 255, 0.3);
}

.pleias-chat-close svg,
.pleias-chat-clear svg,
.pleias-chat-info svg,
.pleias-chat-fullscreen svg {
    width: 16px;
    height: 16px;
}

/* Development styling for clear button */
.pleias-chat-clear, .pleias-chat-info {
    background: rgba(255, 255, 255, 0.15);
    opacity: 0.8;
}

.pleias-chat-clear:hover, .pleias-chat-info:hover {
    background: rgba(255, 255, 255, 0.25);
    opacity: 1;
}


/* Message Styles */
.pleias-message {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    animation: fadeIn 0.3s ease;
}

.pleias-message-content p {
    font-size: .9rem;
}

/* Formatted content styles for AI messages */
.pleias-message.ai .pleias-message-content h1,
.pleias-message.ai .pleias-message-content h2,
.pleias-message.ai .pleias-message-content h3 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    color: #333;
}

.pleias-message.ai .pleias-message-content h1 {
    font-size: 18px;
}

.pleias-message.ai .pleias-message-content h2 {
    font-size: 16px;
}

.pleias-message.ai .pleias-message-content h3 {
    font-size: 15px;
}

.pleias-message.ai .pleias-message-content p {
    margin: 8px 0;
    line-height: 1.6;
}

.pleias-message.ai .pleias-message-content strong {
    font-weight: 600;
    color: #333;
}

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

.pleias-message.ai .pleias-message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.pleias-message.ai .pleias-message-content li {
    margin: 4px 0;
    line-height: 1.5;
}

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

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

.pleias-message.ai {
    justify-content: flex-start;
}

.pleias-message-wrapper {
    max-width: 85%;
}

.pleias-message-content {
    padding: 12px 18px;
    border-radius: 12px;
    word-wrap: break-word;
    position: relative;
    font-size: 14px;
    line-height: 1.5;
}

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

.pleias-message.ai .pleias-message-content {
    background-color: white;
    color: #333333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Timestamp */
.pleias-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 6px;
    display: block;
}

.pleias-message.user .pleias-message-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.7);
}

/* Analysis Buttons Container */
.pleias-message-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* Show/Hide Analysis Button */
.pleias-show-analysis {
    background: none;
    border: none;
    padding: 4px 8px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.pleias-show-analysis:hover {
    color: var(--red);
}

.pleias-show-analysis svg {
    width: 16px;
    height: 16px;
}

/* Hide Analysis Button */
.pleias-hide-analysis {
    background: none;
    border: none;
    padding: 4px 8px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.pleias-hide-analysis:hover {
    color: var(--red);
}

/* Thought/Analysis Duration */
.pleias-analysis-duration {
    font-size: 11px;
    color: #999;
    margin-bottom: 12px;
    font-style: italic;
}

/* Chat Input Container */
.pleias-chat-input-container {
    padding: 20px 24px;
    background-color: white;
    border-top: 1px solid #eee;
}

.pleias-chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pleias-chat-input {
    flex: 1;
    padding: 12px 20px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background-color: #fafafa;
}

.pleias-chat-input:focus {
    border-color: var(--red);
    background-color: white;
}

.pleias-chat-input::placeholder {
    color: #999;
}

.pleias-chat-send {
    background-color: var(--red);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.pleias-chat-send:hover {
    background-color: #a83342;
    transform: scale(1.05);
}

.pleias-chat-send:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: scale(1);
}

.pleias-chat-send svg {
    width: 18px;
    height: 18px;
    fill: white;
    transform: rotate(-45deg);
}

/* Loading Animation */
.pleias-typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
}

.pleias-typing-dot {
    width: 6px;
    height: 6px;
    background-color: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

.pleias-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

/* System Messages */
.pleias-message.system .pleias-message-content {
    background-color: #f0f0f0;
    color: #666;
    text-align: center;
    font-style: italic;
    font-size: 13px;
}

.pleias-message.system.error .pleias-message-content {
    background-color: #fee;
    color: #c33;
}

/* Thought Messages */
.pleias-message.thought {
    justify-content: flex-start;
    margin-bottom: 8px;
}

.pleias-message.thought .pleias-message-content {
    background: none;
    color: #666;
    font-size: 12px;
    font-style: italic;
    padding: 4px 0;
    box-shadow: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .pleias-chat-container {
        right: 10px;
        bottom: 20px;
    }
    
    /* Mobile fullscreen container should not constrain positioning */
    .pleias-chat-container.fullscreen-active {
        position: static !important;
        right: unset !important;
        bottom: unset !important;
        left: unset !important;
        top: unset !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Hide fullscreen toggle on mobile - always fullscreen */
    .pleias-chat-fullscreen {
        display: none !important;
    }
    
    .pleias-chat-widget {
        width: calc(100vw - 20px);
        max-width: 380px;
        height: calc(100vh - 100px);
        max-height: 600px;
    }
    
    /* Keep mobile size even when analysis is expanded */
    .pleias-chat-widget.analysis-expanded {
        width: calc(100vw - 20px);
        max-width: 380px;
    }
    
    /* Mobile fullscreen - true fullscreen (100%) */
    .pleias-chat-widget.fullscreen {
        position: fixed !important;
        inset: 0 !important;            /* top/left/right/bottom: 0 */
        z-index: 10001 !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        margin: 0 !important;

        /* HEIGHT: dynamic units + fallback */
        height: 100dvh !important;
        max-height: 100dvh !important;
        height: calc(var(--vh, 1vh) * 100) !important;

        /* WIDTH: dynamic units + fallback */
        /* width: 100dvw !important;
        max-width: 100dvw !important;
        width: calc(var(--vw, 1vw) * 100) !important;
        max-width: calc(var(--vw, 1vw) * 100) !important; */

        /* Keep content clear of iOS notch/home bar (adjust if you don’t want padding) */
        padding-top: env(safe-area-inset-top, 0) !important;
        padding-right: env(safe-area-inset-right, 0) !important;
        padding-bottom: env(safe-area-inset-bottom, 0) !important;
        padding-left: env(safe-area-inset-left, 0) !important;

        /* Optional: prevent rubber-band scrolling from shifting layout */
        -webkit-overflow-scrolling: touch;
    }
    
    .pleias-chat-widget.fullscreen.analysis-expanded {
        width: 100vw !important;
    }
    
    /* Stack vertically on mobile */
    .pleias-chat-messages-container {
        flex-direction: column;
    }
    
    .pleias-chat-messages {
        padding: 16px;
        flex: 1;
        min-height: 0; /* Allow shrinking */
    }
    
    .pleias-analysis-panel {
        width: 100%;
        height: 0;
        border-left: none;
        border-top: 1px solid #e9ecef;
    }
    
    .pleias-analysis-panel.active {
        width: 100%;
        height: 200px;
        flex-shrink: 0; /* Don't shrink when active */
    }
}

/* If you want to prefer “small visual” units where supported (prevents
   horizontal nudge when UI appears), this feature-query will override above */
   @supports (width: 100svw) {
    @media (max-width: 768px) {
      .pleias-chat-widget.fullscreen {
        /* width: 100svw !important;
        max-width: 100svw !important; */
        height: 100svh !important;
        max-height: 100svh !important;
      }
    }
  }

@media (max-width: 480px) {
    .pleias-chat-widget {
        border-radius: 12px;
    }
    
    .pleias-chat-header {
        padding: 16px 20px;
        font-size: 16px;
    }
    
    .pleias-chat-messages {
        padding: 12px;
    }
    
    .pleias-message-content {
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .pleias-analysis-panel {
        height: 0;
        border-left: none;
        border-top: 1px solid #e9ecef;
    }
    
    .pleias-analysis-panel.active {
        height: 180px;
        flex-shrink: 0;
    }
    
    .pleias-analysis-content {
        padding: 12px;
    }
}

/* Reference Styles */
.pleias-ref {
    display: inline-block;
    padding: 0 4px;
    margin: 0 2px;
    background-color: #e8e8e8;
    color: var(--red);
    font-size: 12px;
    font-weight: 600;
    border-radius: 3px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.pleias-ref:hover {
    background-color: var(--red);
    color: white;
}

/* Tooltip Styles */
.pleias-tooltip {
    position: absolute;
    background-color: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.4;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.pleias-tooltip.active {
    opacity: 1;
}

/* Triangle pointer pointing up to the reference */
.pleias-tooltip::after {
    content: '';
    position: absolute;
    top: -6px;
    left: 8px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #333;
}

/* Sources Section */
.pleias-sources-section {
    margin-bottom: 16px;
}

.pleias-sources-section h4 {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}

/* Collapsible Headers */
.pleias-collapsible-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 8px 0;
    transition: color 0.2s ease;
    font-size: 15px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 12px;
}

.pleias-collapsible-header:hover {
    color: var(--red);
}

.pleias-collapse-icon {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.pleias-collapsible-content {
    margin-top: 8px;
}

.pleias-collapsible-content p {
    font-size: 13px;
    line-height: 1.5;
    color: #555;
    margin: 0;
}

.pleias-source-item {
    background-color: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.pleias-source-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--red);
    margin-bottom: 8px;
}

.pleias-source-content {
    font-size: 12px;
    line-height: 1.5;
    color: #555;
    max-height: 200px;
    overflow-y: auto;
}


/* Analysis Sections */
.pleias-analysis-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.pleias-analysis-section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.pleias-analysis-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.pleias-analysis-section p {
    font-size: 13px;
    line-height: 1.6;
    color: #555;
    margin: 0;
}

/* Resize Handles */
.pleias-resize-handle {
    position: absolute;
    background: transparent;
    z-index: 10;
}

/* Edge handles */
.pleias-resize-n {
    top: 0;
    left: 10px;
    right: 10px;
    height: 5px;
    cursor: ns-resize;
}

.pleias-resize-e {
    top: 10px;
    right: 0;
    bottom: 10px;
    width: 5px;
    cursor: ew-resize;
}

.pleias-resize-s {
    bottom: 0;
    left: 10px;
    right: 10px;
    height: 5px;
    cursor: ns-resize;
}

.pleias-resize-w {
    top: 10px;
    left: 0;
    bottom: 10px;
    width: 5px;
    cursor: ew-resize;
}

/* Corner handles */
.pleias-resize-ne {
    top: 0;
    right: 0;
    width: 10px;
    height: 10px;
    cursor: nesw-resize;
}

.pleias-resize-se {
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    cursor: nwse-resize;
}

.pleias-resize-sw {
    bottom: 0;
    left: 0;
    width: 10px;
    height: 10px;
    cursor: nesw-resize;
}

.pleias-resize-nw {
    top: 0;
    left: 0;
    width: 10px;
    height: 10px;
    cursor: nwse-resize;
}

/* Visual indicator on hover */
.pleias-resize-handle:hover {
    background: rgba(200, 62, 77, 0.1);
}

/* Active resize state */
.pleias-chat-widget.resizing {
    transition: none !important;
}

.pleias-chat-widget.resizing * {
    pointer-events: none;
    user-select: none;
}

/* Message Actions Button Improvements */
.pleias-message-actions {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #e9ecef;
}

.pleias-show-analysis,
.pleias-hide-analysis {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    color: #495057;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.pleias-show-analysis:hover,
.pleias-hide-analysis:hover {
    background-color: #e9ecef;
    border-color: var(--red);
    color: var(--red);
}

.pleias-show-analysis svg,
.pleias-hide-analysis svg {
    width: 14px;
    height: 14px;
}

/* Analysis Sections within Expansion */
.pleias-analysis-expansion .pleias-analysis-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #dee2e6;
}

.pleias-analysis-expansion .pleias-analysis-section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.pleias-analysis-expansion .pleias-analysis-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
}

.pleias-analysis-expansion .pleias-analysis-section p {
    font-size: 12px;
    line-height: 1.5;
    color: #6c757d;
    margin: 0;
}

/* Sources Section within Expansion */
.pleias-analysis-expansion .pleias-sources-section {
    margin-bottom: 20px;
}

.pleias-analysis-expansion .pleias-sources-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 12px;
}

.pleias-analysis-expansion .pleias-source-item {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}

.pleias-analysis-expansion .pleias-source-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--red);
    margin-bottom: 6px;
}

.pleias-analysis-expansion .pleias-source-content {
    font-size: 11px;
    line-height: 1.4;
    color: #6c757d;
    max-height: 150px;
    overflow-y: auto;
}


/* Formatted Prompt Section */
.pleias-formatted-prompt {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.3;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 12px;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    color: #495057;
}



/* Sources Panel Improvements */
.pleias-source-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.pleias-source-link {
    color: #3b82f6;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    padding: 2px;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.pleias-source-link:hover {
    background-color: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

.pleias-source-link svg {
    width: 12px;
    height: 12px;
}

.pleias-no-sources {
    text-align: center;
    color: #6b7280;
    font-style: italic;
    padding: 20px;
}

/* Sources sidebar analysis sections */
.pleias-sidebar-analysis-section {
    margin-bottom: 45px;
}

/* Debug information styling */
.pleias-debug-info {
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    color: #856404;
    line-height: 1.4;
}

.pleias-debug-info strong {
    color: #b45309;
    font-weight: 600;
}

/* Source items styling improvements */

/* Page Loading Overlay */
.pleias-page-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.pleias-page-loader {
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
}

.pleias-page-loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--red);
    border-radius: 50%;
    animation: pleias-spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes pleias-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.pleias-page-loader p {
    margin: 0;
    color: #495057;
    font-size: 14px;
    font-weight: 500;
}

/* Stop pulsing animation when chat is open */
.pleias-chat-container.open .pleias-chat-toggle {
    animation: none;
}


/* Rating Buttons Styles */
.pleias-rating-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: 8px;
}

.pleias-rating-buttons button {
    background: none;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #666;
    min-width: auto;
    height: 32px;
}

.pleias-rating-buttons button i {
    font-size: 14px;
}


.pleias-rating-buttons button:hover:not(:disabled) {
    border-color: #999;
    color: #999;
    background-color: rgba(0, 0, 0, 0.05);
}

.pleias-rating-buttons button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.pleias-rating-buttons button.loading {
    opacity: 0.7;
}

/* Rated state - green for thumbs up */
.pleias-rating-buttons .pleias-rate-up.rated {
    border-color: #22c55e;
    color: #22c55e;
    background-color: rgba(34, 197, 94, 0.1);
}

/* Rated state - red for thumbs down */
.pleias-rating-buttons .pleias-rate-down.rated {
    border-color: #dc2626;
    color: #dc2626;
    background-color: rgba(220, 38, 38, 0.1);
}


.pleias-rating-buttons.rated {
    pointer-events: none;
}

/* Rating feedback messages */
.pleias-rating-feedback {
    text-align: center;
    padding: 8px 16px;
    margin: 8px 0;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    animation: fadeInUp 0.3s ease;
}

.pleias-rating-feedback.pleias-rating-success {
    background-color: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #16a34a;
}

.pleias-rating-feedback.pleias-rating-error {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dark mode rating buttons */
[data-bs-theme="dark"] .pleias-rating-buttons button {
    border-color: var(--dark-border);
    color: var(--dark-text-muted);
}

[data-bs-theme="dark"] .pleias-rating-buttons button:hover:not(:disabled) {
    border-color: #999;
    color: #999;
    background-color: rgba(255, 255, 255, 0.05);
}

/* Dark mode - rated state green for thumbs up */
[data-bs-theme="dark"] .pleias-rating-buttons .pleias-rate-up.rated {
    border-color: #22c55e;
    color: #22c55e;
    background-color: rgba(34, 197, 94, 0.2);
}

/* Dark mode - rated state red for thumbs down */
[data-bs-theme="dark"] .pleias-rating-buttons .pleias-rate-down.rated {
    border-color: #f87171;
    color: #f87171;
    background-color: rgba(248, 113, 113, 0.2);
}

[data-bs-theme="dark"] .pleias-rating-feedback.pleias-rating-success {
    background-color: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.4);
    color: #4ade80;
}

[data-bs-theme="dark"] .pleias-rating-feedback.pleias-rating-error {
    background-color: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

/* Mobile responsive rating buttons */
@media (max-width: 768px) {
    .pleias-rating-buttons {
        gap: 6px;
        margin-left: 6px;
    }

    .pleias-rating-buttons button {
        padding: 5px 10px;
        font-size: 11px;
        height: 28px;
    }

    .pleias-rating-buttons button i {
        font-size: 12px;
    }

}

/* Welcome Bubble Styles */
.pleias-welcome-bubble {
    position: fixed;
    bottom: 24px;
    right: 100px; /* Position to the left of the toggle button */
    max-width: 280px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transition: all 0.3s ease-in-out;
    pointer-events: none;
}

.pleias-welcome-bubble.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.pleias-welcome-bubble-content {
    background: white;
    padding: 16px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border: 1px solid #e9ecef;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: welcomeBubbleBounce 0.4s ease-out;
}

.pleias-welcome-bubble-text {
    flex: 1;
    color: #333;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 500;
}

.pleias-welcome-bubble-close {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 2px;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.pleias-welcome-bubble-close:hover {
    color: #666;
    background-color: #f0f0f0;
}

.pleias-welcome-bubble-arrow {
    position: absolute;
    right: -8px;
    bottom: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid white;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.pleias-welcome-bubble-arrow::after {
    content: '';
    position: absolute;
    right: 1px;
    bottom: -8px;
    width: 0;
    height: 0;
    border-left: 8px solid #e9ecef;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

/* Welcome bubble bounce animation */
@keyframes welcomeBubbleBounce {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Dark mode styles for welcome bubble */
[data-bs-theme="dark"] .pleias-welcome-bubble-content {
    background-color: var(--dark-bg-primary);
    border-color: var(--dark-border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .pleias-welcome-bubble-text {
    color: var(--dark-text-primary);
}

[data-bs-theme="dark"] .pleias-welcome-bubble-close {
    color: var(--dark-text-muted);
}

[data-bs-theme="dark"] .pleias-welcome-bubble-close:hover {
    color: var(--dark-text-primary);
    background-color: var(--dark-hover-bg);
}

[data-bs-theme="dark"] .pleias-welcome-bubble-arrow {
    border-left-color: var(--dark-bg-primary);
}

[data-bs-theme="dark"] .pleias-welcome-bubble-arrow::after {
    border-left-color: var(--dark-border);
}

/* Mobile responsive welcome bubble */
@media (max-width: 768px) {
    .pleias-welcome-bubble {
        right: 20px;
        bottom: 90px; /* Position above toggle button on mobile */
        left: 20px;
        max-width: none;
        width: calc(100vw - 40px);
    }
    
    .pleias-welcome-bubble-arrow {
        right: 30px; /* Align with toggle button */
        bottom: -8px;
        border-left: 8px solid white;
        border-right: none;
        border-top: 8px solid transparent;
        border-bottom: 8px solid transparent;
        transform: rotate(90deg);
    }
    
    .pleias-welcome-bubble-arrow::after {
        transform: rotate(90deg);
        right: 1px;
        bottom: -8px;
        border-left: 8px solid #e9ecef;
    }
    
    [data-bs-theme="dark"] .pleias-welcome-bubble-arrow {
        border-left-color: var(--dark-bg-primary);
    }
    
    [data-bs-theme="dark"] .pleias-welcome-bubble-arrow::after {
        border-left-color: var(--dark-border);
    }
}

/* Fade-out pulsing animation for chat toggle button */
@keyframes pleiasTogglePulse {
    0% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(200, 62, 77, 0.5);
    }
    50% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 15px rgba(200, 62, 77, 0);
    }
    100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(200, 62, 77, 0);
    }
}