/**
 * ═══════════════════════════════════════════════════════════════════════════
 * 🎨 MYSTERYERLEBNIS SMART CHATBOT - Premium UI/UX
 * 
 * Enterprise-Design passend zur MysteryErlebnis Corporate Identity
 * - Primary Color: #610000 (Burgundy)
 * - Secondary: White, Light Grays
 * - Typography: Inter (modern, readable)
 * - Animations: Smooth, professional
 * - Mobile-First: Responsive für alle Geräte
 * ═══════════════════════════════════════════════════════════════════════════
 */

/* ═══ CSS VARIABLES (Modern Premium Colors) ═══ */
:root {
    --me-primary: #610000;
    --me-primary-dark: #4a0000;
    --me-primary-light: #8b0000;
    --me-primary-soft: #f8e4e4;
    --me-accent: #d4af37; /* Elegantes Gold */
    --me-white: #ffffff;
    --me-gray-50: #fafafa;
    --me-gray-100: #f5f5f5;
    --me-gray-200: #e5e7eb;
    --me-gray-300: #d1d5db;
    --me-gray-500: #6b7280;
    --me-gray-700: #374151;
    --me-gray-900: #111827;
    
    /* Chat-specific colors */
    --me-chat-bg: var(--me-white);
    --me-chat-border: rgba(97, 0, 0, 0.08);
    --me-message-user: var(--me-primary);
    --me-message-bot: #fafafa;
    
    /* Shadows & Effects */
    --me-shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.15), 0 10px 30px rgba(97, 0, 0, 0.1);
    --me-shadow-md: 0 8px 32px rgba(97, 0, 0, 0.2), 0 4px 16px rgba(0, 0, 0, 0.1);
    --me-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    
    /* Timing */
    --me-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --me-transition-fast: all 0.15s ease;
}

/* ═══ CHATBOT CONTAINER ═══ */
.me-chatbot {
    position: fixed;
    bottom: 40px;
    right: 40px;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

body.menu-open .me-chatbot {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 250ms ease;
}

/* ═══ FLOATING ACTION BUTTON ═══ */
.me-chat-fab {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--me-primary) 0%, var(--me-primary-light) 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--me-shadow-md);
    transition: var(--me-transition);
    position: relative;
    animation: me-fab-pulse 3s ease-in-out infinite;
}

@keyframes me-fab-pulse {
    0%, 100% { 
        box-shadow: var(--me-shadow-md); 
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 20px 40px rgba(97, 0, 0, 0.3), 0 8px 20px rgba(0, 0, 0, 0.15);
        transform: scale(1.02);
    }
}

.me-chat-fab:hover {
    animation-play-state: paused;
    transform: scale(1.05);
    box-shadow: 0 12px 30px rgba(97, 0, 0, 0.4);
}

.me-chat-fab:active {
    transform: scale(0.95);
    transition: var(--me-transition-fast);
}

/* FAB Icons */
.me-chat-icon, .me-chat-close {
    position: absolute;
    color: var(--me-white);
    transition: opacity 0.3s ease;
    width: 24px;
    height: 24px;
}

.me-chat-icon {
    opacity: 1;
}

.me-chat-close {
    opacity: 0;
}

.me-chat-fab.active .me-chat-icon {
    opacity: 0;
}

.me-chat-fab.active .me-chat-close {
    opacity: 1;
}

/* Notification Badge */
.me-chat-notification {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: var(--me-white);
    border: 2px solid var(--me-white);
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: me-badge-pulse 2s ease-in-out infinite;
}

