/**
 * Artemis Chat Widget Enhanced Styles v5.0.0
 * Complete styling for all P0-P3 improvements
 * @version 5.0.0
 */

/* ========== Import base styles ========== */
@import url('artemis-chat-widget.css');

/* ========== Accessibility ========== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ========== Background Scroll - Removed (Nov 4, 2025) ========== */
/* UX IMPROVEMENT: Allow page scrolling while chat widget is open
 * Users need to scroll the page to see targeting recommendations
 * even when the chat widget is open.
 *
 * The chat widget is a floating overlay, not a modal dialog.
 * Users should be able to:
 * 1. Scroll inside chat widget (to see message history)
 * 2. Scroll main page (to see targeting recommendations)
 * 3. Both should work independently
 *
 * Previous behavior (overflow:hidden) blocked page scrolling - removed.
 */

/* ========== Enhanced Typing Indicator ========== */
.artemis-typing-dots {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: var(--artemis-space-3) var(--artemis-space-4);
}

.artemis-typing-dots .dot {
    width: 10px;
    height: 10px;
    background: var(--artemis-primary);
    border-radius: var(--artemis-radius-full);
    animation: artemisTypingDot 1.4s infinite ease-in-out;
}

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

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

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

@keyframes artemisTypingDot {
    0%, 60%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

[data-theme="dark"] .artemis-typing-dots .dot {
    background: var(--artemis-accent);
    box-shadow: 0 0 8px rgba(var(--artemis-accent-rgb), 0.5);
}

/* ========== Progressive Status Indicators (Nov 11, 2025) ========== */
.artemis-progress-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: var(--artemis-space-3) var(--artemis-space-4);
}

.artemis-progress-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(var(--artemis-primary-rgb, 37, 99, 235), 0.2);
    border-top-color: var(--artemis-primary, #2563eb);
    border-radius: 50%;
    animation: artemisSpinnerRotate 1s linear infinite;
}

@keyframes artemisSpinnerRotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.artemis-progress-message {
    font-size: 14px;
    color: var(--artemis-text-secondary, #6b7280);
    font-weight: 500;
    animation: artemisFadeIn 0.3s ease-in;
}

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

/* Dark mode styles for progress indicators */
[data-theme="dark"] .artemis-progress-spinner {
    border-color: rgba(var(--artemis-accent-rgb, 59, 130, 246), 0.3);
    border-top-color: var(--artemis-accent, #3b82f6);
    box-shadow: 0 0 10px rgba(var(--artemis-accent-rgb, 59, 130, 246), 0.3);
}

[data-theme="dark"] .artemis-progress-message {
    color: var(--artemis-text-primary, #f3f4f6);
}

/* ========== Message Footer (timestamps + edit button) ========== */
.artemis-message-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--artemis-space-2);
    gap: var(--artemis-space-2);
}

.artemis-message-edit {
    background: none;
    border: none;
    color: var(--artemis-text-secondary);
    cursor: pointer;
    padding: var(--artemis-space-1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--artemis-radius-sm);
    transition: all var(--artemis-transition-base);
    min-width: 32px;
    min-height: 32px;
}

.artemis-message-edit:hover {
    color: var(--artemis-primary);
    background: rgba(var(--artemis-primary-rgb), 0.1);
}

.artemis-message-edit:focus {
    outline: 2px solid var(--artemis-accent);
    outline-offset: 2px;
}

/* ========== Message Editing UI ========== */
.artemis-message-edit-input {
    width: 100%;
    padding: var(--artemis-space-3);
    border: 1px solid var(--artemis-border);
    border-radius: var(--artemis-radius-md);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    margin-bottom: var(--artemis-space-2);
}

.artemis-message-edit-input:focus {
    outline: none;
    border-color: var(--artemis-accent);
    box-shadow: 0 0 0 3px rgba(var(--artemis-accent-rgb), 0.15);
}

.artemis-edit-actions {
    display: flex;
    gap: var(--artemis-space-2);
    justify-content: flex-end;
}

.artemis-btn-save,
.artemis-btn-cancel {
    padding: var(--artemis-space-2) var(--artemis-space-4);
    border-radius: var(--artemis-radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--artemis-transition-base);
    border: none;
    min-height: 36px;
}

.artemis-btn-save {
    background: linear-gradient(135deg, var(--artemis-accent) 0%, var(--artemis-accent-hover) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(var(--artemis-accent-rgb), 0.3);
}

.artemis-btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--artemis-accent-rgb), 0.4);
}

