/* === ПУБЛИЧНЫЙ ЧАТ AUTOASIA - ПОЛНОЭКРАННЫЙ ВИДЖЕТ === */

/* Кнопка открытия чата */
.public-chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: transform 0.3s, box-shadow 0.3s;
}

.public-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
}

.public-chat-toggle i {
    font-size: 24px;
    color: white;
}

.public-chat-toggle .chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    display: none;
}

/* 🎅 Шапка Деда Мороза */
.public-chat-toggle .santa-hat-img {
    position: absolute;
    top: -38px;
    left: 50%;
    transform: translateX(-50%) rotate(-8deg);
    width: 90px;
    height: auto;
    z-index: 1;
    pointer-events: none;
    filter: drop-shadow(2px 4px 8px rgba(0,0,0,0.35));
    transition: transform 0.3s ease;
}

.public-chat-toggle:hover .santa-hat-img {
    animation: santaHatWiggle 0.6s ease-in-out infinite;
}

@keyframes santaHatWiggle {
    0%, 100% { transform: translateX(-50%) rotate(-8deg); }
    50% { transform: translateX(-50%) rotate(2deg); }
}

/* Окно чата - полная ширина внизу */
.public-chat-window {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60vh;
    max-height: 600px;
    background: #1a1a2e;
    border-top: 2px solid #667eea;
    border-radius: 20px 20px 0 0;
    display: none;
    flex-direction: column;
    z-index: 9999;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.public-chat-window.open {
    display: flex;
}

/* Мобильная версия - полный экран */
@media (max-width: 768px) {
    .public-chat-window {
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }
    
    .public-chat-toggle {
        bottom: 15px;
        right: 15px;
        width: 55px;
        height: 55px;
    }
    
    .public-chat-toggle .santa-hat-img {
        width: 80px;
        top: -34px;
    }
}

/* На узких экранах делаем поле ввода вертикальным и удобным для тача */
@media (max-width: 480px) {
    .public-chat-input-area {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px;
    }
    .public-chat-input-area input[type="text"] {
        height: 44px;
        padding: 10px 12px;
        border-radius: 10px;
    }
    .public-chat-input-area button {
        width: 44px;
        height: 44px;
    }
    .public-chat-reply-banner {
        order: -1;
    }
}

/* Шапка чата */
.public-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 18px 18px 0 0;
}

.public-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.public-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.public-chat-avatar i {
    font-size: 20px;
    color: white;
}

.public-chat-title {
    color: white;
}

.public-chat-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.public-chat-title span {
    font-size: 12px;
    opacity: 0.8;
}

.public-chat-header-actions {
    display: flex;
    gap: 10px;
}

.public-chat-header-actions button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: background 0.2s;
}

.public-chat-header-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.public-chat-support-btn {
    width: auto !important;
    padding: 8px 12px !important;
    border-radius: 20px !important;
    font-size: 13px !important;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.public-chat-support-btn.active {
    background: rgba(255, 255, 255, 0.35) !important;
}

/* Форма личного сообщения в поддержку */
.public-chat-support-form {
    padding: 14px 20px;
    background: #16213e;
    border-bottom: 1px solid #2a2a4a;
}
.public-chat-support-form-title {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 600;
    color: #e0e0e0;
}
.public-chat-support-form-hint {
    margin: 0 0 10px 0;
    font-size: 12px;
    color: #9ca3af;
}
.public-chat-support-form textarea {
    width: 100%;
    box-sizing: border-box;
    background: #1a1a2e;
    border: 1px solid #3a3a5a;
    border-radius: 8px;
    padding: 10px 12px;
    color: white;
    font-size: 14px;
    resize: vertical;
    min-height: 70px;
}
.public-chat-support-form textarea::placeholder {
    color: #888;
}
.public-chat-support-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    justify-content: flex-end;
}
.public-chat-support-form-actions button {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}
.public-chat-support-form-actions button:first-child {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}
.public-chat-support-form-actions button:first-child:hover {
    background: rgba(255, 255, 255, 0.25);
}
.public-chat-support-submit {
    background: #667eea !important;
    color: white !important;
}
.public-chat-support-submit:hover {
    background: #5a6fd6 !important;
}
.public-chat-support-notice {
    padding: 10px 14px;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.4);
    border-radius: 8px;
    color: #86efac;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Область ника */
.public-chat-nickname-bar {
    padding: 10px 20px;
    background: #16213e;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #2a2a4a;
}

.public-chat-nickname-bar input {
    flex: 1;
    background: #1a1a2e;
    border: 1px solid #3a3a5a;
    border-radius: 8px;
    padding: 8px 12px;
    color: white;
    font-size: 14px;
}

.public-chat-nickname-bar input::placeholder {
    color: #888;
}

.public-chat-nickname-bar button {
    background: #667eea;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.public-chat-nickname-bar button:hover {
    background: #5a6fd6;
}

/* Область сообщений */
.public-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Скроллбар */
.public-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.public-chat-messages::-webkit-scrollbar-track {
    background: #1a1a2e;
}

.public-chat-messages::-webkit-scrollbar-thumb {
    background: #3a3a5a;
    border-radius: 3px;
}

/* Сообщение */
.public-chat-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

.public-chat-message.selected .public-chat-message-content {
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.7);
}

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

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

.public-chat-message.assistant,
.public-chat-message.admin {
    align-self: flex-start;
}

.public-chat-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.public-chat-message.user .public-chat-message-avatar {
    background: #667eea;
}

.public-chat-message.assistant .public-chat-message-avatar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.public-chat-message.admin .public-chat-message-avatar {
    background: #10b981;
}

.public-chat-message-avatar i {
    font-size: 16px;
    color: white;
}