@keyframes me-badge-pulse {
    0%, 100% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* ═══ CHAT WINDOW ═══ */
.me-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    height: 600px;
    background: var(--me-chat-bg);
    border-radius: 16px;
    box-shadow: var(--me-shadow-lg);
    border: 1px solid var(--me-chat-border);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: var(--me-transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.me-chat-window.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ═══ CHAT HEADER ═══ */
.me-chat-header {
    background: linear-gradient(135deg, var(--me-primary) 0%, var(--me-primary-light) 100%);
    color: var(--me-white);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    border-radius: 16px 16px 0 0;
}

.me-chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="8" height="8" patternUnits="userSpaceOnUse"><path d="M 8 0 L 0 0 0 8" fill="none" stroke="rgba(255,255,255,0.08)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>') repeat;
    opacity: 1;
}

.me-chat-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.85) 100%);
    border: 2px solid rgba(212, 175, 55, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.5px;
    color: var(--me-primary);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.me-chat-info {
    flex: 1;
    position: relative;
    z-index: 1;
}

.me-chat-title {
    font-weight: 600;
    font-size: 16px;
    margin: 0 0 4px 0;
    color: var(--me-white);
}

.me-chat-subtitle {
    font-size: 13px;
    opacity: 0.9;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--me-white);
}

.me-status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: me-pulse 2s infinite;
}

@keyframes me-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

.me-chat-minimize {
    background: none;
    border: none;
    color: var(--me-white);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--me-transition-fast);
    position: relative;
    z-index: 1;
}

.me-chat-minimize:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ═══ MESSAGES AREA ═══ */
.me-chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--me-gray-50);
    scrollbar-width: thin;
    scrollbar-color: rgba(97, 0, 0, 0.2) transparent;
}

.me-chat-messages.typing-active {
    padding-bottom: 52px;
}

.me-chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

.me-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(97, 0, 0, 0.2);
    border-radius: 2px;
}

.me-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(97, 0, 0, 0.3);
}

/* ═══ MESSAGE STYLES ═══ */
.me-message {
    display: flex;
    gap: 12px;
    animation: me-slideInUp 0.3s ease-out;
    max-width: 100%;
}

@keyframes me-slideInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.me-message.user {
    flex-direction: row-reverse;
}

.me-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    margin-top: 2px;
}

.me-message.bot .me-message-avatar {
    background: linear-gradient(135deg, var(--me-primary), var(--me-primary-light));
    color: var(--me-white);
    border: 2px solid rgba(212, 175, 55, 0.2);
    box-shadow: 0 2px 8px rgba(97, 0, 0, 0.15);
}

.me-message.user .me-message-avatar {
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    color: var(--me-gray-700);
    border: 2px solid var(--me-gray-200);
}

.me-message-content {
    max-width: 280px;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.me-message.bot .me-message-content {
    background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
    color: var(--me-gray-700);
    border: 1px solid rgba(97, 0, 0, 0.06);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.me-message.user .me-message-content {
    background: var(--me-primary);
    color: var(--me-white);
    border-bottom-right-radius: 6px;
    box-shadow: var(--me-shadow-sm);
}

.me-message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 6px;
    text-align: center;
}

/* Bot Message Links */
.me-message.bot .me-message-content a {
    color: var(--me-primary);
    text-decoration: none;
    font-weight: 500;
}

.me-message.bot .me-message-content a:hover {
    text-decoration: underline;
}

/* ═══ TYPING INDICATOR ═══ */
.me-typing-indicator {
    display: none;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transform: translateY(6px);
    transition: var(--me-transition);
    pointer-events: none;
}

.me-typing-indicator.active {
    display: flex;
    margin: 12px 0 24px;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.me-typing-dots {
    display: flex;
    gap: 6px;
    padding: 16px 20px;
    background: var(--me-white);
    border: 1px solid rgba(97, 0, 0, 0.08);
    border-radius: 22px 22px 22px 10px;
    box-shadow: var(--me-shadow-sm);
}

.me-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--me-gray-500);
    border-radius: 50%;
    animation: me-typing 1.4s infinite;
}

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

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

/* ═══ INPUT AREA ═══ */
.me-chat-input {
    padding: 20px 24px;
    background: var(--me-white);
    border-top: 1px solid var(--me-gray-200);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    border-radius: 0 0 16px 16px;
}

.me-input-wrapper {
    flex: 1;
    position: relative;
}

.me-chat-textarea {
    width: 100%;
    min-height: 44px;
    max-height: 120px;
    padding: 12px 16px;
    border: 2px solid rgba(97, 0, 0, 0.08);
    border-radius: 22px;
    font-family: inherit;
    font-size: 16px; /* WICHTIG: Verhindert Zoom auf iOS */
    resize: none;
    outline: none;
    background: var(--me-gray-50);
    transition: var(--me-transition-fast);
    scrollbar-width: none;
    -webkit-appearance: none; /* iOS Styling entfernen */
    -webkit-border-radius: 22px; /* iOS Border-Radius Fix */
    transform: scale(1); /* Verhindert Zoom-Bugs */
}

