/**
 * RAG Chatbot Styles
 *
 * Floating chatbot widget styling for Uit Holland.
 *
 * @package Uit_Holland_Theme
 * @since 1.53.0
 */

/* Font size CSS variables - controlled via JS toggle */
#rag-chatbot {
    --rag-font-size-base: 14px;
    --rag-font-size-small: 12px;
    --rag-font-size-heading: 15px;
    --rag-font-size-input: 14px;
}

/* Font size presets - applied via data-font-size attribute */
/* medium = default (no attribute needed) */

#rag-chatbot[data-font-size="large"] {
    --rag-font-size-base: 16px;
    --rag-font-size-small: 14px;
    --rag-font-size-heading: 17px;
    --rag-font-size-input: 16px;
}

#rag-chatbot[data-font-size="xlarge"] {
    --rag-font-size-base: 18px;
    --rag-font-size-small: 16px;
    --rag-font-size-heading: 19px;
    --rag-font-size-input: 18px;
}

/* Container */
#rag-chatbot {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Launcher button */
#rag-chatbot-launcher {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #F29100; /* Uit Holland orange */
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#rag-chatbot-launcher:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#rag-chatbot-launcher .icon-close {
    display: none;
}

#rag-chatbot.is-open #rag-chatbot-launcher .icon-chat {
    display: none;
}

#rag-chatbot.is-open #rag-chatbot-launcher .icon-close {
    display: block;
}

/* Chat window */
#rag-chatbot-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

#rag-chatbot.is-open #rag-chatbot-window {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Enlarged state (first maximize click) */
#rag-chatbot.is-enlarged #rag-chatbot-window {
    width: 600px;
    max-width: calc(100vw - 48px);
    height: 80vh;
    max-height: calc(100vh - 100px);
}

/* Fullscreen state (second maximize click) */
#rag-chatbot.is-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
}

#rag-chatbot.is-fullscreen #rag-chatbot-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
}

#rag-chatbot.is-fullscreen #rag-chatbot-launcher {
    display: none;
}

/* Prevent body scroll when chatbot is enlarged or fullscreen */
body.rag-chatbot-maximized {
    overflow: hidden;
}

/* Form progress indicator */
.rag-form-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.rag-form-progress-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.rag-form-progress-bar {
    flex: 1;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.rag-form-progress-fill {
    height: 100%;
    background: #F29100;
    border-radius: 2px;
    transition: width 0.3s ease;
    animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.rag-form-progress-text {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}

.rag-form-cancel {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #666;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.rag-form-cancel:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #dc2626;
}

.rag-form-cancel svg {
    width: 16px;
    height: 16px;
}

/* Quick action buttons */
.rag-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.rag-quick-action {
    background: white;
    border: 1px solid #F29100;
    color: #F29100;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.2s;
}

.rag-quick-action:hover {
    background: #F29100;
    color: white;
    transform: scale(1.02);
}

/* Header - ALWAYS dark (never changes with dark/light mode) */
.rag-chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: #1a1a1a !important;
    color: white;
    flex-shrink: 0;
}

.rag-chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rag-chatbot-avatar {
    width: 32px;
    height: 32px;
    background: #F29100;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rag-chatbot-avatar svg {
    color: white;
}

.rag-chatbot-title {
    font-weight: 600;
    font-size: 15px;
}

/* Service selector (portal only) */
.rag-service-selector {
    margin-left: 8px;
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #2d2d2d;
    color: white;
    cursor: pointer;
    max-width: 120px;
}

.rag-service-selector:hover {
    border-color: #F29100;
}

.rag-service-selector:focus {
    outline: none;
    border-color: #F29100;
}

.rag-service-selector option {
    background: #2d2d2d;
    color: white;
}

/* Header action buttons */
.rag-chatbot-header-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.rag-chatbot-header-actions button {
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.rag-chatbot-header-actions button:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

/* Mode toggle button (search to chat) */
.rag-chatbot-mode-toggle {
    display: none;
    align-items: center;
    gap: 4px;
    background: #F29100 !important;
    color: white !important;
    padding: 4px 10px !important;
    border-radius: 12px !important;
    font-size: 12px;
    font-weight: 500;
}

.rag-chatbot-mode-toggle:hover {
    background: #e08400 !important;
}

.rag-chatbot-mode-toggle svg {
    width: 14px;
    height: 14px;
}

.rag-chatbot-mode-toggle .mode-toggle-text {
    line-height: 1;
}

/* Font size toggle button - click to cycle through sizes */
.rag-font-size-toggle-btn {
    display: flex;
    align-items: baseline;
    gap: 1px;
    padding: 4px 6px !important;
    cursor: pointer;
    transition: transform 0.2s;
}

.rag-font-size-toggle-btn:hover {
    transform: scale(1.1);
}

.rag-font-size-toggle-btn:active {
    transform: scale(0.95);
}

.rag-font-size-toggle-btn .font-size-icon {
    display: flex;
    align-items: baseline;
    gap: 1px;
}

.rag-font-size-toggle-btn .font-a-small {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.7;
}

.rag-font-size-toggle-btn .font-a-large {
    font-size: 15px;
    font-weight: 700;
}

/* Maximize button icons */
.rag-chatbot-maximize .icon-minimize {
    display: none;
}

/* Show minimize icon in enlarged and fullscreen states */
#rag-chatbot.is-enlarged .rag-chatbot-maximize .icon-maximize,
#rag-chatbot.is-fullscreen .rag-chatbot-maximize .icon-maximize {
    display: none;
}

#rag-chatbot.is-enlarged .rag-chatbot-maximize .icon-minimize,
#rag-chatbot.is-fullscreen .rag-chatbot-maximize .icon-minimize {
    display: block;
}

