/**
 * Chatbot Widget Styles for Omeka S
 *
 * Provides responsive, accessible chat interface for the public site.
 * Implements mobile-first design with floating widget on desktop and
 * fullscreen modal on mobile. All themeable values exposed as CSS custom
 * properties for easy customization.
 *
 * Accessibility: WCAG AA compliant with proper focus states, color contrast,
 * and reduced motion support.
 */

/* ==================== CSS Custom Properties (Theme Variables) ==================== */

:root {
    /* Primary Theme Colors */
    --chatbot-primary-color: #007bff;
    --chatbot-primary-hover: #0056b3;
    --chatbot-primary-active: #004085;
    --chatbot-secondary-color: #6c757d;
    --chatbot-secondary-hover: #5a6268;

    /* Background Colors */
    --chatbot-bg-primary: #ffffff;
    --chatbot-bg-secondary: #f8f9fa;
    --chatbot-bg-header: #007bff;
    --chatbot-bg-overlay: rgba(0, 0, 0, 0.5);

    /* Text Colors */
    --chatbot-text-primary: #333333;
    --chatbot-text-secondary: #666666;
    --chatbot-text-light: #ffffff;
    --chatbot-text-muted: #999999;

    /* Message Bubble Colors */
    --chatbot-message-user-bg: #007bff;
    --chatbot-message-user-text: #ffffff;
    --chatbot-message-bot-bg: #e9ecef;
    --chatbot-message-bot-text: #333333;

    /* Border Colors */
    --chatbot-border-color: #dee2e6;
    --chatbot-border-light: #e9ecef;
    --chatbot-border-focus: #80bdff;

    /* Status Colors */
    --chatbot-success-color: #28a745;
    --chatbot-warning-color: #ffc107;
    --chatbot-error-color: #dc3545;
    --chatbot-info-color: #17a2b8;

    /* Positioning (Closed State) */
    --chatbot-position-bottom: 20px;
    --chatbot-position-right: 20px;
    --chatbot-position-left: auto;

    /* Sizing (Desktop Floating Widget) */
    --chatbot-window-width: 350px;
    --chatbot-window-height: 500px;
    --chatbot-window-max-width: 90vw;
    --chatbot-window-max-height: 90vh;
    --chatbot-toggle-size: 56px;

    /* Header Sizing */
    --chatbot-header-height: 60px;
    --chatbot-header-padding: 16px;

    /* Input Zone Sizing */
    --chatbot-input-height: auto;
    --chatbot-input-min-height: 50px;
    --chatbot-input-max-height: 120px;
    --chatbot-input-padding: 12px;

    /* Spacing */
    --chatbot-spacing-xs: 4px;
    --chatbot-spacing-sm: 8px;
    --chatbot-spacing-md: 16px;
    --chatbot-spacing-lg: 24px;
    --chatbot-spacing-xl: 32px;

    /* Border Radius */
    --chatbot-radius-sm: 4px;
    --chatbot-radius-md: 8px;
    --chatbot-radius-lg: 12px;
    --chatbot-radius-full: 50%;

    /* Shadows */
    --chatbot-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --chatbot-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --chatbot-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --chatbot-shadow-focus: 0 0 0 3px rgba(0, 123, 255, 0.25);

    /* Typography */
    --chatbot-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --chatbot-font-size-xs: 0.75rem;
    --chatbot-font-size-sm: 0.875rem;
    --chatbot-font-size-base: 1rem;
    --chatbot-font-size-lg: 1.125rem;
    --chatbot-font-size-xl: 1.25rem;
    --chatbot-font-weight-normal: 400;
    --chatbot-font-weight-medium: 500;
    --chatbot-font-weight-semibold: 600;
    --chatbot-font-weight-bold: 700;
    --chatbot-line-height-tight: 1.25;
    --chatbot-line-height-normal: 1.5;
    --chatbot-line-height-relaxed: 1.75;

    /* Z-Index Layering */
    --chatbot-z-index-base: 1000;
    --chatbot-z-index-toggle: 1001;
    --chatbot-z-index-window: 1002;
    --chatbot-z-index-overlay: 999;

    /* Transitions */
    --chatbot-transition-fast: 150ms ease-in-out;
    --chatbot-transition-base: 200ms ease-in-out;
    --chatbot-transition-slow: 300ms ease-in-out;

    /* Animation Durations */
    --chatbot-animation-pulse: 2s;
    --chatbot-animation-slide: 300ms;

    /* Badge */
    --chatbot-badge-size: 18px;
    --chatbot-badge-bg: #dc3545;
    --chatbot-badge-text: #ffffff;

    /* Avatar */
    --chatbot-avatar-size: 32px;
    --chatbot-avatar-bg: #6c757d;
}