.me-chat-textarea::-webkit-scrollbar {
    display: none;
}

.me-chat-textarea:focus {
    border-color: var(--me-primary);
    background: var(--me-white);
    box-shadow: 0 0 0 4px rgba(97, 0, 0, 0.08);
    font-size: 16px; /* Zoom-Prevention auf Focus */
}

.me-chat-textarea::placeholder {
    color: var(--me-gray-500);
}

.me-send-button {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--me-primary) 0%, var(--me-primary-light) 100%);
    border: none;
    border-radius: 50%;
    color: var(--me-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--me-transition-fast);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(97, 0, 0, 0.2);
}

.me-send-button:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--me-primary-dark) 0%, var(--me-primary) 100%);
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(97, 0, 0, 0.3);
}

.me-send-button:active {
    transform: scale(0.95);
}

.me-send-button:disabled {
    background: var(--me-gray-300);
    cursor: not-allowed;
    transform: none;
}

/* ═══ WELCOME MESSAGE ═══ */
.me-welcome {
    text-align: center;
    padding: 30px 20px;
    color: var(--me-gray-700);
}

.me-welcome-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--me-primary);
    margin: 0 0 8px 0;
}

.me-welcome-subtitle {
    font-size: 14px;
    margin: 0 0 24px 0;
    line-height: 1.5;
    opacity: 0.8;
}

.me-quick-questions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.me-quick-question {
    background: var(--me-white);
    border: 1px solid var(--me-gray-200);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--me-transition-fast);
    text-align: left;
}

.me-quick-question:hover {
    background: var(--me-primary);
    color: var(--me-white);
    border-color: var(--me-primary);
    transform: translateY(-1px);
    box-shadow: var(--me-shadow-sm);
}

/* ═══ iOS ZOOM PREVENTION ═══ */
@supports (-webkit-touch-callout: none) {
    /* iOS spezifische Fixes */
    .me-chat-textarea {
        font-size: 16px !important;
        -webkit-text-size-adjust: 100%;
        -webkit-appearance: none !important;
    }
    
    /* Verhindert Doppel-Tap Zoom */
    .me-chatbot * {
        touch-action: manipulation;
    }
}

/* ═══ MOBILE RESPONSIVE ═══ */
@media (max-width: 480px) {
    .me-chatbot {
        bottom: 16px;
        right: 16px;
        left: 16px;
    }
    
    .me-chat-window {
        width: 100%;
        height: 70vh;
        max-height: 600px;
        bottom: 76px;
        right: 0;
        left: 0;
        border-radius: 16px 16px 0 0;
    }
    
    .me-message-content {
        max-width: 260px;
    }
    
    .me-chat-fab {
        width: 56px;
        height: 56px;
        position: fixed;
        right: 16px;
        bottom: 16px;
    }
    
    /* KRITISCH: Zoom Prevention auf Mobile */
    .me-chat-textarea {
        font-size: 16px !important;
        transform: scale(1);
        -webkit-text-size-adjust: 100%;
    }
    
    .me-chat-textarea:focus {
        font-size: 16px !important;
    }
}

@media (max-width: 360px) {
    .me-chat-window {
        height: 75vh;
    }
    
    .me-message-content {
        max-width: 220px;
    }
}

/* ═══ ACCESSIBILITY ═══ */
.me-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus indicators for keyboard navigation */
.me-chat-fab:focus,
.me-send-button:focus,
.me-quick-question:focus,
.me-chat-minimize:focus {
    outline: 2px solid var(--me-primary);
    outline-offset: 2px;
}

.me-chat-textarea:focus {
    outline: none; /* Already has custom focus style */
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .me-chat-window {
        border: 2px solid var(--me-gray-700);
    }
    
    .me-message.bot .me-message-content {
        border: 2px solid var(--me-gray-700);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    /* Mobile optimizations - nicht mehr nötig */
}