/* Messages container */
#rag-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain; /* Prevent page scroll when scrolling in chatbot */
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Message bubbles */
.rag-message {
    max-width: 85%;
    animation: messageSlide 0.3s ease;
}

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

.rag-message-user {
    align-self: flex-end;
}

.rag-message-assistant,
.rag-message-error {
    align-self: flex-start;
}

.rag-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: var(--rag-font-size-base) !important;
    word-wrap: break-word;
}

.rag-message-user .rag-message-content {
    white-space: pre-wrap;
    background: #F29100;
    color: white;
    border-bottom-right-radius: 4px;
}

.rag-message-assistant .rag-message-content {
    white-space: normal;
    background: #f1f3f4;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

.rag-message-error .rag-message-content {
    background: #fee2e2;
    color: #991b1b;
    border-bottom-left-radius: 4px;
}

/* Rich text formatting in messages */
.rag-message-content .rag-heading {
    display: block;
    font-size: var(--rag-font-size-heading);
    font-weight: 600;
    color: #F29100;
    margin: 12px 0 6px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(242, 145, 0, 0.2);
}

.rag-message-content .rag-heading:first-child {
    margin-top: 0;
}

.rag-message-content strong {
    font-weight: 600;
}

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

.rag-message-content ul,
.rag-message-content ol {
    margin: 2px 0 4px 0;
    padding-left: 24px;
    list-style-position: outside;
    white-space: normal;
}

.rag-message-content ul {
    list-style-type: disc;
}

.rag-message-content ol {
    list-style-type: decimal;
}

.rag-message-content li {
    margin: 2px 0;
    padding-left: 4px;
    display: list-item;
    color: inherit !important;
}

/* Ensure list items inherit from parent and override any global rules */
.rag-message-assistant .rag-message-content ul li,
.rag-message-assistant .rag-message-content ol li,
#rag-chatbot .rag-message-content ul li,
#rag-chatbot .rag-message-content ol li {
    color: inherit !important;
}

.rag-message-content ul li::marker {
    color: #F29100;
}

.rag-message-content ol li::marker {
    color: #F29100;
    font-weight: 500;
}

/* Tables in chat messages */
.rag-message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}

.rag-message-content table th,
.rag-message-content table td {
    padding: 8px 12px;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.rag-message-content table th {
    background: rgba(242, 145, 0, 0.2);
    font-weight: 600;
    color: #F29100;
}

.rag-message-content table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.05);
}

.theme-mode-light .rag-message-content table th,
.theme-mode-light .rag-message-content table td {
    border-color: rgba(0, 0, 0, 0.1);
    color: #1e293b;
}