.artemis-btn-cancel {
    background: var(--artemis-background);
    color: var(--artemis-text-primary);
    border: 1px solid var(--artemis-border);
}

.artemis-btn-cancel:hover {
    background: var(--artemis-border);
}

.edited-label {
    font-size: 11px;
    color: var(--artemis-text-secondary);
    font-style: italic;
    margin-left: var(--artemis-space-2);
}

/* ========== System Messages ========== */
.artemis-message.system {
    justify-content: center;
}

.artemis-message.system .artemis-message-content {
    max-width: 90%;
    text-align: center;
}

.artemis-message.system .artemis-message-text {
    background: var(--artemis-background);
    border: 1px solid var(--artemis-border);
    font-size: 13px;
    padding: var(--artemis-space-2) var(--artemis-space-3);
}

.artemis-message.system.warning .artemis-message-text {
    background: rgba(251, 188, 4, 0.1);
    border-color: var(--artemis-warning);
    color: #8b6914;
}

[data-theme="dark"] .artemis-message.system.warning .artemis-message-text {
    background: rgba(251, 188, 4, 0.15);
    color: #fbbf24;
}

.artemis-message.system.error .artemis-message-text {
    background: rgba(234, 67, 53, 0.1);
    border-color: var(--artemis-danger);
    color: #991b1b;
}

[data-theme="dark"] .artemis-message.system.error .artemis-message-text {
    background: rgba(234, 67, 53, 0.15);
    color: #f87171;
}

.artemis-message.system.success .artemis-message-text {
    background: rgba(52, 168, 83, 0.1);
    border-color: var(--artemis-success);
    color: #166534;
}

[data-theme="dark"] .artemis-message.system.success .artemis-message-text {
    background: rgba(52, 168, 83, 0.15);
    color: #4ade80;
}

.artemis-message.system.info .artemis-message-text {
    background: rgba(var(--artemis-primary-rgb), 0.1);
    border-color: var(--artemis-primary);
}

/* ========== Export Button ========== */
#artemis-export-btn {
    position: relative;
}

#artemis-export-btn:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -30px;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 1000;
}

/* ========== Enhanced Touch Targets for Mobile ========== */
@media (max-width: 640px) {
    /* MOBILE FIX: Hide chat widget header "Artemis AI Assistant" text - Nov 2, 2025 23:40 UTC */
    .artemis-chat-title,
    .artemis-chat-title h3,
    #artemis-chat-title,
    .artemis-chat-header-left .artemis-chat-title {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        max-height: 0 !important;
        overflow: hidden !important;
    }

    /* Larger touch targets */
    .artemis-chat-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .artemis-send-btn {
        min-width: 52px;
        min-height: 52px;
    }

    .artemis-message-edit {
        min-width: 44px;
        min-height: 44px;
    }

    .artemis-segment-checkbox {
        width: 20px;
        height: 20px;
        min-width: 44px;
        min-height: 44px;
        cursor: pointer;
    }

    /* Larger tap area for close button */
    .artemis-close-targeting {
        min-width: 44px;
        min-height: 44px;
    }

    /* Better spacing for edit actions on mobile */
    .artemis-edit-actions button {
        flex: 1;
        min-height: 44px;
        font-size: 14px;
    }
}

/* ========== Improved Focus States ========== */
*:focus {
    outline: 2px solid var(--artemis-accent);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 2px solid var(--artemis-accent);
    outline-offset: 2px;
}

[data-theme="dark"] *:focus,
[data-theme="dark"] *:focus-visible {
    outline-color: var(--artemis-accent);
    box-shadow: 0 0 0 4px rgba(var(--artemis-accent-rgb), 0.25);
}

