/**
 * DigiMarkt AI Chatbot Styles
 * Accessible design with WCAG 2.1 compliance features
 */

:root {
    --chatbot-primary: #4f46e5;
    --chatbot-primary-dark: #4338ca;
    --chatbot-secondary: #8b5cf6;
    --chatbot-success: #10b981;
    --chatbot-error: #ef4444;
    --chatbot-text-light: #f9fafb;
    --chatbot-text-dark: #111827;
    --chatbot-gray-100: #f3f4f6;
    --chatbot-gray-200: #e5e7eb;
    --chatbot-gray-300: #d1d5db;
    --chatbot-gray-400: #9ca3af;
    --chatbot-gray-500: #6b7280;
    --chatbot-gray-600: #4b5563;
    --chatbot-gray-700: #374151;
    --chatbot-gray-800: #1f2937;
    --chatbot-gray-900: #111827;
    --chatbot-border-radius: 16px;
    --chatbot-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --chatbot-font-size: 16px;
    --chatbot-z-index: 9999;
}

/* Visually hidden elements for 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-width: 0;
}

/* Base container */
.chatbot-container {
    position: fixed;
    font-size: var(--chatbot-font-size);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    z-index: var(--chatbot-z-index);
    box-sizing: border-box;
}

.chatbot-container *,
.chatbot-container *:before,
.chatbot-container *:after {
    box-sizing: inherit;
}

/* Positioning variants */
.chatbot-bottom-right {
    right: 20px;
    bottom: 20px;
}

.chatbot-bottom-left {
    left: 20px;
    bottom: 20px;
}

/* Toggle button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--chatbot-primary);
    color: var(--chatbot-text-light);
    border: none;
    box-shadow: var(--chatbot-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background-color 0.3s ease;
    outline: none;
}

.chatbot-toggle:hover {
    transform: scale(1.05);
    background-color: var(--chatbot-primary-dark);
}

.chatbot-toggle:focus {
    outline: 3px solid var(--chatbot-secondary);
    outline-offset: 2px;
}

/* Main chat interface */
.chatbot-interface {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background-color: white;
    border-radius: var(--chatbot-border-radius);
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.8);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.chatbot-interface.chatbot-open {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
    color: var(--chatbot-text-light);
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: var(--chatbot-border-radius);
    border-top-right-radius: var(--chatbot-border-radius);
}

.chatbot-title {
    font-weight: 600;
    font-size: 1.1em;
}

.chatbot-close {
    background: none;
    border: none;
    color: var(--chatbot-text-light);
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.chatbot-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.chatbot-close:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Messages area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.chatbot-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    margin-bottom: 5px;
    position: relative;
    word-wrap: break-word;
}

.chatbot-message-user {
    background-color: var(--chatbot-gray-100);
    color: var(--chatbot-gray-900);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chatbot-message-bot {
    background-color: var(--chatbot-primary);
    color: var(--chatbot-text-light);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chatbot-message-error {
    background-color: var(--chatbot-error);
}

.chatbot-message-time {
    font-size: 0.7em;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

/* Loading animation */
.chatbot-message-loading {
    background-color: var(--chatbot-gray-200);
    padding: 12px;
    min-width: 60px;
}

.chatbot-loading-dots {
    display: flex;
    gap: 5px;
}

.chatbot-loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--chatbot-gray-500);
    animation: dot-pulse 1.5s infinite ease-in-out;
}

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

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

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

@keyframes dot-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Input area */
.chatbot-input-area {
    padding: 12px 16px;
    background-color: white;
    border-top: 1px solid var(--chatbot-gray-200);
    display: flex;
    align-items: end;
    gap: 10px;
}

.chatbot-input {
    flex: 1;
    border: 1px solid var(--chatbot-gray-300);
    border-radius: 20px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: inherit;
    resize: none;
    max-height: 120px;
    outline: none;
    transition: border-color 0.3s ease;
}

.chatbot-input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.chatbot-send {
    background-color: var(--chatbot-primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.chatbot-send:hover {
    background-color: var(--chatbot-primary-dark);
}

.chatbot-send:focus {
    outline: 3px solid rgba(79, 70, 229, 0.4);
    outline-offset: 2px;
}

.chatbot-send svg {
    width: 18px;
    height: 18px;
}

/* Accessibility controls */
.chatbot-accessibility-controls {
    display: flex;
    padding: 10px;
    background-color: var(--chatbot-gray-100);
    justify-content: center;
    gap: 8px;
    border-top: 1px solid var(--chatbot-gray-200);
}

.chatbot-accessibility-btn {
    background-color: white;
    border: 1px solid var(--chatbot-gray-300);
    border-radius: 4px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chatbot-accessibility-btn:hover {
    background-color: var(--chatbot-gray-200);
}

.chatbot-accessibility-btn:focus {
    outline: 2px solid var(--chatbot-primary);
    outline-offset: 1px;
}

.chatbot-accessibility-btn svg {
    width: 16px;
    height: 16px;
}

/* High contrast mode */
.chatbot-high-contrast {
    --chatbot-primary: #000000;
    --chatbot-primary-dark: #333333;
    --chatbot-secondary: #000000;
    --chatbot-gray-100: #f3f3f3;
    --chatbot-gray-200: #e0e0e0;
    --chatbot-text-light: #ffffff;
    --chatbot-text-dark: #000000;
}

.chatbot-high-contrast .chatbot-header {
    background: #000000;
}

.chatbot-high-contrast .chatbot-message-bot {
    background-color: #000000;
    color: #ffffff;
    border: 1px solid #ffffff;
}

.chatbot-high-contrast .chatbot-message-user {
    background-color: #ffffff;
    color: #000000;
    border: 1px solid #000000;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .chatbot-interface {
        width: calc(100vw - 40px);
        height: 60vh;
        right: 20px;
        left: 20px;
        bottom: 80px;
        transform-origin: bottom center;
    }
    
    .chatbot-bottom-right,
    .chatbot-bottom-left {
        right: 20px;
        left: auto;
    }
}

/* Focus visible polyfill */
.js-focus-visible :focus:not(.focus-visible) {
    outline: none;
}

.js-focus-visible .focus-visible {
    outline: 3px solid var(--chatbot-primary);
    outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .chatbot-toggle,
    .chatbot-interface,
    .chatbot-input,
    .chatbot-send,
    .chatbot-close {
        transition: none;
    }
    
    .chatbot-loading-dot {
        animation: none;
        opacity: 0.8;
    }
}