.theme-mode-light .rag-message-content table th {
    background: rgba(242, 145, 0, 0.15);
}

.theme-mode-light .rag-message-content table tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.03);
}

/* Headings in chat messages */
.rag-message-content h3,
.rag-message-content h4 {
    margin: 16px 0 8px 0;
    font-weight: 600;
}

.rag-message-content h3 {
    font-size: 15px;
    color: #F29100;
}

.rag-message-content h4 {
    font-size: 14px;
    color: inherit;
    opacity: 0.9;
}

.rag-message-content h3:first-child,
.rag-message-content h4:first-child {
    margin-top: 0;
}

/* Calculation Result Block */
.rag-calculation-result {
    background: linear-gradient(135deg, rgba(242, 145, 0, 0.1) 0%, rgba(242, 145, 0, 0.05) 100%);
    border: 1px solid rgba(242, 145, 0, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
}

.rag-calculation-result h4 {
    color: #F29100;
    font-size: 15px;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(242, 145, 0, 0.2);
}

.rag-calculation-result p {
    margin: 8px 0;
}

.rag-calculation-result table {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    overflow: hidden;
}

.theme-mode-light .rag-calculation-result {
    background: linear-gradient(135deg, rgba(242, 145, 0, 0.08) 0%, rgba(242, 145, 0, 0.03) 100%);
}

.theme-mode-light .rag-calculation-result table {
    background: rgba(255, 255, 255, 0.8);
}

/* Price Result Block */
.rag-price-header {
    color: #F29100;
    font-size: 14px;
    margin: 0 0 8px 0;
}

.rag-price-result {
    background: linear-gradient(135deg, rgba(242, 145, 0, 0.1) 0%, rgba(242, 145, 0, 0.05) 100%);
    border: 1px solid rgba(242, 145, 0, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
}

.rag-price-result h4 {
    color: #F29100;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(242, 145, 0, 0.2);
}

.rag-price-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
    font-size: 13px;
}

.rag-price-table td,
.rag-price-table th {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.rag-price-table td:first-child {
    width: 45%;
    color: #555;
}

.rag-price-table td:last-child {
    font-weight: 500;
}

.rag-price-table thead {
    background: rgba(242, 145, 0, 0.15);
}

.rag-price-table thead th {
    font-weight: 600;
    color: #333;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.rag-price-table.rag-price-costs {
    margin-top: 16px;
}

.rag-price-table.rag-price-costs td:last-child,
.rag-price-table.rag-price-costs th:last-child {
    text-align: right;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

.rag-price-table tr.rag-price-total {
    background: rgba(242, 145, 0, 0.12);
}

.rag-price-table tr.rag-price-total td {
    border-bottom: none;
    font-size: 14px;
}

.rag-price-table tr.rag-price-total td:last-child {
    color: #F29100;
    font-size: 16px;
}

/* Dealer discount styling */
.rag-price-table tr.rag-price-discount {
    background: rgba(34, 197, 94, 0.08);
}

.rag-price-table tr.rag-price-discount td {
    color: #16a34a;
    font-size: 13px;
}

.rag-price-table tr.rag-price-purchase {
    background: rgba(34, 197, 94, 0.15);
}

.rag-price-table tr.rag-price-purchase td {
    border-bottom: none;
    font-size: 14px;
}

.rag-price-table tr.rag-price-purchase td:last-child {
    font-size: 18px;
}

.rag-price-highlight {
    color: #16a34a !important;
}

.rag-price-disclaimer {
    margin: 12px 0 0 0;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 6px;
    font-size: 11px;
    color: #666;
}

.rag-price-disclaimer em {
    font-style: normal;
}

/* Light theme adjustments */
.theme-mode-light .rag-price-result {
    background: linear-gradient(135deg, rgba(242, 145, 0, 0.08) 0%, rgba(242, 145, 0, 0.03) 100%);
}

.theme-mode-light .rag-price-table {
    background: rgba(255, 255, 255, 0.9);
}

.theme-mode-light .rag-price-table td:first-child {
    color: #444;
}

/* Sources */
.rag-message-sources {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 12px;
}

.rag-sources-label {
    color: #666;
    margin-right: 6px;
}

.rag-source-link {
    display: inline;
    color: #F29100;
    text-decoration: none;
}

.rag-source-link:hover {
    text-decoration: underline;
}

/* Non-clickable sources (PDFs without download link enabled) */
.rag-source-text {
    display: inline;
    color: #6c757d;
}

/* Service redirect button */
.rag-service-redirect {
    display: flex;
    justify-content: center;
    padding: 12px 16px;
    margin-top: 8px;
}

.rag-service-redirect-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #F29100;
    color: white;
    font-weight: 600;
    font-size: 14px;
    border-radius: 24px;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(242, 145, 0, 0.3);
}

.rag-service-redirect-btn:hover {
    background: #d97f00;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(242, 145, 0, 0.4);
    color: white !important;
    text-decoration: none;
}

.rag-service-redirect-btn svg {
    flex-shrink: 0;
}

/* Dark mode */
.theme-mode-dark .rag-service-redirect-btn {
    background: #F29100;
    color: white;
    box-shadow: 0 2px 8px rgba(242, 145, 0, 0.4);
}

.theme-mode-dark .rag-service-redirect-btn:hover {
    background: #ffab2e;
    box-shadow: 0 4px 12px rgba(255, 171, 46, 0.5);
    color: white !important;
}

/* Search results (search-only mode) - override .rag-message max-width */
.rag-message.rag-search-results {
    padding: 0;
    max-width: 100% !important;
    width: 100%;
}

.rag-search-results-header {
    font-weight: 600;
    font-size: 0.875rem;
    color: #374151;
    margin-bottom: 0.75rem;
    padding: 12px 16px 0;
}

.theme-mode-dark .rag-search-results-header {
    color: #e5e7eb;
}

.rag-search-results-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Search results grouped by document type */
.rag-search-group {
    margin-bottom: 0.5rem;
}

.rag-search-group:last-child {
    margin-bottom: 0;
}

.rag-search-group-header {
    font-weight: 600;
    font-size: 0.8rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 16px 6px;
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.theme-mode-dark .rag-search-group-header {
    color: #9ca3af;
    background-color: #1f2937;
    border-bottom-color: #374151;
}

/* "Show more" / "Toon meer" button */
.rag-show-more-btn {
    display: block;
    width: calc(100% - 32px);
    margin: 8px 16px;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #F29100;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.rag-show-more-btn:hover:not(:disabled) {
    background: #F29100;
    border-color: #F29100;
    color: white;
}

.rag-show-more-btn:disabled {
    opacity: 0.6;
    cursor: wait;
    color: #6b7280;
}

.theme-mode-dark .rag-show-more-btn {
    border-color: #374151;
    color: #F29100;
    background: #1f2937;
}

.theme-mode-dark .rag-show-more-btn:hover:not(:disabled) {
    background: #F29100;
    border-color: #F29100;
    color: white;
}

.theme-mode-dark .rag-show-more-btn:disabled {
    color: #6b7280;
}

/* System dark mode (no explicit theme class) */
@media (prefers-color-scheme: dark) {
    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-show-more-btn {
        border-color: #374151;
        color: #F29100;
        background: #1f2937;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-show-more-btn:hover:not(:disabled) {
        background: #F29100;
        border-color: #F29100;
        color: white;
    }
}

.rag-search-result-item {
    border-bottom: 1px solid #e5e7eb;
}

.rag-search-result-item:last-child {
    border-bottom: none;
}

.theme-mode-dark .rag-search-result-item {
    border-bottom-color: #374151;
}

.rag-search-result-link {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

/* When item has image, use row layout */
.rag-search-result-item.has-image .rag-search-result-link {
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
}

.rag-search-result-image {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.rag-search-result-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.rag-search-result-link:hover {
    background-color: #f3f4f6;
}

.theme-mode-dark .rag-search-result-link:hover {
    background-color: #374151;
}

.rag-search-result-title {
    font-weight: 500;
    font-size: 0.9rem;
    color: #F29100;
    margin-bottom: 0.25rem;
    line-height: 1.4;
}

.rag-search-result-excerpt {
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.theme-mode-dark .rag-search-result-excerpt {
    color: #9ca3af;
}

.rag-search-no-results {
    padding: 16px;
    text-align: center;
    color: #6b7280;
    font-size: 0.875rem;
}

.theme-mode-dark .rag-search-no-results {
    color: #9ca3af;
}

/* Search follow-up question - override .rag-message max-width */
.rag-message.rag-search-followup {
    padding: 12px 16px;
    background-color: #f9fafb;
    border-top: 1px solid #e5e7eb;
    max-width: 100% !important;
    width: 100%;
}

.theme-mode-dark .rag-search-followup {
    background-color: #1f2937;
    border-top-color: #374151;
}

.rag-followup-text {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 8px;
}

.theme-mode-dark .rag-followup-text {
    color: #9ca3af;
}

.rag-followup-buttons {
    display: flex;
    gap: 8px;
    width: 100%;
}

.rag-followup-btn {
    flex: 1;
    padding: 10px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background-color: white;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 500;
}

.rag-followup-btn:hover {
    background-color: #f3f4f6;
}

.rag-followup-btn.rag-followup-chat {
    background-color: #F29100;
    border-color: #F29100;
    color: white;
}

.rag-followup-btn.rag-followup-chat:hover {
    background-color: #d98200;
    border-color: #d98200;
}

.theme-mode-dark .rag-followup-btn {
    background-color: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

.theme-mode-dark .rag-followup-btn:hover {
    background-color: #4b5563;
}

.theme-mode-dark .rag-followup-btn.rag-followup-chat {
    background-color: #F29100;
    border-color: #F29100;
    color: white;
}

.theme-mode-dark .rag-followup-btn.rag-followup-chat:hover {
    background-color: #d98200;
    border-color: #d98200;
}

/* Typing indicator */
.rag-typing {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rag-typing-dots {
    display: flex;
    gap: 4px;
}

.rag-typing-dots span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.rag-typing-dots span:nth-child(1) { animation-delay: 0s; }
.rag-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.rag-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

.rag-typing-text {
    font-size: 12px;
    color: #666;
}

/* Input area */
.rag-chatbot-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

#rag-chatbot-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

#rag-chatbot-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: var(--rag-font-size-input);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#rag-chatbot-input:focus {
    border-color: #F29100;
    box-shadow: 0 0 0 3px rgba(242, 145, 0, 0.1);
}

#rag-chatbot-input:disabled {
    background: #f8f9fa;
    cursor: not-allowed;
}

#rag-chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #F29100;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

#rag-chatbot-send:hover:not(:disabled) {
    background: #d97f00;
    transform: scale(1.05);
}

#rag-chatbot-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Mobile responsive */
@media (max-width: 480px) {
    #rag-chatbot {
        bottom: 16px;
        right: 16px;
    }

    #rag-chatbot-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        bottom: 64px;
        right: -8px;
        border-radius: 12px;
    }

    #rag-chatbot-launcher {
        width: 48px;
        height: 48px;
    }
}

/* Dark mode support - via .theme-mode-dark class (theme toggle) */
.theme-mode-dark #rag-chatbot-window {
    background: #1a1a1a;
}

/* Header stays orange in ALL modes - no dark mode override */

.theme-mode-dark .rag-message-assistant .rag-message-content {
    background: #2d2d2d;
    color: #e5e7eb;
}

.theme-mode-dark .rag-message-sources {
    background: #2d2d2d;
}

/* Dark mode rich text formatting */
.theme-mode-dark .rag-message-assistant .rag-message-content .rag-heading {
    color: #FFB347;
    border-bottom-color: rgba(255, 179, 71, 0.2);
}

.theme-mode-dark .rag-message-assistant .rag-message-content ul li::marker,
.theme-mode-dark .rag-message-assistant .rag-message-content ol li::marker {
    color: #FFB347;
}

.theme-mode-dark .rag-sources-label {
    color: #999;
}

.theme-mode-dark .rag-chatbot-input-area {
    border-top-color: #333;
}

.theme-mode-dark #rag-chatbot-input {
    background: #2d2d2d;
    border-color: #333;
    color: #e5e7eb;
}