/* ========== High Contrast Mode Enhancements ========== */
@media (prefers-contrast: high) {
    .artemis-chat-bubble,
    .artemis-send-btn,
    .artemis-chat-btn {
        border: 3px solid currentColor;
    }

    .artemis-message-text {
        border-width: 2px;
        border-style: solid;
    }

    .artemis-targeting-card {
        border-width: 2px;
    }

    .artemis-typing-dots .dot {
        border: 2px solid currentColor;
    }

    /* Ensure sufficient contrast for all interactive elements */
    button:hover {
        background: ButtonFace;
        color: ButtonText;
        border-color: ButtonText;
    }
}

/* ========== Reduced Motion Support ========== */
@media (prefers-reduced-motion: reduce) {
    .artemis-chat-bubble,
    .artemis-chat-widget,
    .artemis-message,
    .artemis-chat-btn,
    .artemis-targeting-card,
    .artemis-typing-dots .dot,
    .artemis-message-edit,
    .artemis-btn-save,
    .artemis-btn-cancel {
        animation: none;
        transition: none;
    }

    .artemis-typing-dots .dot {
        animation: none;
        opacity: 0.7;
    }
}

/* ========== Loading States ========== */
.artemis-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

[data-theme="dark"] .artemis-loading-overlay {
    background: rgba(0, 0, 0, 0.8);
}

.artemis-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(var(--artemis-primary-rgb), 0.2);
    border-top-color: var(--artemis-primary);
    border-radius: 50%;
    animation: artemisSpinnerRotate 0.8s linear infinite;
}

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

/* ========== Offline Indicator ========== */
.artemis-offline-banner {
    background: rgba(234, 67, 53, 0.1);
    border-bottom: 2px solid var(--artemis-danger);
    padding: var(--artemis-space-2) var(--artemis-space-4);
    text-align: center;
    font-size: 13px;
    color: var(--artemis-danger);
    font-weight: 500;
}

[data-theme="dark"] .artemis-offline-banner {
    background: rgba(234, 67, 53, 0.2);
    color: #f87171;
}

/* ========== Session Warning Banner ========== */
.artemis-session-warning {
    background: rgba(251, 188, 4, 0.1);
    border-bottom: 2px solid var(--artemis-warning);
    padding: var(--artemis-space-2) var(--artemis-space-4);
    text-align: center;
    font-size: 13px;
    color: #8b6914;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--artemis-space-2);
}

[data-theme="dark"] .artemis-session-warning {
    background: rgba(251, 188, 4, 0.2);
    color: #fbbf24;
}

/* ========== Enhanced Animations ========== */
@keyframes artemisSlideInEnhanced {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.artemis-chat-widget {
    animation: artemisSlideInEnhanced 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ========== Message Timestamps Enhancement ========== */
.artemis-message-time {
    font-size: 11px;
    color: var(--artemis-text-secondary);
    opacity: 0.8;
    transition: opacity var(--artemis-transition-base);
}

.artemis-message:hover .artemis-message-time {
    opacity: 1;
}

/* ========== Improved Scrollbar ========== */
.artemis-chat-messages::-webkit-scrollbar {
    width: 10px;
}

.artemis-chat-messages::-webkit-scrollbar-track {
    background: rgba(148, 163, 184, 0.1);
    border-radius: 5px;
    margin: 4px 0;
}

.artemis-chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--artemis-primary) 0%, var(--artemis-accent) 100%);
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.artemis-chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--artemis-primary-hover) 0%, var(--artemis-accent-hover) 100%);
}

[data-theme="dark"] .artemis-chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--artemis-accent) 0%, var(--artemis-primary) 100%);
    box-shadow: 0 0 8px rgba(var(--artemis-accent-rgb), 0.3);
}

/* ========== Performance Optimizations ========== */
.artemis-chat-widget,
.artemis-message,
.artemis-targeting-card {
    contain: layout style paint;
}

.artemis-message-text {
    will-change: transform;
    color: var(--artemis-text-primary) !important; /* CRITICAL FIX: Override global p rule from cloudline-modern-refinements.css */
}

/* Override global paragraph styling for chat messages - Fixes unreadable text bug */
/* Higher specificity (0,2,1) beats body:not(.dark-mode) p (0,1,1) */
.artemis-chat-widget .artemis-message-text p,
.artemis-chat-widget .artemis-message-text strong,
.artemis-chat-widget .artemis-message-text em {
    color: inherit !important; /* Inherit dark color from parent .artemis-message-text */
}