/* Иконка AI/Admin - логотип */
.public-chat-message-avatar .chat-bot-avatar {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

/* Убираем фон для AI и Admin когда используется картинка */
.public-chat-message.assistant .public-chat-message-avatar,
.public-chat-message.admin .public-chat-message-avatar {
    background: transparent;
}

.public-chat-message-content {
    background: #16213e;
    border-radius: 16px;
    padding: 12px 16px;
    color: white;
    font-size: 14px;
    line-height: 1.5;
}

.public-chat-message.user .public-chat-message-content {
    background: #667eea;
    border-radius: 16px 16px 4px 16px;
}

.public-chat-message.assistant .public-chat-message-content,
.public-chat-message.admin .public-chat-message-content {
    border-radius: 16px 16px 16px 4px;
}

.public-chat-reply-quote {
    font-size: 12px;
    color: #cbd5f5;
    padding: 4px 8px;
    border-left: 3px solid rgba(129, 140, 248, 0.9);
    margin-bottom: 4px;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 6px;
}

.public-chat-reply-main {
    margin-top: 2px;
}

.public-chat-message-content img {
    max-width: 200px;
    border-radius: 8px;
    margin-top: 8px;
}

/* Имя отправителя */
.public-chat-message-sender {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #a5b4fc;
}

.public-chat-message.user .public-chat-message-sender {
    color: #c4b5fd;
    text-align: right;
}

.public-chat-message.assistant .public-chat-message-sender {
    color: #f9a8d4;
}

.public-chat-message.admin .public-chat-message-sender {
    color: #6ee7b7;
}

.public-chat-message-time {
    font-size: 11px;
    color: #888;
    margin-top: 4px;
}

.public-chat-message.user .public-chat-message-time {
    text-align: right;
}

.public-chat-message-body {
    position: relative;
}
.public-chat-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.public-chat-reaction-pill {
    font-size: 12px;
    padding: 2px 8px;
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
}
.public-chat-reaction-bar {
    display: none;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.public-chat-message:hover .public-chat-reaction-bar {
    display: flex;
}
.public-chat-reaction-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}
.public-chat-reaction-btn:hover {
    background: rgba(255,255,255,0.35);
}

/* Индикатор печати */
.public-chat-typing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: #888;
    font-size: 13px;
}

.public-chat-typing-dots {
    display: flex;
    gap: 4px;
}

.public-chat-typing-dots span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.public-chat-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.public-chat-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Поле ввода */
.public-chat-input-area {
    padding: 10px 14px;
    background: #16213e;
    border-top: 1px solid #2a2a4a;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.public-chat-input-area input[type="text"] {
    flex: 1;
    background: #1a1a2e;
    border: 1px solid #3a3a5a;
    border-radius: 20px;
    padding: 8px 12px;
    color: white;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    height: 40px;
    box-sizing: border-box;
}

.public-chat-input-area input[type="text"]:focus {
    border-color: #667eea;
}

.public-chat-input-area input[type="text"]::placeholder {
    color: #666;
}

.public-chat-input-area button {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.public-chat-input-area button i {
    font-size: 18px;
    color: #888;
}

.public-chat-input-area button:hover {
    background: #2a2a4a;
}

.public-chat-input-area button:hover i {
    color: #667eea;
}

.public-chat-input-area .send-btn {
    background: #667eea;
}

.public-chat-input-area .send-btn i {
    color: white;
}

.public-chat-input-area .send-btn:hover {
    background: #5a6fd6;
}

.public-chat-reply-banner {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 12px;
    background: rgba(37, 99, 235, 0.15);
    border: 1px solid rgba(129, 140, 248, 0.6);
    color: #cbd5f5;
    font-size: 12px;
    flex-basis: 100%;
    order: -1;
    width: 100%;
    align-self: stretch;
    box-sizing: border-box;
    margin-bottom: 6px;
}

.public-chat-reply-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    /* Обрезаем длинный текст в одну строку с местом для кнопки */
    max-width: calc(100% - 40px);
}

.public-chat-reply-banner button {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    background: transparent;
    color: #cbd5f5;
    cursor: pointer;
    padding: 0;
}

.public-chat-reply-banner button:hover {
    background: rgba(148, 163, 184, 0.25);
}

/* Скрытый input для файла */
.public-chat-input-area input[type="file"] {
    display: none;
}

/* Обёртка кнопки смайла и панели */
.public-chat-emoji-wrap {
    position: relative;
}

.public-chat-emoji-wrap .public-chat-emoji-picker {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 320px;
    max-height: 260px;
    overflow-y: auto;
    background: #16213e;
    border: 1px solid #3a3a5a;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 100;
    display: none;
}

.public-chat-emoji-wrap .public-chat-emoji-picker.open {
    display: block;
}

.public-chat-emoji-section {
    margin-bottom: 10px;
}

.public-chat-emoji-section:last-child {
    margin-bottom: 0;
}

.public-chat-emoji-section-title {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.public-chat-emoji-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.public-chat-emoji-item {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
}

.public-chat-emoji-item:hover {
    background: #2a2a4a;
}

/* Приветственное сообщение */
.public-chat-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #888;
}

.public-chat-welcome i {
    font-size: 48px;
    color: #667eea;
    margin-bottom: 15px;
}

.public-chat-welcome h4 {
    color: white;
    margin: 0 0 10px 0;
    font-size: 18px;
}

.public-chat-welcome p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* Быстрые вопросы */
.public-chat-quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
}

.public-chat-quick-questions button {
    background: #2a2a4a;
    border: 1px solid #3a3a5a;
    border-radius: 20px;
    padding: 8px 16px;
    color: white;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.public-chat-quick-questions button:hover {
    background: #667eea;
    border-color: #667eea;
}