/* ==================== Base Widget Container ==================== */

.chatbot-widget {
    position: fixed;
    z-index: var(--chatbot-z-index-base);
    font-family: var(--chatbot-font-family);
    font-size: var(--chatbot-font-size-base);
    line-height: var(--chatbot-line-height-normal);
    color: var(--chatbot-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== Closed State (Toggle Button) ==================== */

.chatbot-toggle {
    position: fixed;
    bottom: var(--chatbot-position-bottom);
    right: var(--chatbot-position-right);
    left: var(--chatbot-position-left);
    width: var(--chatbot-toggle-size);
    height: var(--chatbot-toggle-size);
    background: var(--chatbot-primary-color);
    color: var(--chatbot-text-light);
    border: none;
    border-radius: var(--chatbot-radius-full);
    box-shadow: var(--chatbot-shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--chatbot-z-index-toggle);
    transition: transform var(--chatbot-transition-base),
                background-color var(--chatbot-transition-base),
                box-shadow var(--chatbot-transition-base);
}

.chatbot-toggle:hover {
    background: var(--chatbot-primary-hover);
    transform: scale(1.05);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

.chatbot-toggle:active {
    background: var(--chatbot-primary-active);
    transform: scale(0.98);
}

.chatbot-toggle:focus-visible {
    outline: none;
    box-shadow: var(--chatbot-shadow-lg), var(--chatbot-shadow-focus);
}

/* Pulse animation for toggle button */
@keyframes pulse {
    0%, 100% {
        box-shadow: var(--chatbot-shadow-lg), 0 0 0 0 rgba(0, 123, 255, 0.7);
    }
    50% {
        box-shadow: var(--chatbot-shadow-lg), 0 0 0 8px rgba(0, 123, 255, 0);
    }
}

.chatbot-toggle.has-notification {
    animation: pulse var(--chatbot-animation-pulse) infinite;
}

/* Toggle button icon */
.chatbot-toggle-icon {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

/* Notification badge */
.chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: var(--chatbot-badge-size);
    height: var(--chatbot-badge-size);
    padding: 0 var(--chatbot-spacing-xs);
    background: var(--chatbot-badge-bg);
    color: var(--chatbot-badge-text);
    font-size: var(--chatbot-font-size-xs);
    font-weight: var(--chatbot-font-weight-bold);
    line-height: var(--chatbot-badge-size);
    text-align: center;
    border-radius: var(--chatbot-radius-full);
    border: 2px solid var(--chatbot-bg-primary);
}

/* ==================== Open State (Chat Window) ==================== */

/* Mobile-first: fullscreen modal by default */
.chatbot-window {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--chatbot-bg-primary);
    z-index: var(--chatbot-z-index-window);
    display: grid;
    grid-template-rows: var(--chatbot-header-height) 1fr auto;
    grid-template-areas:
        "header"
        "messages"
        "input";
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--chatbot-transition-base),
                transform var(--chatbot-transition-base);
}

.chatbot-window[hidden] {
    display: none;
}

.chatbot-window:not([hidden]) {
    opacity: 1;
    transform: translateY(0);
}

/* Tablet and up: adaptive widget */
@media (min-width: 768px) {
    .chatbot-window {
        top: auto;
        left: auto;
        bottom: calc(var(--chatbot-position-bottom) + var(--chatbot-toggle-size) + 10px);
        right: var(--chatbot-position-right);
        width: var(--chatbot-window-width);
        height: var(--chatbot-window-height);
        max-width: var(--chatbot-window-max-width);
        max-height: var(--chatbot-window-max-height);
        border-radius: var(--chatbot-radius-lg);
        box-shadow: var(--chatbot-shadow-lg);
        transform: translateY(10px) scale(0.95);
    }

    .chatbot-window:not([hidden]) {
        transform: translateY(0) scale(1);
    }
}

/* Desktop: refined floating widget */
@media (min-width: 1024px) {
    .chatbot-window {
        width: 380px;
        height: 550px;
    }
}

/* Ultra-wide: maintain optimal width */
@media (min-width: 1440px) {
    .chatbot-window {
        width: 400px;
        height: 600px;
    }
}

/* ==================== Header Section ==================== */

.chatbot-header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--chatbot-header-padding);
    background: var(--chatbot-bg-header);
    color: var(--chatbot-text-light);
    border-bottom: 1px solid var(--chatbot-border-color);
}