/* Use GPU acceleration for animations */
.artemis-chat-bubble,
.artemis-send-btn,
.artemis-chat-btn {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ========== Dark Mode Specific Enhancements ========== */
[data-theme="dark"] .artemis-message-edit-input {
    background: var(--artemis-secondary);
    border-color: var(--artemis-border);
    color: var(--artemis-text-primary);
}

[data-theme="dark"] .artemis-btn-cancel {
    background: var(--artemis-secondary);
    border-color: var(--artemis-border);
    color: var(--artemis-text-primary);
}

[data-theme="dark"] .artemis-btn-cancel:hover {
    background: var(--artemis-border);
}

/* ========== Print Styles ========== */
@media print {
    .artemis-chat-widget-container,
    .artemis-chat-backdrop,
    #artemis-live-region,
    #artemis-live-region-assertive {
        display: none !important;
    }

    /* Print conversation if widget is open */
    .artemis-chat-messages {
        display: block;
        overflow: visible;
        height: auto;
        max-height: none;
    }

    .artemis-message {
        page-break-inside: avoid;
    }
}

/* ========== Experimental: Backdrop Blur Support ========== */
@supports (backdrop-filter: blur(10px)) {
    .artemis-chat-widget {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
    }

    [data-theme="dark"] .artemis-chat-widget {
        background: rgba(37, 43, 59, 0.95);
        backdrop-filter: blur(10px);
    }
}

/* ========== Notification Pulse Animation ========== */
@keyframes artemisPulseNotification {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.artemis-chat-bubble-badge {
    animation: artemisPulseNotification 2s ease-in-out infinite;
}

/* ========== Hover Effects Enhancement ========== */
.artemis-targeting-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--artemis-shadow-md);
}

.artemis-message-edit:hover,
.artemis-close-targeting:hover {
    transform: scale(1.05);
}

