/**
 * Accessibility Fixes for RI Plugin
 * Hour 5 Accessibility Check - Fixing WCAG AA violations
 */

/* ============================================================================
   1. IMPROVED FOCUS INDICATORS
   ============================================================================ */

/* Ensure all interactive elements have visible focus */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid #2563eb !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.3) !important;
}

/* Action buttons focus */
.multimodal-ai-action-button:focus-visible,
.multimodal-ai-control-button:focus-visible,
.multimodal-ai-squircle-button:focus-visible {
    outline: 3px solid #000000 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.3) !important;
    transform: scale(1.05) !important;
}

/* ============================================================================
   2. COLOR CONTRAST IMPROVEMENTS
   ============================================================================ */

/* Improve contrast on action buttons (teal to darker color) */
.multimodal-ai-action-button {
    background: var(--button-bg) !important;
    color: var(--button-text) !important;
}

.multimodal-ai-action-button:hover {
    background: var(--button-hover) !important;
}

/* Ensure icon colors have sufficient contrast */
.multimodal-ai-action-button svg {
    stroke: currentColor !important;
    color: currentColor !important;
}

/* Fix "Dismiss" and other light text buttons */
.multimodal-ai-gallery-close,
.multimodal-ai-player-close,
.ri-unified-modal-close {
    color: #dc2626 !important; /* Darker red for contrast */
    font-weight: 600 !important;
}

.multimodal-ai-gallery-close:hover,
.multimodal-ai-player-close:hover,
.ri-unified-modal-close:hover {
    color: #b91c1c !important;
}

/* ============================================================================
   3. PLACEHOLDER TEXT
   ============================================================================ */

/* Add visible placeholder to input field */
#multimodal-ai-user-input::placeholder {
    color: var(--text-secondary) !important;
}

/* Ensure hint text is visible when focused */
#multimodal-ai-input-hint:not(.visually-hidden) {
    color: var(--text-secondary) !important;
    font-size: 14px !important;
    margin-bottom: 4px !important;
}

/* ============================================================================
   4. BETTER BUTTON STYLES
   ============================================================================ */

/* Ensure all buttons have proper hover and active states */
button:active {
    transform: scale(0.98) !important;
}

/* Improve button visibility */
.multimodal-ai-control-button {
    background: rgba(0, 0, 0, 0.05) !important;
    border-radius: 8px !important;
    padding: 8px !important;
}

.multimodal-ai-control-button:hover {
    background: rgba(0, 0, 0, 0.1) !important;
}

/* ============================================================================
   5. INPUT FIELD STYLING
   ============================================================================ */

/* Make sure input field has visible border */
#multimodal-ai-user-input {
    border: 1px solid var(--input-border) !important;
    color: var(--message-ai-text) !important;
    min-height: 48px !important; /* WCAG touch target minimum */
}

#multimodal-ai-user-input:focus {
    border-color: var(--input-focus) !important;
    border-width: 2px !important;
}

/* ============================================================================
   6. LINK AND TEXT CONTRAST
   ============================================================================ */

/* Improve link contrast */
.multimodal-ai-gallery-btn,
.multimodal-ai-conversations-btn,
.multimodal-ai-new-chat-btn {
    color: #0369a1 !important; /* Darker blue */
    font-weight: 500 !important;
}

.multimodal-ai-gallery-btn:hover,
.multimodal-ai-conversations-btn:hover,
.multimodal-ai-new-chat-btn:hover {
    color: #0c4a6e !important;
    text-decoration: underline !important;
}

/* ============================================================================
   7. MODAL AND DIALOG IMPROVEMENTS
   ============================================================================ */

/* Ensure modal close buttons are clearly visible */
.ri-unified-modal-close {
    width: 32px !important;
    height: 32px !important;
    font-size: 24px !important;
    background: rgba(0, 0, 0, 0.05) !important;
    border-radius: 4px !important;
}

.ri-unified-modal-close:hover {
    background: rgba(0, 0, 0, 0.1) !important;
}

/* ============================================================================
   8. SCREEN READER SUPPORT
   ============================================================================ */

/* Ensure visually-hidden content is actually hidden visually but available to screen readers */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ============================================================================
   9. TOAST NOTIFICATIONS
   ============================================================================ */

/* Make toast notifications more visible */
.ri-toast {
    background: #1f2937 !important;
    color: #ffffff !important;
    border: 2px solid #374151 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.ri-toast-success {
    background: #065f46 !important;
    border-color: #047857 !important;
}

.ri-toast-error {
    background: #7f1d1d !important;
    border-color: #991b1b !important;
}

.ri-toast-warning {
    background: #78350f !important;
    border-color: #92400e !important;
}

/* ============================================================================
   10. LOADING INDICATORS
   ============================================================================ */

/* Make loading indicators more visible */
.ri-loading-spinner {
    border: 3px solid rgba(0, 0, 0, 0.1) !important;
    border-top: 3px solid #2563eb !important;
}

/* ============================================================================
   11. RESPONSIVE ACCESSIBILITY
   ============================================================================ */

/* Ensure touch targets are large enough on mobile */
@media (max-width: 768px) {
    .multimodal-ai-action-button {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        min-height: 48px !important;
    }
    
    .multimodal-ai-squircle-button {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        min-height: 48px !important;
    }
    
    /* Make buttons easier to tap */
    button[aria-label],
    [role="button"] {
        min-width: 44px !important;
        min-height: 44px !important;
    }
}

/* ============================================================================
   12. HIGH CONTRAST MODE SUPPORT
   ============================================================================ */

@media (prefers-contrast: high) {
    .multimodal-ai-action-button {
        background: #000000 !important;
        color: #ffffff !important;
        border: 2px solid #ffffff !important;
    }
    
    .multimodal-ai-action-button:hover {
        background: #ffffff !important;
        color: #000000 !important;
    }
    
    input:focus,
    textarea:focus,
    button:focus {
        outline: 4px solid #000000 !important;
        outline-offset: 2px !important;
    }
}