.theme-mode-dark #rag-chatbot-input:focus {
    border-color: #F29100;
}

.theme-mode-dark .rag-chatbot-header-actions button:hover {
    background: rgba(255, 255, 255, 0.05);
}

.theme-mode-dark .rag-form-progress {
    background: #2d2d2d;
    border-bottom-color: #333;
}

.theme-mode-dark .rag-form-progress-bar {
    background: #444;
}

.theme-mode-dark .rag-form-progress-text {
    color: #999;
}

.theme-mode-dark .rag-form-cancel {
    color: #999;
}

.theme-mode-dark .rag-form-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ef4444;
}

.theme-mode-dark .rag-quick-action {
    background: #2d2d2d;
    border-color: #F29100;
    color: #F29100;
}

.theme-mode-dark .rag-quick-action:hover {
    background: #F29100;
    color: #1a1a1a;
}

.theme-mode-dark .rag-typing-text {
    color: #999;
}

/* Light mode explicit styles - override prefers-color-scheme when user selects light mode */
.theme-mode-light #rag-chatbot-window {
    background: white !important;
}

.theme-mode-light .rag-message-assistant .rag-message-content {
    background: #f3f4f6 !important;
    color: #374151 !important;
}

/* Ensure all text elements in light mode have correct color - high specificity to override global rules */
.theme-mode-light .rag-message-assistant .rag-message-content p,
.theme-mode-light .rag-message-assistant .rag-message-content li,
.theme-mode-light .rag-message-assistant .rag-message-content span,
.theme-mode-light .rag-message-assistant .rag-message-content ul,
.theme-mode-light .rag-message-assistant .rag-message-content ol,
.theme-mode-light .rag-message-assistant .rag-message-content strong,
.theme-mode-light .rag-message-assistant .rag-message-content em,
.theme-mode-light .rag-message-assistant .rag-message-content .rag-heading,
.theme-mode-light .rag-message-assistant .rag-message-content ul li,
.theme-mode-light .rag-message-assistant .rag-message-content ol li,
.theme-mode-light #rag-chatbot .rag-message-assistant .rag-message-content li,
.theme-mode-light #rag-chatbot .rag-message-assistant .rag-message-content ul li,
.theme-mode-light #rag-chatbot .rag-message-assistant .rag-message-content ol li {
    color: #374151 !important;
}

