/* Chat System Styles - Gizadata.vn */

/* ============================================
   POPUP MODAL - Hiển thị ở giữa màn hình khi có tin nhắn mới từ admin
   ============================================ */
.chat-popup-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(4px);
}

.chat-popup-modal.hidden {
    display: none;
}

/* Ẩn icon chat khi popup hiển thị */
body.chat-popup-open .chat-toggle-btn {
    display: none !important;
}

/* Ẩn nút chat khi widget đang mở */
.chat-widget-container:not(.minimized) ~ .chat-toggle-btn {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chat-popup-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    position: relative;
}

.chat-popup-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-popup-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 600;
}

.chat-popup-title i {
    font-size: 1.5rem;
}

.chat-popup-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1.2rem;
}

.chat-popup-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.chat-popup-body {
    padding: 24px;
}

.chat-popup-message {
    font-size: 1rem;
    line-height: 1.6;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-bottom: 20px;
}

.chat-popup-footer {
    padding: 16px 24px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.chat-popup-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.chat-popup-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.chat-popup-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-popup-btn-secondary {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.chat-popup-btn-secondary:hover {
    background: #e9ecef;
}

/* ============================================
   CHAT WIDGET - Hiển thị ở mép màn hình
   ============================================ */
#chatWidget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.chat-toggle-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.chat-toggle-btn i {
    display: inline-block;
    transform-origin: center bottom;
    animation: gentleIconWiggle 3.5s ease-in-out infinite;
}

.chat-toggle-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.chat-toggle-btn:hover i {
    animation-play-state: paused;
}

.chat-toggle-btn.pulse {
    animation: pulse 2s infinite;
}

@keyframes gentleIconWiggle {
    0%, 78%, 100% {
        transform: rotate(0deg);
    }
    82% {
        transform: rotate(-5deg);
    }
    86% {
        transform: rotate(5deg);
    }
    90% {
        transform: rotate(-3deg);
    }
    94% {
        transform: rotate(3deg);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.chat-unread-badge-mini {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
    animation: bounce 0.5s;
}

@keyframes bounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

.chat-widget-container {
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s;
    animation: slideUpWidget 0.3s ease;
}

.chat-widget-container.minimized {
    display: none;
}

@keyframes slideUpWidget {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chat-widget-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    cursor: move;
}

.chat-widget-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 1rem;
}

.chat-unread-badge {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

.chat-widget-actions {
    display: flex;
    gap: 8px;
}

.chat-widget-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.chat-widget-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-widget-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f5f5f5;
}

.chat-message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    animation: messageSlideIn 0.3s ease;
}

.chat-message.from-me {
    align-items: flex-end;
}

.chat-message.from-other {
    align-items: flex-start;
}

.chat-message-sender {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 4px;
    padding: 0 5px;
    font-weight: 600;
}

.chat-message.from-me .chat-message-sender {
    color: #667eea;
}

.chat-message.from-other .chat-message-sender {
    color: #6c757d;
}

.chat-message-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.4;
}

.chat-message.from-me .chat-message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.from-other .chat-message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chat-message-time {
    font-size: 0.7rem;
    color: #999;
    margin-top: 4px;
    padding: 0 5px;
}

.chat-input-wrapper {
    padding: 12px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    resize: none;
    max-height: 100px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #667eea;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.chat-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    text-align: center;
    padding: 40px 20px;
}

.chat-empty i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #6c757d;
    gap: 10px;
    min-height: 100px;
}

.chat-loading .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 0.2em;
}

.chat-loading span {
    font-size: 0.9rem;
    font-weight: 500;
}

.chat-typing-indicator {
    padding: 10px 15px;
    font-style: italic;
    color: #6c757d;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-typing-dots {
    display: flex;
    gap: 4px;
}

.chat-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6c757d;
    animation: typingDot 1.4s infinite;
}

.chat-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Scrollbar styling */
.chat-messages-list::-webkit-scrollbar {
    width: 6px;
}

.chat-messages-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.chat-messages-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive */
@media (max-width: 768px) {
    #chatWidget {
        bottom: 10px;
        right: 10px;
    }

    .chat-widget-container {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        max-width: 400px;
    }

    .chat-popup-content {
        width: 95%;
        max-height: 90vh;
    }
}

/* Notification sound indicator (optional) */
.chat-notification-sound {
    display: none;
}

/* Load More Button */
.chat-load-more-container {
    text-align: center;
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.chat-load-more {
    width: 100%;
    padding: 8px 16px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    color: #6c757d;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-load-more:hover:not(:disabled) {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #495057;
}

.chat-load-more:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-load-more i {
    margin-right: 4px;
}



@media (max-width: 600px) {
    #chatWidget {
        bottom: 95px;
        right: 10px;
    }
    
    .chat-widget-container {
        width: calc(100vw - 20px);
        height: calc(100vh - 200px);
        max-height: 450px;
    }
    
    .chat-messages-list {
        padding: 10px;
        max-height: calc(100vh - 300px);
    }
    
    .chat-widget-header {
        padding: 12px 15px;
    }
    
    .chat-input-wrapper {
        padding: 10px;
    }
    
    .chat-popup-content {
        max-height: 70vh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-toggle-btn i {
        animation: none;
    }
}