/* Новый уникальный дизайн чата для пользователей */

.ticket-chat-frontend { 
    max-width: 900px; 
    margin: 30px auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.chat-window { 
    border: none;
    border-radius: 20px; 
    overflow: hidden; 
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    background: #ffffff;
}

/* Хедер чата */
.chat-header-user { 
    padding: 25px 30px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e22ce 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.chat-header-user::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.chat-header-user h3 { 
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-user h3::before {
    content: '💬';
    font-size: 24px;
}

.status-indicator { 
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 14px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.status-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

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

.status-indicator::after {
    content: 'В сети';
}

/* Область сообщений */
.chat-messages-user { 
    height: 550px;
    overflow-y: auto;
    padding: 25px;
    background: linear-gradient(to bottom, #f8fafc 0%, #f1f5f9 100%);
    position: relative;
}

.chat-messages-user::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.8), transparent);
    pointer-events: none;
}

/* Кастомный скроллбар */
.chat-messages-user::-webkit-scrollbar {
    width: 8px;
}

.chat-messages-user::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 10px;
}

.chat-messages-user::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.chat-messages-user::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5568d3 0%, #63408b 100%);
}

/* Область ввода */
.chat-input-user { 
    padding: 20px 25px 25px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

.input-group { 
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: #f8fafc;
    padding: 8px;
    border-radius: 25px;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
}

.input-group:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.attach-icon { 
    cursor: pointer;
    font-size: 22px;
    padding: 10px 12px;
    transition: all 0.2s ease;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.attach-icon:hover {
    background: #e2e8f0;
    transform: rotate(15deg);
}

.attach-icon::before {
/*    content: '📎';*/
}

#user-message-text { 
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    border-radius: 20px;
    resize: none;
    min-height: 44px;
    max-height: 200px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    outline: none;
    color: #1e293b;
    overflow-y: auto;
    transition: height 0.1s ease;
}

#user-message-text::placeholder {
    color: #94a3b8;
}

.send-button { 
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.send-button:hover {
    transform: scale(1.08) rotate(15deg);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

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

.send-button::before {
    content: '➤';
    transform: translateX(1px);
}

/* Сообщения пользователя */
.message-item-user { 
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
/*    animation: slideIn 0.3s ease;*/
}

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

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

.msg-avatar { 
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    border: 3px solid #ffffff;
}

.from-me .msg-avatar { 
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

.msg-content { 
    max-width: 75%;
}

.msg-bubble { 
    padding: 14px 18px;
    border-radius: 20px 20px 20px 4px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
}

.from-me .msg-bubble { 
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border-radius: 20px 20px 4px 20px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.msg-bubble::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 20px 8px;
    border-color: transparent transparent #ffffff transparent;
}

.from-me .msg-bubble::before {
    left: auto;
    right: -8px;
    border-width: 0 8px 20px 0;
    border-color: transparent transparent #764ba2 transparent;
}

.msg-text { 
    margin: 0;
    line-height: 1.6;
    word-wrap: break-word;
    font-size: 15px;
}

.msg-time { 
    font-size: 11px;
    color: #000;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.msg-time::before {
    content: '🕐';
    font-size: 12px;
}

.from-me .msg-time { 
    text-align: right;
    color: #000;
    justify-content: flex-end;
}

/* Вложения */
.msg-attachments { 
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.msg-attachment { 
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #f1f5f9;
    border-radius: 12px;
    font-size: 13px;
    transition: all 0.2s ease;
    border: 1px solid #e2e8f0;
}
.msg-attachment a{ 
    word-wrap: break-word;
    display: flex;
    flex-wrap: wrap;
}

.msg-attachment:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.msg-attachment::before {
    content: '📄';
    font-size: 16px;
}

.from-me .msg-attachment { 
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

.from-me .msg-attachment:hover {
    background: rgba(255, 255, 255, 0.35);
}

.msg-attachment a { 
    text-decoration: none;
    color: inherit;
    font-weight: 500;
}

/* Превью прикрепленных файлов */
#user-file-preview { 
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.user-file-item { 
    padding: 10px 16px;
    background: linear-gradient(135deg, #e0e7ff 0%, #ddd6fe 100%);
    border-radius: 14px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 2px solid #c7d2fe;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.user-file-item::before {
    content: '📎';
    font-size: 16px;
}

/* Пустое состояние */
.chat-messages-user:empty::after {
    content: 'Начните диалог с нашей службой поддержки';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #94a3b8;
    font-size: 16px;
    text-align: center;
}

/* Адаптивность */
@media (max-width: 768px) {
    .ticket-chat-frontend {
        margin: 15px;
    }
    
    .chat-window {
        border-radius: 15px;
    }
    
    .chat-header-user {
        padding: 20px;
    }
    
    .chat-header-user h3 {
        font-size: 18px;
    }
    
    .chat-messages-user {
        height: 450px;
        padding: 15px;
    }
    
    .msg-content {
        max-width: 85%;
    }
    
    .chat-input-user {
        padding: 15px;
    }
}
/* Мобильная адаптация */
@media screen and (max-width: 768px) {
    .ticket-chat-frontend {
        margin: 15px auto;
        max-width: 100%;
        padding: 0 10px;
    }
    
    .chat-window {
        border-radius: 15px;
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    }
    
    .chat-header-user {
        padding: 18px 20px;
    }
    
    .chat-header-user h3 {
        font-size: 18px;
    }
    
    .status-indicator {
        width: 10px;
        height: 10px;
    }
    
    .chat-messages-user {
        min-height: 400px;
        max-height: 50vh;
        padding: 20px 15px;
    }
    
    .message-item-user {
        max-width: 85%;
    }
    
    .msg-avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .msg-text {
        font-size: 14px;
        line-height: 1.5;
    }
    
    .msg-time {
        font-size: 11px;
    }
    
    .chat-input-user {
        padding: 15px;
    }
    
    .input-group {
        gap: 8px;
    }
    
    #user-message-text {
        font-size: 14px;
        padding: 12px 15px;
        min-height: 44px; /* Увеличено для удобства на мобильных */
    }
    
    .send-button {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    
    .attach-icon {
        font-size: 20px;
        padding: 10px;
    }
    
    .user-file-item {
        font-size: 12px;
        padding: 6px 10px;
    }
}

/* Улучшение для очень маленьких экранов */
@media screen and (max-width: 480px) {
    .ticket-chat-frontend {
        margin: 10px auto;
        padding: 0 5px;
    }
    
    .chat-window {
        border-radius: 12px;
    }
    
    .chat-header-user {
        padding: 15px;
    }
    
    .chat-header-user h3 {
        font-size: 16px;
        gap: 8px;
    }
    
    .chat-messages-user {
        min-height: 350px;
        max-height: 45vh;
        padding: 15px 10px;
    }
    
    .message-item-user {
        max-width: 90%;
    }
    
    .msg-bubble {
        padding: 10px 14px;
    }
    
    .msg-text {
        font-size: 13px;
    }
    
    .chat-input-user {
        padding: 12px;
    }
    
    .input-group {
        gap: 6px;
    }
    
    #user-message-text {
        font-size: 15px; /* Увеличено, чтобы избежать автозума на iOS */
        padding: 10px 12px;
    }
    
    .send-button {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .attach-icon {
        font-size: 18px;
        padding: 8px;
    }
}

/* Поддержка landscape ориентации на мобильных */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .chat-messages-user {
        max-height: 30vh;
        min-height: 200px;
    }
}