.theme-mode-light .rag-message-assistant .rag-message-content ul li::marker,
.theme-mode-light .rag-message-assistant .rag-message-content ol li::marker {
    color: #F29100 !important;
}

.theme-mode-light .rag-message-sources {
    background: #f9fafb !important;
}

.theme-mode-light .rag-sources-label {
    color: #6b7280 !important;
}

.theme-mode-light .rag-chatbot-input-area {
    border-top-color: #e5e7eb !important;
}

.theme-mode-light #rag-chatbot-input {
    background: white !important;
    border-color: #d1d5db !important;
    color: #374151 !important;
}

.theme-mode-light #rag-chatbot-input:focus {
    border-color: #F29100 !important;
}

.theme-mode-light .rag-form-progress {
    background: #f8f9fa !important;
    border-bottom-color: #e5e7eb !important;
}

.theme-mode-light .rag-form-progress-bar {
    background: #e5e7eb !important;
}

.theme-mode-light .rag-form-progress-text {
    color: #6b7280 !important;
}

.theme-mode-light .rag-form-cancel {
    color: #6b7280 !important;
}

.theme-mode-light .rag-form-cancel:hover {
    background: rgba(0, 0, 0, 0.1) !important;
    color: #dc2626 !important;
}

.theme-mode-light .rag-quick-action {
    background: white !important;
    border-color: #F29100 !important;
    color: #F29100 !important;
}