@media (min-width: 768px) {
    .chatbot-header {
        border-top-left-radius: var(--chatbot-radius-lg);
        border-top-right-radius: var(--chatbot-radius-lg);
    }
}

.chatbot-header-title {
    font-size: var(--chatbot-font-size-lg);
    font-weight: var(--chatbot-font-weight-semibold);
    margin: 0;
    flex: 1;
}

.chatbot-header-actions {
    display: flex;
    gap: var(--chatbot-spacing-sm);
    align-items: center;
}

.chatbot-header-button {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--chatbot-text-light);
    cursor: pointer;
    border-radius: var(--chatbot-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--chatbot-transition-fast);
}

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

.chatbot-header-button:active {
    background: rgba(255, 255, 255, 0.2);
}

.chatbot-header-button:focus-visible {
    outline: 2px solid var(--chatbot-text-light);
    outline-offset: 2px;
}

.chatbot-header-button-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* ==================== Message Display Zone ==================== */

.chatbot-messages {
    grid-area: messages;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--chatbot-spacing-md);
    background: var(--chatbot-bg-secondary);
    display: flex;
    flex-direction: column;
    gap: var(--chatbot-spacing-md);
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--chatbot-border-color);
    border-radius: 3px;
    transition: background-color var(--chatbot-transition-fast);
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chatbot-secondary-color);
}

/* Message container */
.chatbot-message {
    display: flex;
    gap: var(--chatbot-spacing-sm);
    align-items: flex-end;
    max-width: 85%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chatbot-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-message.bot {
    align-self: flex-start;
}

/* Message avatar */
.chatbot-message-avatar {
    width: var(--chatbot-avatar-size);
    height: var(--chatbot-avatar-size);
    border-radius: var(--chatbot-radius-full);
    background: var(--chatbot-avatar-bg);
    color: var(--chatbot-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--chatbot-font-size-sm);
    font-weight: var(--chatbot-font-weight-medium);
    flex-shrink: 0;
}

.chatbot-message.user .chatbot-message-avatar {
    background: var(--chatbot-primary-color);
}

/* Message bubble */
.chatbot-message-bubble {
    padding: var(--chatbot-spacing-sm) var(--chatbot-spacing-md);
    border-radius: var(--chatbot-radius-md);
    font-size: var(--chatbot-font-size-base);
    line-height: var(--chatbot-line-height-normal);
}

.chatbot-message.user .chatbot-message-bubble {
    background: var(--chatbot-message-user-bg);
    color: var(--chatbot-message-user-text);
    border-bottom-right-radius: var(--chatbot-radius-sm);
}

.chatbot-message.bot .chatbot-message-bubble {
    background: var(--chatbot-message-bot-bg);
    color: var(--chatbot-message-bot-text);
    border-bottom-left-radius: var(--chatbot-radius-sm);
}

/* Message timestamp */
.chatbot-message-time {
    display: block;
    font-size: var(--chatbot-font-size-xs);
    color: var(--chatbot-text-muted);
    margin-top: var(--chatbot-spacing-xs);
    opacity: 0.8;
}

/* Typing indicator */
.chatbot-typing-indicator {
    display: flex;
    gap: var(--chatbot-spacing-xs);
    padding: var(--chatbot-spacing-sm) var(--chatbot-spacing-md);
    background: var(--chatbot-message-bot-bg);
    border-radius: var(--chatbot-radius-md);
    width: fit-content;
}

.chatbot-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--chatbot-text-secondary);
    border-radius: var(--chatbot-radius-full);
    animation: typing 1.4s infinite ease-in-out;
}

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

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

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

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

