/* AI Concierge Widget Styles */
:root {
    --ai-concierge-primary: #2563EB;
    --ai-concierge-bg: #ffffff;
    --ai-concierge-text: #1f2937;
    --ai-concierge-muted: #6b7280;
    --ai-concierge-border: #e5e7eb;
    --ai-concierge-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

/* Кнопка открытия чата */
.ai-concierge-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--ai-concierge-primary);
    border: none;
    cursor: pointer;
    box-shadow: var(--ai-concierge-shadow);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ai-concierge-button:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 45px rgba(0,0,0,0.2);
}

.ai-concierge-button svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.ai-concierge-button.open svg.chat-icon {
    display: none;
}

.ai-concierge-button svg.close-icon {
    display: none;
}

.ai-concierge-button.open svg.close-icon {
    display: block;
}

/* Окно чата */
.ai-concierge-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: var(--ai-concierge-bg);
    border-radius: 16px;
    box-shadow: var(--ai-concierge-shadow);
    z-index: 99998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    -webkit-text-size-adjust: 100%; /* iOS: prevent text resize */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ai-concierge-window.open {
    display: flex;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Шапка чата */
.ai-concierge-header {
    background: var(--ai-concierge-primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-concierge-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.ai-concierge-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.ai-concierge-info p {
    margin: 2px 0 0;
    font-size: 13px;
    opacity: 0.9;
}

/* Область сообщений */
.ai-concierge-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* iOS: плавный скролл */
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transform: translateZ(0); /* iOS: GPU рендеринг */
    backface-visibility: hidden; /* iOS: предотвращает мерцание */
}

.ai-concierge-message {
    max-width: 85%;
    transform: translateZ(0); /* iOS: GPU рендеринг */
    backface-visibility: hidden;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-concierge-message.bot {
    align-self: flex-start;
    background: #f3f4f6;
    color: var(--ai-concierge-text);
    border-bottom-left-radius: 4px;
}

.ai-concierge-message.user {
    align-self: flex-end;
    background: var(--ai-concierge-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-concierge-message.typing {
    display: flex;
    gap: 4px;
    padding: 16px;
}

.ai-concierge-message.typing span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.ai-concierge-message.typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-concierge-message.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Форма ввода */
.ai-concierge-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--ai-concierge-border);
    display: flex;
    gap: 10px;
    background: #fafafa;
}

.ai-concierge-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--ai-concierge-border);
    border-radius: 20px;
    -webkit-appearance: none; /* iOS: убрать стандартные стили */
    font-size: 16px; /* iOS zoom fix */
    outline: none;
    transition: border-color 0.2s, height 0.1s;
    /* Для textarea */
    resize: none;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.4;
    overflow-y: auto;
    font-family: inherit;
}

.ai-concierge-input:focus {
    border-color: var(--ai-concierge-primary);
}

.ai-concierge-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--ai-concierge-primary);
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1); /* iOS feedback */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-concierge-send:hover {
    filter: brightness(1.1);
}

.ai-concierge-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-concierge-send svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Мобильная адаптация */
@media (max-width: 480px) {
    .ai-concierge-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: calc(100vh - 80px);
        max-height: none;
        border-radius: 16px 16px 0 0;
    }
    
    .ai-concierge-button {
        bottom: 80px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
}

/* Кнопка закрытия в header */
.ai-concierge-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 12px; /* Увеличена область касания для мобильных */
    margin: -8px; /* Компенсация padding для визуального размера */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
    transition: opacity 0.2s;
    -webkit-tap-highlight-color: rgba(255,255,255,0.2); /* iOS feedback */
}

.ai-concierge-close-btn:hover {
    opacity: 1;
}

.ai-concierge-close-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* Мобильная версия - скрыть плавающую кнопку когда окно открыто */
@media (max-width: 480px) {
    .ai-concierge-button.open {
        display: none !important;
    }
    
    .ai-concierge-input-area {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

/* Правильное позиционирование кнопки закрытия в header */
.ai-concierge-info {
    flex-grow: 1;
}

/* ================================================================
   🎯 PREMIUM CHAT UX - Google/Apple/Netflix Level
   Добавлено: 10.12.2025
   ================================================================ */

/* === КНОПКА ЧАТА - Premium pulse === */
.ai-concierge-button {
    background: linear-gradient(135deg, var(--ai-concierge-primary) 0%, var(--ai-concierge-primary-dark) 100%);
    animation: concierge-pulse 2.5s ease-in-out infinite;
}

@keyframes concierge-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--ai-concierge-primary-rgb), 0.4), var(--ai-concierge-shadow); }
    50% { box-shadow: 0 0 0 12px rgba(var(--ai-concierge-primary-rgb), 0), var(--ai-concierge-shadow); }
}

.ai-concierge-button:hover {
    animation: none;
    box-shadow: 0 15px 50px rgba(var(--ai-concierge-primary-rgb), 0.35);
}

/* === АВАТАР БОТА рядом с сообщениями === */
.ai-concierge-message.bot {
    position: relative;
    padding-left: 48px;
}

.ai-concierge-message.bot::before {
    content: '🤖';
    position: absolute;
    left: 0;
    top: 8px;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* === АНИМАЦИЯ ПОЯВЛЕНИЯ СООБЩЕНИЙ === */
.ai-concierge-message {
    animation: messageSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes messageSlideIn {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-concierge-message.user {
    animation: messageSlideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes messageSlideInRight {
    from { opacity: 0; transform: translateX(20px) scale(0.95); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

/* === УЛУЧШЕННЫЙ TYPING ИНДИКАТОР === */
.ai-concierge-message.typing {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    padding-left: 48px;
}

.ai-concierge-message.typing::before {
    content: '🤖';
    position: absolute;
    left: 0;
    top: 8px;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    animation: avatarPulse 1.5s ease-in-out infinite;
}

@keyframes avatarPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.ai-concierge-message.typing span {
    background: linear-gradient(135deg, var(--ai-concierge-primary) 0%, #60a5fa 100%);
}

/* === КНОПКА ОТПРАВКИ - Premium === */
.ai-concierge-send {
    background: linear-gradient(135deg, var(--ai-concierge-primary) 0%, var(--ai-concierge-primary-dark) 100%);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-concierge-send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 15px rgba(var(--ai-concierge-primary-rgb), 0.3);
}

.ai-concierge-send:active {
    transform: scale(0.95);
}

/* === ПОЛЕ ВВОДА - Focus эффект === */
.ai-concierge-input:focus {
    box-shadow: 0 0 0 3px rgba(var(--ai-concierge-primary-rgb), 0.15);
    border-color: var(--ai-concierge-primary);
}

/* === ХЕДЕР ЧАТА - Gradient === */
.ai-concierge-header {
    background: linear-gradient(135deg, var(--ai-concierge-primary) 0%, var(--ai-concierge-primary-dark) 100%);
}

/* === СТАТУС ОНЛАЙН === */
.ai-concierge-avatar {
    position: relative;
}

.ai-concierge-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid white;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* === СКРОЛЛБАР === */
.ai-concierge-messages::-webkit-scrollbar { width: 6px; }
.ai-concierge-messages::-webkit-scrollbar-track { background: transparent; }
.ai-concierge-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }

/* === ACCESSIBILITY === */
@media (prefers-reduced-motion: reduce) {
    .ai-concierge-button, .ai-concierge-message, .ai-concierge-send, .ai-concierge-avatar::after {
        animation: none !important;
    }
}
