/**
 * Стили для системы чатов магазинов
 * Версия 1.4.2 - 23.10.2025 22:00
 * Добавлено: кнопка обновления с анимацией вращения
 */

/* === КНОПКА ОТКРЫТИЯ ЧАТА === */
.chat-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    z-index: 999;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.chat-button:active {
    transform: scale(0.95);
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 12px;
    padding: 3px 8px;
    font-size: 13px;
    font-weight: bold;
    min-width: 22px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.6);
    animation: pulse-badge 2s ease-in-out infinite;
    border: 2px solid white;
}

@keyframes pulse-badge {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(255, 68, 68, 0.6);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 4px 16px rgba(255, 68, 68, 0.9);
    }
}

/* === МОДАЛЬНОЕ ОКНО ЧАТА === */
.chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.chat-modal.active {
    display: flex;
}

.chat-modal-content {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* === ШАПКА ЧАТА === */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-refresh-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.chat-refresh-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(180deg);
}

.chat-refresh-btn:active {
    transform: rotate(360deg);
}

/* === ТАБЫ МАГАЗИНОВ === */
.chat-shops-tabs {
    display: flex;
    gap: 8px;
    padding: 15px;
    border-bottom: 2px solid #f0f0f0;
    overflow-x: auto;
    flex-shrink: 0;
}

.chat-shop-tab {
    background: #f5f5f5;
    border: none;
    padding: 10px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.3s;
    position: relative;
}

.chat-shop-tab:hover {
    background: #e8e8e8;
}

.chat-shop-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.shop-unread-badge {
    display: none; /* По умолчанию скрыт */
    background: #ff4444;
    color: white;
    border-radius: 12px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 700;
    margin-left: 8px;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(255, 68, 68, 0.5);
    animation: pulse-badge-small 2s ease-in-out infinite;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.shop-unread-badge.visible {
    display: inline-block !important; /* Показываем когда есть непрочитанные */
}

.shop-unread-badge:empty {
    display: none !important; /* Всегда скрываем если пустой */
}

@keyframes pulse-badge-small {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

.chat-shop-tab.active .shop-unread-badge {
    background: rgba(255, 255, 255, 0.95);
    color: #667eea;
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.chat-shop-tab.has-new-message {
    animation: shake 0.5s ease-in-out;
    background: #ffeb3b !important;
    color: #333 !important;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* === ОБЛАСТЬ СООБЩЕНИЙ === */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
}

.chat-welcome {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-size: 16px;
}

.chat-date-separator {
    text-align: center;
    color: #999;
    font-size: 12px;
    margin: 15px 0;
    position: relative;
}

.chat-date-separator::before,
.chat-date-separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: #ddd;
}

.chat-date-separator::before {
    left: 0;
}

.chat-date-separator::after {
    right: 0;
}

/* === СООБЩЕНИЯ === */
.chat-message {
    background: white;
    border-radius: 15px;
    padding: 12px 15px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    max-width: 80%;
}

.chat-message.own {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    font-size: 12px;
}

.chat-message.own .message-header {
    color: rgba(255, 255, 255, 0.9);
}

.message-header strong {
    font-size: 14px;
}

.message-time {
    color: #999;
    font-size: 11px;
}

.chat-message.own .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.message-text {
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
}

/* === ОБЛАСТЬ ВВОДА === */
.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 15px;
    border-top: 2px solid #f0f0f0;
    background: white;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
}

.chat-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-send-btn {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    border: none;
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
    padding-left: 3px; /* Центрируем треугольник */
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.5);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

/* === ПОДВАЛ ЧАТА === */
.chat-footer {
    padding: 10px 15px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #666;
    flex-shrink: 0;
}

.btn-change-name {
    background: transparent;
    border: 1px solid #667eea;
    color: #667eea;
    padding: 4px 10px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.3s;
}

.btn-change-name:hover {
    background: #667eea;
    color: white;
}

.btn-toggle-sound {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.btn-toggle-sound:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

.btn-toggle-sound:active {
    transform: scale(0.95);
}

/* === АДАПТИВНОСТЬ === */
@media (max-width: 768px) {
    .chat-button {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
        font-size: 24px;
    }
    
    .chat-modal {
        padding: 0;
    }
    
    .chat-modal-content {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .chat-message {
        max-width: 90%;
    }
}

/* === СКРОЛЛБАР === */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

.chat-shops-tabs::-webkit-scrollbar {
    height: 4px;
}

.chat-shops-tabs::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-shops-tabs::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

/* === ФОТО В СООБЩЕНИЯХ === */
.photo-preview {
    padding: 10px 15px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    position: relative;
}

.photo-preview img {
    max-width: 200px;
    max-height: 150px;
    border-radius: 8px;
    display: block;
}

.remove-photo-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: rgba(255, 68, 68, 0.9);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.remove-photo-btn:hover {
    background: #ff4444;
    transform: scale(1.1);
}

.chat-photo-btn {
    background: transparent;
    border: none;
    color: #667eea;
    font-size: 22px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.chat-photo-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

.chat-photo-btn:active {
    transform: scale(0.95);
}

.message-photo {
    margin: 8px 0;
}

.message-photo img {
    max-width: 300px;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: block;
}

.message-photo img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* === ПРОСМОТР ФОТО В ПОЛНОМ РАЗМЕРЕ === */
.photo-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.photo-overlay-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.photo-overlay-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.photo-close-btn {
    position: absolute;
    top: -40px;
    right: 0;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.photo-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