/* ========== Gradient Text for Special Elements ========== */
.artemis-chat-title h3 {
    background: linear-gradient(135deg, white 0%, rgba(255, 255, 255, 0.9) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ========== Status Indicators ========== */
.artemis-status-online,
.artemis-status-offline,
.artemis-status-busy {
    display: inline-flex;
    align-items: center;
    gap: var(--artemis-space-1);
    font-size: 12px;
    padding: 2px 8px;
    border-radius: var(--artemis-radius-full);
}

.artemis-status-online {
    background: rgba(52, 168, 83, 0.1);
    color: var(--artemis-success);
}

.artemis-status-offline {
    background: rgba(148, 163, 184, 0.1);
    color: var(--artemis-text-secondary);
}

.artemis-status-busy {
    background: rgba(251, 188, 4, 0.1);
    color: var(--artemis-warning);
}

/* ========== CRITICAL FIX: Dark Mode Assistant Message Styling ========== */
/* Ensure assistant messages are visible in dark mode */
[data-theme="dark"] .artemis-message:not(.user) .artemis-message-text,
body.dark-mode .artemis-message:not(.user) .artemis-message-text,
.dark-mode .artemis-message:not(.user) .artemis-message-text {
    background: var(--artemis-card) !important;  /* Dark background #252b3b */
    color: var(--artemis-text-primary) !important;  /* Light text #E8EDF2 for visibility */
    border-color: var(--artemis-border) !important;  /* Darker border in dark mode */
}

/* ========================================================================
   CRITICAL FIX #2: Dark Mode Chat Widget Contrast (Oct 30, 2025)
   Issue: White background with light text (unreadable)
   Mobile UX Analysis: 0.93:1 contrast ratio (needs 4.5:1 WCAG AA)
   Target: WCAG AAA compliant (7:1+ contrast ratio)
   ======================================================================== */

/* Chat Widget Container - Dark Background */
.dark-mode #artemis-chat-widget,
.dark-mode .artemis-chat-widget,
body.dark-mode #artemis-chat-widget,
html.dark-mode #artemis-chat-widget,
.dark-mode [role="dialog"][class*="artemis"],
body.dark-mode [role="dialog"][class*="artemis"],
.dark-mode [role="dialog"],
body.dark-mode [role="dialog"] {
  background-color: #0f172a !important; /* Very dark slate */
  color: #ffffff !important; /* Pure white text */
  border: 1px solid #334155 !important;
}

/* Chat Header */
.dark-mode .artemis-chat-header,
body.dark-mode .artemis-chat-header,
html.dark-mode .artemis-chat-header,
.dark-mode .chat-header,
body.dark-mode .chat-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
  border-bottom: 1px solid #334155 !important;
  color: #ffffff !important;
}

.dark-mode .artemis-chat-header h3,
body.dark-mode .artemis-chat-header h3,
.dark-mode .chat-header h3,
body.dark-mode .chat-header h3 {
  color: #ffffff !important;
}

/* Messages Container */
.dark-mode #artemis-messages,
body.dark-mode #artemis-messages,
.dark-mode .artemis-messages,
body.dark-mode .artemis-messages,
.dark-mode .artemis-chat-messages,
body.dark-mode .artemis-chat-messages,
.dark-mode [role="log"],
body.dark-mode [role="log"] {
  background-color: #0f172a !important; /* Very dark background */
}

/* Assistant Messages - Dark Background + Pure White Text (WCAG AAA) */
.dark-mode .assistant-message,
body.dark-mode .assistant-message,
html.dark-mode .assistant-message,
.dark-mode .message.assistant,
body.dark-mode .message.assistant,
.dark-mode .message-content.assistant,
body.dark-mode .message-content.assistant,
.dark-mode .artemis-message:not(.user),
body.dark-mode .artemis-message:not(.user),
.dark-mode .artemis-message:not(.user) .artemis-message-text,
body.dark-mode .artemis-message:not(.user) .artemis-message-text {
  background-color: #1e293b !important; /* Dark slate background */
  color: #ffffff !important; /* Pure white text for maximum contrast */
  border-left: 3px solid #60a5fa !important; /* Blue accent */
}

/* Ensure all text within assistant messages is pure white */
.dark-mode .assistant-message *,
body.dark-mode .assistant-message *,
.dark-mode .assistant-message p,
body.dark-mode .assistant-message p,
.dark-mode .assistant-message strong,
body.dark-mode .assistant-message strong,
.dark-mode .assistant-message em,
body.dark-mode .assistant-message em,
.dark-mode .artemis-message:not(.user) *,
body.dark-mode .artemis-message:not(.user) *,
.dark-mode .artemis-message-text p,
body.dark-mode .artemis-message-text p,
.dark-mode .message-content p,
body.dark-mode .message-content p {
  color: #ffffff !important;
}

/* ========================================================================
   LIGHT MODE FIX: Assistant Message Readability (Oct 30, 2025)
   Issue: Text unreadable in light mode (white text on light background)
   Solution: Explicit dark text on light background for light mode
   ======================================================================== */

/* Assistant Messages - Light Background + Dark Text (Light Mode) */
body:not(.dark-mode) .assistant-message,
html:not(.dark-mode):not([data-theme="dark"]) .assistant-message,
body:not(.dark-mode) .message.assistant,
html:not(.dark-mode):not([data-theme="dark"]) .message.assistant,
body:not(.dark-mode) .message-content.assistant,
html:not(.dark-mode):not([data-theme="dark"]) .message-content.assistant,
body:not(.dark-mode) .artemis-message:not(.user),
html:not(.dark-mode):not([data-theme="dark"]) .artemis-message:not(.user),
body:not(.dark-mode) .artemis-message:not(.user) .artemis-message-text,
html:not(.dark-mode):not([data-theme="dark"]) .artemis-message:not(.user) .artemis-message-text {
  background-color: #f8f9fa !important; /* Light gray background */
  color: #202124 !important; /* Dark text for readability */
  border-left: 3px solid #9ED9F5 !important; /* Pale Blue accent */
}

/* Ensure all text within assistant messages is dark in light mode */
body:not(.dark-mode) .assistant-message *,
html:not(.dark-mode):not([data-theme="dark"]) .assistant-message *,
body:not(.dark-mode) .assistant-message p,
html:not(.dark-mode):not([data-theme="dark"]) .assistant-message p,
body:not(.dark-mode) .assistant-message strong,
html:not(.dark-mode):not([data-theme="dark"]) .assistant-message strong,
body:not(.dark-mode) .assistant-message em,
html:not(.dark-mode):not([data-theme="dark"]) .assistant-message em,
body:not(.dark-mode) .artemis-message:not(.user) *,
html:not(.dark-mode):not([data-theme="dark"]) .artemis-message:not(.user) *,
body:not(.dark-mode) .artemis-message-text p,
html:not(.dark-mode):not([data-theme="dark"]) .artemis-message-text p,
body:not(.dark-mode) .message-content p,
html:not(.dark-mode):not([data-theme="dark"]) .message-content p {
  color: #202124 !important; /* Dark text */
}

/* User Messages - Blue Background + White Text */
.dark-mode .user-message,
body.dark-mode .user-message,
html.dark-mode .user-message,
.dark-mode .message.user,
body.dark-mode .message.user,
.dark-mode .artemis-message.user,
body.dark-mode .artemis-message.user {
  background-color: #3b82f6 !important; /* Blue */
  color: #ffffff !important; /* White text */
}

.dark-mode .user-message *,
body.dark-mode .user-message *,
.dark-mode .artemis-message.user *,
body.dark-mode .artemis-message.user * {
  color: #ffffff !important;
}

/* Timestamp */
.dark-mode .message-timestamp,
body.dark-mode .message-timestamp,
.dark-mode .timestamp,
body.dark-mode .timestamp,
.dark-mode .artemis-message-time,
body.dark-mode .artemis-message-time {
  color: #cbd5e1 !important; /* Light gray for timestamps */
  opacity: 0.9 !important;
}

/* Input Area */
.dark-mode .artemis-input-container,
body.dark-mode .artemis-input-container,
html.dark-mode .artemis-input-container,
.dark-mode .chat-input-container,
body.dark-mode .chat-input-container {
  background-color: #1e293b !important;
  border-top: 1px solid #334155 !important;
}

.dark-mode .artemis-input-container textarea,
body.dark-mode .artemis-input-container textarea,
.dark-mode textarea[placeholder*="message"],
body.dark-mode textarea[placeholder*="message"],
.dark-mode .artemis-input-container input,
body.dark-mode .artemis-input-container input,
.dark-mode input[placeholder*="message"],
body.dark-mode input[placeholder*="message"] {
  background-color: #0f172a !important;
  color: #ffffff !important;
  border: 1px solid #334155 !important;
}

.dark-mode .artemis-input-container textarea::placeholder,
body.dark-mode .artemis-input-container textarea::placeholder,
.dark-mode .artemis-input-container input::placeholder,
body.dark-mode .artemis-input-container input::placeholder {
  color: #94a3b8 !important; /* Medium gray */
  opacity: 1;
}

.dark-mode .artemis-input-container textarea:focus,
body.dark-mode .artemis-input-container textarea:focus,
.dark-mode .artemis-input-container input:focus,
body.dark-mode .artemis-input-container input:focus {
  border-color: #60a5fa !important; /* Blue focus */
  outline: none;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2) !important;
}