.theme-mode-light .rag-quick-action:hover {
    background: #F29100 !important;
    color: white !important;
}

/* Dark mode support - via prefers-color-scheme (system preference)
   Only applies when NO explicit theme class is set on html element */
@media (prefers-color-scheme: dark) {
    /* Only apply when no theme-mode class is set */
    html:not(.theme-mode-light):not(.theme-mode-dark) #rag-chatbot-window {
        background: #1a1a1a;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-message-assistant .rag-message-content {
        background: #2d2d2d;
        color: #e5e7eb;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-message-sources {
        background: #2d2d2d;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-sources-label {
        color: #999;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-chatbot-input-area {
        border-top-color: #333;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) #rag-chatbot-input {
        background: #2d2d2d;
        border-color: #333;
        color: #e5e7eb;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) #rag-chatbot-input:focus {
        border-color: #F29100;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-chatbot-header-actions button:hover {
        background: rgba(255, 255, 255, 0.05);
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-form-progress {
        background: #2d2d2d;
        border-bottom-color: #333;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-form-progress-bar {
        background: #444;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-form-progress-text {
        color: #999;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-quick-action {
        background: #2d2d2d;
        border-color: #F29100;
        color: #F29100;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-quick-action:hover {
        background: #F29100;
        color: #1a1a1a;
    }
}