/* ==================== Input Zone ==================== */

.chatbot-input-zone {
    grid-area: input;
    padding: var(--chatbot-input-padding);
    background: var(--chatbot-bg-primary);
    border-top: 1px solid var(--chatbot-border-color);
    display: flex;
    flex-direction: column;
    gap: var(--chatbot-spacing-sm);
}

@media (min-width: 768px) {
    .chatbot-input-zone {
        border-bottom-left-radius: var(--chatbot-radius-lg);
        border-bottom-right-radius: var(--chatbot-radius-lg);
    }
}

/* Input container */
.chatbot-input-container {
    display: flex;
    gap: var(--chatbot-spacing-sm);
    align-items: flex-end;
}

/* Textarea */
.chatbot-input-textarea {
    flex: 1;
    min-height: var(--chatbot-input-min-height);
    max-height: var(--chatbot-input-max-height);
    padding: var(--chatbot-spacing-sm) var(--chatbot-spacing-md);
    font-family: var(--chatbot-font-family);
    font-size: var(--chatbot-font-size-base);
    line-height: var(--chatbot-line-height-normal);
    color: var(--chatbot-text-primary);
    background: var(--chatbot-bg-secondary);
    border: 1px solid var(--chatbot-border-color);
    border-radius: var(--chatbot-radius-md);
    resize: none;
    overflow-y: auto;
    transition: border-color var(--chatbot-transition-fast),
                box-shadow var(--chatbot-transition-fast);
}

.chatbot-input-textarea:hover {
    border-color: var(--chatbot-secondary-color);
}

