
.chat-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.4);
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.chat-btn:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.6);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.chat-btn i {
    color: white;
    font-size: 24px;
    transition: transform 0.3s ease;
}

.chat-btn:hover i {
    transform: scale(1.1);
}


.chat-notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #ff4757, #ff3742);
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 20px; 
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
    animation: pulse-notification 2s infinite;
    z-index: 1001;
}

@keyframes pulse-notification {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
    }
    50% { 
        transform: scale(1.1); 
        box-shadow: 0 4px 12px rgba(255, 71, 87, 0.6);
    }
}


.chat-live-indicator {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 14px;
    height: 14px;
    background: #2ecc71;
    border-radius: 50%;
    border: 2px solid rgb(255, 0, 0);
    animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.2); }
}


.modal.chat-modal-container {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(15px);
}

.modal-content.chat-modal {
    background: linear-gradient(145deg, #1e1e2e, #2a2a3e);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    max-width: 450px;
    width: 90%;
    max-height: 650px;
    margin: 2% auto;
    overflow: hidden;
    backdrop-filter: blur(20px);
    position: relative;
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    border-radius: 20px 20px 0 0;
    overflow: hidden;
}

.modal-header h3 {
    color: white;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h3 i {
    font-size: 20px;
}

.modal-header h3::after {
    content: '';
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    animation: pulse 2s infinite;
    margin-left: 8px;
}

.modal-header .close {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 20px;
    font-weight: 300;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10;
}

.modal-header .close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) rotate(90deg);
}


.chat-container {
    height: 550px;
    display: flex;
    flex-direction: column;
    background: #1e1e2e;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: linear-gradient(145deg, #1e1e2e, #252538);
    min-height: 450px;
    max-height: 450px;
    position: relative;
}


.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin: 5px 0;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2, #667eea);
    border: 1px solid rgba(255, 255, 255, 0.2);
}


.chat-message {
    margin-bottom: 20px;
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: all 0.3s ease;
}

.chat-message.new-message {
    animation: slideInMessage 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInMessage {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-message.user {
    text-align: right;
}

.chat-message.admin {
    text-align: left;
}

.chat-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 12px;
    opacity: 0.9;
}

.chat-message.user .chat-message-header {
    flex-direction: row-reverse;
}

.chat-sender {
    font-weight: 600;
    color: #667eea;
}

.chat-message.admin .chat-sender {
    color: #f093fb;
}

.chat-time {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
}

.chat-text {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 14px 18px;
    border-radius: 20px;
    display: inline-block;
    max-width: 70%;
    word-wrap: break-word;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
    font-size: 14px;
}


.chat-message.user .chat-text { margin-left: auto; }
.chat-message.admin .chat-text { margin-right: auto; }

.chat-message.admin .chat-text {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    box-shadow: 0 4px 20px rgba(240, 147, 251, 0.3);
}

.chat-message.user .chat-text::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: -10px;
    width: 0;
    height: 0;
    border: 10px solid transparent;
    border-left-color: #764ba2;
    border-bottom: 0;
    border-right: 0;
}

.chat-message.admin .chat-text::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -10px;
    width: 0;
    height: 0;
    border: 10px solid transparent;
    border-right-color: #f5576c;
    border-bottom: 0;
    border-left: 0;
}


.chat-image-container {
    position: relative;
    margin: 10px 0;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.3);
    max-width: 280px;
    display: inline-block;
}

.chat-image {
    width: 100%;
    height: auto;
    max-height: 220px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.3s ease;
    border-radius: 15px;
}

.chat-image:hover {
    transform: scale(1.02);
}

.chat-image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 10px 15px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 0 0 15px 15px;
}

.chat-image-container:hover .chat-image-overlay {
    opacity: 1;
}

.chat-message.user .chat-image-container {
    margin-left: auto;
}

.chat-message.admin .chat-image-container {
    margin-right: auto;
}


.chat-file-container {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    margin: 10px 0;
    max-width: 280px;
    display: inline-block;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
}

.file-info i {
    font-size: 24px;
    color: #667eea;
}

.file-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    word-break: break-all;
}

.download-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.download-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}


.chat-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 5px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2ecc71;
}

.status-dot.sending {
    background: #f39c12;
    animation: pulse 1s infinite;
}

.status-dot.delivered {
    background: #3498db;
}

.status-dot.read {
    background: #2ecc71;
}


.delete-message-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 8px;
}

.delete-message-btn:hover {
    background: rgba(255, 82, 82, 0.8);
    color: white;
}


.chat-input-container {
    padding: 20px;
    background: linear-gradient(145deg, #2a2a3e, #1e1e2e);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: flex-end;
    gap: 12px;
    border-radius: 0 0 20px 20px;
    min-height: 110px;
}

.image-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.image-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

#chatMessageInput {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 14px 18px;
    border-radius: 25px;
    outline: none;
    font-size: 14px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    resize: none;
    min-height: 58px;
    max-height: 120px;
    overflow-y: hidden;
    font-family: inherit;
    line-height: 1.4;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

#chatMessageInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2), inset 0 1px 3px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.12);
    outline: none;
}

#chatMessageInput::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.send-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
    background: linear-gradient(135deg, #764ba2, #667eea);
}

.send-btn:active {
    transform: scale(0.95);
}


.chat-message.admin:first-child .chat-text {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}


.online-indicator {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    margin-left: 8px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}


@media (max-width: 768px) {
    .modal-content.chat-modal {
        width: 95%;
        max-height: 85vh;
        margin: 2% auto;
    }
    
    .chat-container {
        height: 500px;
    }
    
    .chat-messages {
        max-height: 400px;
    }
    
    .chat-input-container {
        padding: 15px;
        min-height: 70px;
    }
    
    .image-btn, .send-btn {
        width: 38px;
        height: 38px;
    }
    
    #chatMessageInput {
        min-height: 38px;
        padding: 12px 16px;
    }
    
    .chat-btn {
        width: 50px;
        height: 50px;
        bottom: 15px;
        right: 15px;
    }
    
    .chat-btn i {
        font-size: 20px;
    }
    
    .chat-image-container {
        max-width: 220px;
    }
    
    .chat-notification-badge {
        min-width: 18px;
        height: 18px;
        line-height: 18px;
        font-size: 10px;
        top: -6px;
        right: -6px;
    }
}


.chat-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 10px;
    color: rgb(255, 0, 0);
    font-weight: 500;
    z-index: 10000;
    animation: slideInNotification 0.3s ease-out;
    max-width: 300px;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.3);
}

.notification-success {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
}

.notification-error {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.notification-info {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

@keyframes slideInNotification {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}


.chat-btn:has(.chat-live-indicator) .chat-notification-badge {
    top: -5px;
    right: -12px;
}


.ai-loading-message {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    margin: 8px 0;
    border-left: 3px solid #667eea;
    animation: fadeInUp 0.3s ease-out;
}

.ai-loading-text {
    color: #667eea;
    font-size: 14px;
    font-weight: 500;
}

.ai-loading-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.ai-loading-dot {
    width: 6px;
    height: 6px;
    background: #667eea;
    border-radius: 50%;
    animation: loadingDots 1.4s infinite ease-in-out both;
}

.ai-loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.ai-loading-dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes loadingDots {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}