/* 
 * WLIQ Chatbot - Accessibility Enhancements
 * 
 * Additional CSS to improve accessibility and fix console warnings
 */

/* ===============================================
   Focus Management
   =============================================== */

/* Ensure proper focus visibility */
#chatgpt-open-btn:focus,
#chatgpt-open-btn:focus-visible {
    outline: 3px solid #000;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* Remove conflicting aria-hidden styles */
#chatgpt-open-btn[aria-hidden="true"] {
    aria-hidden: false !important;
}

/* Ensure buttons are keyboard accessible */
#chatbot-chatgpt-buttons-container button:focus {
    outline: 2px solid #000;
    outline-offset: 2px;
}

/* ===============================================
   Screen Reader Support
   =============================================== */

/* Hidden but accessible to screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Add screen reader text for icon buttons */
#chatbot-chatgpt-submit::before {
    content: "Send message";
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

#chatbot-chatgpt-erase-btn::before {
    content: "Clear conversation";
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

/* ===============================================
   High Contrast Mode Support
   =============================================== */

@media (prefers-contrast: high) {
    #chatbot-chatgpt {
        border: 2px solid currentColor;
    }
    
    #chatgpt-open-btn {
        border: 2px solid currentColor;
    }
    
    .chatbot-user-text,
    .chatbot-bot-text {
        border: 2px solid currentColor;
    }
    
    #chatbot-chatgpt-message {
        border: 2px solid currentColor;
    }
}

/* ===============================================
   Motion Preferences
   =============================================== */

@media (prefers-reduced-motion: reduce) {
    /* Disable animations for users who prefer reduced motion */
    #chatbot-chatgpt,
    #chatgpt-open-btn,
    .chat-message,
    #chatbot-chatgpt-header,
    .chatbot-typing-dot,
    .chatbot-loading-dot {
        animation: none !important;
        transition: none !important;
    }
    
    /* Instant transitions for essential interactions */
    #chatgpt-open-btn:hover,
    #chatbot-chatgpt-buttons-container button:hover {
        transition: outline 0.1s ease !important;
    }
}

/* ===============================================
   Keyboard Navigation Improvements
   =============================================== */

/* Visible focus for tab navigation */
/* #chatbot-chatgpt *:focus {
    outline: 2px solid var(--chat-accent-color, #667eea);
    outline-offset: 2px;
} */

/* Skip link for keyboard users */
.chatbot-skip-link {
    position: absolute;
    left: -9999px;
    z-index: 999;
}

.chatbot-skip-link:focus {
    position: fixed;
    left: 6px;
    top: 6px;
    z-index: 999;
    padding: 8px 16px;
    background: var(--chat-accent-color, #667eea);
    color: white;
    text-decoration: none;
    border-radius: 4px;
}

/* ===============================================
   Touch Target Sizes
   =============================================== */

/* Ensure minimum touch target size of 44x44px for accessibility */
#chatbot-chatgpt-buttons-container button,
#chatgpt-open-btn {
    min-width: 44px;
    min-height: 44px;
}

/* ===============================================
   Color Contrast Improvements
   =============================================== */

/* Ensure sufficient contrast ratios */
.chatbot-user-text {
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.error-message {
    background: #dc3545;
    color: #ffffff;
    border-color: #dc3545;
}

/* ===============================================
   Loading States
   =============================================== */

/* Accessible loading indicator */
.chatbot-loading[aria-live="polite"]::before {
    content: "Loading message...";
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

/* ===============================================
   Form Labels
   =============================================== */

/* Ensure form elements have proper labels */
#chatbot-chatgpt-message {
    /* Associated label is already present but hidden */
}

/* Make placeholder text more visible */
#chatbot-chatgpt-message::placeholder {
    opacity: 0.7;
    color: var(--chat-text-secondary, #4a5568);
}

/* ===============================================
   Error Messaging
   =============================================== */

/* Make errors more noticeable for accessibility */
.error-message[role="alert"] {
    font-weight: 600;
    padding: 16px 20px;
}

/* ===============================================
   ARIA Live Regions
   =============================================== */

/* Style for screen reader announcements */
[aria-live="polite"],
[aria-live="assertive"] {
    position: relative;
}

/* ===============================================
   Semantic HTML Enhancements
   =============================================== */

/* Ensure proper heading hierarchy */
#chatbot-chatgpt-title {
    font-size: 1.125rem;
    font-weight: 600;
}

/* ===============================================
   Message Display Fixes
   =============================================== */

/* Ensure messages are always visible */
.chat-message {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Prevent message hiding */
.chat-message.user-message,
.chat-message.bot-message {
    display: block !important;
    visibility: visible !important;
}

/* Ensure conversation container is visible */
#chatbot-chatgpt-conversation {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Prevent duplicate typing indicators */
.chatbot-typing-indicator + .chatbot-typing-indicator {
    display: none !important;
}

/* Ensure typing indicator is properly styled */
.chatbot-typing-indicator {
    display: inline-flex !important;
    align-items: center !important;
}

/* ===============================================
   Focus Trap Management
   =============================================== */

/* When chatbot is open, trap focus within */
#chatbot-chatgpt.chatbot-wide:focus-within,
#chatbot-chatgpt.chatbot-narrow:focus-within,
#chatbot-chatgpt.chatbot-full:focus-within {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