/* Send Button in Dark Mode */
.dark-mode button[aria-label*="Send"],
body.dark-mode button[aria-label*="Send"],
.dark-mode .artemis-send-btn,
body.dark-mode .artemis-send-btn {
  background-color: #3b82f6 !important;
  color: #ffffff !important;
}

.dark-mode button[aria-label*="Send"]:hover,
body.dark-mode button[aria-label*="Send"]:hover,
.dark-mode .artemis-send-btn:hover,
body.dark-mode .artemis-send-btn:hover {
  background-color: #2563eb !important;
}

/* Export and Minimize Buttons */
.dark-mode .artemis-chat-header button,
body.dark-mode .artemis-chat-header button,
.dark-mode .chat-header button,
body.dark-mode .chat-header button {
  color: #ffffff !important;
  background-color: transparent !important;
}

.dark-mode .artemis-chat-header button:hover,
body.dark-mode .artemis-chat-header button:hover,
.dark-mode .chat-header button:hover,
body.dark-mode .chat-header button:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Online Status Indicator */
.dark-mode .status-indicator,
body.dark-mode .status-indicator {
  color: #86efac !important; /* Green */
}

/* Targeting Recommendations Panel in Dark Mode */
.dark-mode .artemis-targeting-recommendations,
body.dark-mode .artemis-targeting-recommendations,
.dark-mode .targeting-recommendations,
body.dark-mode .targeting-recommendations {
  background-color: #1e293b !important;
  border: 1px solid #334155 !important;
  color: #ffffff !important;
}