.chatbot-input-textarea:focus {
    outline: none;
    border-color: var(--chatbot-primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.chatbot-input-textarea::placeholder {
    color: var(--chatbot-text-muted);
}

/* Send button */
.chatbot-send-button {
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--chatbot-primary-color);
    color: var(--chatbot-text-light);
    border: none;
    border-radius: var(--chatbot-radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color var(--chatbot-transition-fast),
                transform var(--chatbot-transition-fast);
}

.chatbot-send-button:hover:not(:disabled) {
    background: var(--chatbot-primary-hover);
    transform: scale(1.05);
}

.chatbot-send-button:active:not(:disabled) {
    background: var(--chatbot-primary-active);
    transform: scale(0.98);
}

.chatbot-send-button:disabled {
    background: var(--chatbot-secondary-color);
    opacity: 0.5;
    cursor: not-allowed;
}

.chatbot-send-button:focus-visible {
    outline: none;
    box-shadow: var(--chatbot-shadow-focus);
}

.chatbot-send-button-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Quick reply buttons */
.chatbot-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: var(--chatbot-spacing-sm);
}

.chatbot-quick-reply-button {
    padding: var(--chatbot-spacing-sm) var(--chatbot-spacing-md);
    background: var(--chatbot-bg-secondary);
    color: var(--chatbot-text-primary);
    border: 1px solid var(--chatbot-border-color);
    border-radius: var(--chatbot-radius-full);
    font-size: var(--chatbot-font-size-sm);
    font-weight: var(--chatbot-font-weight-medium);
    cursor: pointer;
    transition: background-color var(--chatbot-transition-fast),
                border-color var(--chatbot-transition-fast),
                transform var(--chatbot-transition-fast);
    white-space: nowrap;
}

.chatbot-quick-reply-button:hover {
    background: var(--chatbot-primary-color);
    color: var(--chatbot-text-light);
    border-color: var(--chatbot-primary-color);
}

.chatbot-quick-reply-button:active {
    transform: scale(0.98);
}

.chatbot-quick-reply-button:focus-visible {
    outline: 2px solid var(--chatbot-primary-color);
    outline-offset: 2px;
}

/* Collection item links */
.chatbot-collection-links {
    display: flex;
    flex-direction: column;
    gap: var(--chatbot-spacing-sm);
    margin-top: var(--chatbot-spacing-sm);
}

.chatbot-collection-link {
    display: inline-block;
    padding: var(--chatbot-spacing-sm) var(--chatbot-spacing-md);
    background: var(--chatbot-bg-primary);
    color: var(--chatbot-primary-color);
    border: 1px solid var(--chatbot-primary-color);
    border-radius: var(--chatbot-radius-sm);
    font-size: var(--chatbot-font-size-sm);
    font-weight: var(--chatbot-font-weight-medium);
    text-decoration: none;
    transition: background-color var(--chatbot-transition-fast),
                color var(--chatbot-transition-fast),
                transform var(--chatbot-transition-fast);
}

.chatbot-collection-link:hover {
    background: var(--chatbot-primary-color);
    color: var(--chatbot-text-light);
    text-decoration: none;
}

.chatbot-collection-link:active {
    transform: scale(0.98);
}

.chatbot-collection-link:focus-visible {
    outline: 2px solid var(--chatbot-primary-color);
    outline-offset: 2px;
}

/* ==================== Responsive Breakpoints (Mobile-First) ==================== */

/* Small Mobile (320px and up) - Base adjustments for very small screens */
@media (min-width: 320px) {
    .chatbot-message {
        max-width: 90%;
    }

    .chatbot-toggle {
        width: 52px;
        height: 52px;
    }

    .chatbot-input-textarea {
        font-size: var(--chatbot-font-size-base);
    }

    .chatbot-header-title {
        font-size: var(--chatbot-font-size-base);
    }
}

/* Tablet (768px and up) - Adaptive widget begins */
@media (min-width: 768px) {
    .chatbot-message {
        max-width: 80%;
    }

    .chatbot-toggle {
        width: var(--chatbot-toggle-size);
        height: var(--chatbot-toggle-size);
    }

    .chatbot-header-title {
        font-size: var(--chatbot-font-size-lg);
    }

    .chatbot-messages {
        padding: var(--chatbot-spacing-lg);
    }

    .chatbot-input-zone {
        padding: var(--chatbot-spacing-md);
    }
}

/* Desktop (1024px and up) - Refined floating widget */
@media (min-width: 1024px) {
    .chatbot-message {
        max-width: 75%;
    }

    .chatbot-message-bubble {
        padding: var(--chatbot-spacing-md) var(--chatbot-spacing-lg);
    }

    .chatbot-quick-replies {
        gap: var(--chatbot-spacing-md);
    }
}

/* Large Desktop (1440px and up) - Enhanced spacing and sizing */
@media (min-width: 1440px) {
    .chatbot-messages {
        gap: var(--chatbot-spacing-lg);
    }

    .chatbot-input-container {
        gap: var(--chatbot-spacing-md);
    }

    .chatbot-send-button {
        width: 48px;
        height: 48px;
    }
}

/* Ultra-Wide (2560px and up) - Optimal viewing on large displays */
@media (min-width: 2560px) {
    .chatbot-window {
        width: 420px;
        height: 650px;
    }

    .chatbot-message {
        max-width: 70%;
    }

    .chatbot-header-title {
        font-size: var(--chatbot-font-size-xl);
    }

    .chatbot-avatar-size {
        width: 36px;
        height: 36px;
    }
}

/* ==================== Accessibility & Motion Preferences ==================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .chatbot-toggle,
    .chatbot-send-button,
    .chatbot-header-button {
        border: 2px solid currentColor;
    }

    .chatbot-window {
        border: 2px solid var(--chatbot-text-primary);
    }

    .chatbot-message-bubble {
        border: 1px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .chatbot-toggle.has-notification {
        animation: none;
    }
}

/* Focus visible polyfill for older browsers */
.chatbot-toggle:focus:not(:focus-visible) {
    box-shadow: var(--chatbot-shadow-lg);
}

/* ==================== Focus States & Keyboard Navigation ==================== */

/* Enhanced focus indicators for all interactive elements */
.chatbot-input-textarea:focus-visible {
    outline: 2px solid var(--chatbot-primary-color);
    outline-offset: 2px;
    border-color: var(--chatbot-primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Message links within bubbles */
.chatbot-message-bubble a {
    color: inherit;
    text-decoration: underline;
    transition: opacity var(--chatbot-transition-fast);
}

.chatbot-message-bubble a:hover {
    opacity: 0.8;
}

.chatbot-message-bubble a:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    border-radius: var(--chatbot-radius-sm);
}

/* Chat window focus management */
.chatbot-window:focus {
    outline: none;
}

.chatbot-window:focus-visible {
    box-shadow: var(--chatbot-shadow-lg), 0 0 0 4px var(--chatbot-border-focus);
}

/* Keyboard navigation visual feedback */
.chatbot-header-button:focus-visible,
.chatbot-quick-reply-button:focus-visible {
    outline-width: 2px;
    outline-style: solid;
}

/* Enhanced toggle button focus for keyboard users */
.chatbot-toggle:focus-visible {
    outline: none;
    box-shadow: var(--chatbot-shadow-lg),
                var(--chatbot-shadow-focus),
                0 0 0 4px rgba(0, 123, 255, 0.15);
}

/* Ensure disabled elements don't show focus */
.chatbot-send-button:disabled:focus-visible,
.chatbot-header-button:disabled:focus-visible {
    outline: none;
    box-shadow: none;
}

/* Focus trap indicator for modal state on mobile */
@media (max-width: 767px) {
    .chatbot-window:not([hidden])::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 2px;
        background: var(--chatbot-primary-color);
        z-index: 1;
        opacity: 0;
        transition: opacity var(--chatbot-transition-base);
    }

    .chatbot-window:focus-within::before {
        opacity: 1;
    }
}

/* Skip link for keyboard navigation (if implemented in JS) */
.chatbot-skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--chatbot-primary-color);
    color: var(--chatbot-text-light);
    padding: var(--chatbot-spacing-sm) var(--chatbot-spacing-md);
    text-decoration: none;
    border-radius: var(--chatbot-radius-sm);
    z-index: calc(var(--chatbot-z-index-window) + 1);
    transition: top var(--chatbot-transition-fast);
}

.chatbot-skip-link:focus-visible {
    top: var(--chatbot-spacing-sm);
    outline: 2px solid var(--chatbot-text-light);
    outline-offset: 2px;
}

/* Visible focus indicator for messages area when tabbing through */
.chatbot-messages:focus-visible {
    outline: 2px solid var(--chatbot-primary-color);
    outline-offset: -2px;
}

/* ==================== Utility Classes ==================== */

.chatbot-hidden {
    display: none !important;
}

.chatbot-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;
}

/* ==================== Print Styles ==================== */

@media print {
    .chatbot-widget,
    .chatbot-toggle,
    .chatbot-window {
        display: none !important;
    }
}