/* Print: hide chatbot */
@media print {
    #rag-chatbot {
        display: none !important;
    }
}

/* =====================================================
 * SLASH COMMANDS AUTOCOMPLETE (Kennisbank)
 * ===================================================== */

.rag-autocomplete-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
    z-index: 10;
}

.rag-autocomplete-item {
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}

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

.rag-autocomplete-item:hover,
.rag-autocomplete-item.selected {
    background: #FEF3C7;
}

.rag-autocomplete-command {
    font-weight: 600;
    color: #F29100;
    font-size: 14px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

.rag-autocomplete-desc {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

/* Dark mode autocomplete */
.theme-mode-dark .rag-autocomplete-dropdown {
    background: #1f2937;
    border-color: #374151;
}

.theme-mode-dark .rag-autocomplete-item {
    border-bottom-color: #374151;
}

.theme-mode-dark .rag-autocomplete-item:hover,
.theme-mode-dark .rag-autocomplete-item.selected {
    background: #374151;
}

.theme-mode-dark .rag-autocomplete-desc {
    color: #9ca3af;
}

/* System dark mode (no explicit class) */
@media (prefers-color-scheme: dark) {
    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-autocomplete-dropdown {
        background: #1f2937;
        border-color: #374151;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-autocomplete-item {
        border-bottom-color: #374151;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-autocomplete-item:hover,
    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-autocomplete-item.selected {
        background: #374151;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-autocomplete-desc {
        color: #9ca3af;
    }
}

/* =====================================================
 * KENNISBANK SEARCH RESULTS
 * ===================================================== */

.rag-kennisbank-results .rag-message-content {
    padding: 0;
    max-width: 100%;
}

.rag-kb-results-header {
    padding: 12px 16px;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    font-size: 14px;
    border-radius: 12px 12px 0 0;
}

.rag-kb-results-list {
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

.rag-kb-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: white;
}

.rag-kb-result-item:last-child {
    border-bottom: none;
}

.rag-kb-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
    gap: 8px;
}

.rag-kb-result-title {
    font-weight: 600;
    color: #10B981;
    font-size: 14px;
    flex: 1;
}

.rag-kb-result-meta {
    font-size: 11px;
    color: #6b7280;
    display: flex;
    gap: 6px;
    align-items: center;
    white-space: nowrap;
}

.rag-kb-result-excerpt {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
    margin-bottom: 10px;
}

.rag-kb-result-actions {
    display: flex;
    gap: 8px;
}

.rag-kb-btn {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
}

.rag-kb-btn-view {
    background: transparent;
    border: 1px solid #e5e7eb;
    color: #374151;
}

.rag-kb-btn-view:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.rag-kb-btn-edit {
    background: #F29100;
    color: white;
}

.rag-kb-btn-edit:hover {
    background: #d98200;
}

.rag-kb-btn-delete {
    background: #EF4444;
    color: white;
}

.rag-kb-btn-delete:hover {
    background: #DC2626;
}

.rag-kb-no-results {
    padding: 16px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* Dark mode kennisbank results */
.theme-mode-dark .rag-kb-results-list {
    border-color: #374151;
}

.theme-mode-dark .rag-kb-result-item {
    background: #1f2937;
    border-bottom-color: #374151;
}

.theme-mode-dark .rag-kb-result-excerpt {
    color: #9ca3af;
}

.theme-mode-dark .rag-kb-btn-view {
    background: transparent;
    border-color: #4b5563;
    color: #d1d5db;
}

.theme-mode-dark .rag-kb-btn-view:hover {
    background: #374151;
    border-color: #6b7280;
}

.theme-mode-dark .rag-kb-no-results {
    color: #9ca3af;
}

/* System dark mode kennisbank */
@media (prefers-color-scheme: dark) {
    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-kb-results-list {
        border-color: #374151;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-kb-result-item {
        background: #1f2937;
        border-bottom-color: #374151;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-kb-result-excerpt {
        color: #9ca3af;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-kb-btn-view {
        background: transparent;
        border-color: #4b5563;
        color: #d1d5db;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-kb-btn-view:hover {
        background: #374151;
        border-color: #6b7280;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-kb-no-results {
        color: #9ca3af;
    }
}

/* Kennisbank Item View (full item display from Bekijken button) */
.rag-kb-item-view {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
}

.rag-kb-item-header {
    font-size: 15px;
    margin-bottom: 12px;
    color: #111827;
}

.rag-kb-item-content {
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
    white-space: pre-wrap;
    margin-bottom: 12px;
}

.rag-kb-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 12px;
}

.rag-kb-item-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.rag-kb-item-actions {
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

/* Dark mode - Kennisbank Item View */
.theme-mode-dark .rag-kb-item-view {
    background: #1f2937;
    border-color: #374151;
}

.theme-mode-dark .rag-kb-item-header {
    color: #f9fafb;
}

.theme-mode-dark .rag-kb-item-content {
    color: #d1d5db;
}

.theme-mode-dark .rag-kb-item-meta {
    color: #9ca3af;
}

.theme-mode-dark .rag-kb-item-actions {
    border-color: #374151;
}

/* System dark mode preference - Kennisbank Item View */
@media (prefers-color-scheme: dark) {
    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-kb-item-view {
        background: #1f2937;
        border-color: #374151;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-kb-item-header {
        color: #f9fafb;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-kb-item-content {
        color: #d1d5db;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-kb-item-meta {
        color: #9ca3af;
    }

    html:not(.theme-mode-light):not(.theme-mode-dark) .rag-kb-item-actions {
        border-color: #374151;
    }
}

/* Shake animation when switching to search mode (chatbot already open) */
@keyframes chatbotShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

#rag-chatbot.chatbot-shake {
    animation: chatbotShake 0.5s ease-in-out;
}

/* Hint toast for search mode */
.rag-mode-hint {
    background: #FEF3C7;
    border: 1px solid #F59E0B;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 10px;
    margin-bottom: 0;
    font-size: 13px;
    color: #92400E;
    text-align: center;
    animation: slideInHint 0.3s ease-out;
    flex-shrink: 0;
}

.rag-mode-hint strong {
    color: #F29100;
    font-weight: 600;
}

.rag-mode-hint.fade-out {
    animation: fadeOutHint 0.3s ease-out forwards;
}

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

@keyframes fadeOutHint {
    to { opacity: 0; transform: translateY(-10px); }
}

/* ============================================
   Command Flow Buttons (Onthoud:/Annoteer:)
   ============================================ */
.rag-command-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    justify-content: flex-end;
    animation: slideInButtons 0.2s ease-out;
}

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

.rag-command-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #e0e0e0;
    background: white;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.rag-command-btn:hover {
    background: #f5f5f5;
    border-color: #F29100;
    color: #F29100;
}

.rag-command-btn:active {
    transform: scale(0.96);
}

/* Primary action styling (first button) */
.rag-command-btn:first-child {
    background: #F29100;
    border-color: #F29100;
    color: white;
}

.rag-command-btn:first-child:hover {
    background: #d97e00;
    border-color: #d97e00;
    color: white;
}

/* Cancel button styling (last button if contains cancel/annuleer) */
.rag-command-btn:last-child {
    background: transparent;
    border-color: #ccc;
    color: #666;
}

.rag-command-btn:last-child:hover {
    background: #f5f5f5;
    border-color: #999;
    color: #333;
}

/* ==========================================================================
   Portal Modal Detection - Hide chatbot when slide modal is open
   ========================================================================== */

/**
 * Hide chatbot when a slide-out modal or overlay modal is open in Plek portal.
 * The body class is toggled via JavaScript in the portal layout.
 *
 * @since 1.156.0
 */
body.plek-modal-open #rag-chatbot {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