.dark-mode .artemis-targeting-recommendations h4,
body.dark-mode .artemis-targeting-recommendations h4,
.dark-mode .targeting-recommendations h4,
body.dark-mode .targeting-recommendations h4 {
  color: #ffffff !important;
}

.dark-mode .artemis-targeting-card,
body.dark-mode .artemis-targeting-card,
.dark-mode .recommendation-card,
body.dark-mode .recommendation-card {
  background-color: #0f172a !important;
  border: 1px solid #334155 !important;
  color: #ffffff !important;
}

.dark-mode .artemis-targeting-card *,
body.dark-mode .artemis-targeting-card *,
.dark-mode .recommendation-card *,
body.dark-mode .recommendation-card * {
  color: #ffffff !important;
}

/* ========================================================================
   END OF DARK MODE FIXES - October 30, 2025
   ======================================================================== */

/* ========================================================================
   L6/L7 SEGMENT ANALYSIS UI - November 8, 2025
   ======================================================================== */

/* Analysis Container */
.artemis-analysis-container {
    display: none;
    margin: 16px 0;
    animation: slideInDown 0.3s ease-out;
}

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

/* Analysis Panel */
.artemis-analysis-panel {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 20px;
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

/* Analysis Header */
.artemis-analysis-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    font-weight: 600;
}

.artemis-analysis-icon {
    font-size: 24px;
}

.artemis-analysis-title {
    flex: 1;
    font-size: 18px;
}

.artemis-analysis-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
}

/* Pattern Tags */
.artemis-pattern-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.artemis-pattern-tag {
    background: rgba(255, 255, 255, 0.25);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    text-transform: capitalize;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Narrowing Guidance */
.artemis-narrowing-guidance {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    backdrop-filter: blur(10px);
}

.artemis-narrowing-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    margin-bottom: 8px;
}

.artemis-current-count {
    color: #ffd700;
}

.artemis-arrow {
    font-size: 16px;
}

.artemis-target-count {
    color: #90ee90;
}

.artemis-narrowing-strategy {
    font-size: 13px;
    opacity: 0.9;
}

/* Probing Questions */
.artemis-probing-questions-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    opacity: 0.95;
}

.artemis-probing-questions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.artemis-probing-question {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 14px;
    color: #2d3748;
    transition: all 0.2s ease;
    cursor: pointer;
}

.artemis-probing-question:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.artemis-question-text {
    font-weight: 600;
    margin-bottom: 8px;
    color: #1a202c;
    font-size: 14px;
    line-height: 1.5;
}

.artemis-question-reasoning {
    font-size: 12px;
    color: #4a5568;
    margin-bottom: 12px;
    font-style: italic;
}

.artemis-question-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    width: 100%;
}

.artemis-question-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.artemis-question-btn:active {
    transform: scale(0.98);
}

/* Dark Mode Support */
.dark-mode .artemis-analysis-panel,
body.dark-mode .artemis-analysis-panel {
    background: linear-gradient(135deg, #4c51bf 0%, #553c9a 100%);
}

.dark-mode .artemis-probing-question,
body.dark-mode .artemis-probing-question {
    background: rgba(255, 255, 255, 0.9);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .artemis-analysis-panel {
        padding: 16px;
    }

    .artemis-analysis-header {
        font-size: 16px;
    }

    .artemis-pattern-tag {
        font-size: 12px;
        padding: 4px 10px;
    }

    .artemis-question-text {
        font-size: 13px;
    }

    .artemis-question-reasoning {
        font-size: 11px;
    }
}

/* ========================================================================
   END OF L6/L7 SEGMENT ANALYSIS UI
   ======================================================================== */
