/* Chat Widget Styles */
.chat-widget {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    height: 500px;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-widget.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border-radius: 16px 16px 0 0;
}

.chat-agent {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-agent img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
}

.chat-agent h4 {
    font-size: 16px;
    margin-bottom: 2px;
}

.chat-agent .status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-agent .status i {
    font-size: 8px;
    color: #4ade80;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-request-human {
    display: flex !important;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    border: none;
    border-radius: 20px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(74, 222, 128, 0.3);
}

.btn-request-human:hover {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(74, 222, 128, 0.4);
}

.btn-request-human i {
    font-size: 14px;
}

.chat-close {
    background: none;
    border: none;
    color: var(--white);
    font-size: 20px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.chat-close:hover {
    opacity: 1;
    background: rgba(255,255,255,0.1);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
}

.message {
    margin-bottom: 16px;
    animation: messageSlide 0.3s ease;
}

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

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.message.agent .message-content {
    background: var(--white);
    color: var(--dark);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.message.user {
    display: flex;
    justify-content: flex-end;
}

.message.user .message-content {
    background: var(--primary);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.message-time {
    display: block;
    font-size: 11px;
    color: var(--gray);
    margin-top: 4px;
    margin-left: 4px;
}

.message.user .message-time {
    text-align: right;
    margin-right: 4px;
}

/* System Message */
.message.system {
    display: flex;
    justify-content: center;
    margin: 12px 0;
}

.system-message {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 16px;
    font-size: 12px;
    text-align: center;
    max-width: 90%;
}

/* Message sender label */
.message-sender {
    font-size: 11px;
    color: var(--primary);
    margin-bottom: 2px;
    font-weight: 500;
}

.message.agent .message-sender {
    margin-left: 4px;
}

/* Status indicators */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.status-dot.online {
    background: #4ade80;
    animation: pulse 2s infinite;
}

.status-dot.pending {
    background: #f59e0b;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    background: var(--white);
    border-top: 1px solid #eee;
}

.chat-quick-replies button {
    padding: 8px 14px;
    background: rgba(26,95,158,0.1);
    border: none;
    border-radius: 16px;
    font-size: 12px;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

.chat-quick-replies button:hover {
    background: var(--primary);
    color: var(--white);
}

.chat-input {
    display: flex;
    padding: 16px 20px;
    background: var(--white);
    border-top: 1px solid #eee;
    border-radius: 0 0 16px 16px;
}

.chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input input:focus {
    border-color: var(--primary);
}

.chat-input button {
    width: 44px;
    height: 44px;
    margin-left: 10px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input button:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.chat-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(26,95,158,0.4);
    z-index: 9998;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(26,95,158,0.5);
}

.unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    color: var(--white);
    font-size: 12px;
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: badgePulse 0.3s ease;
}

@keyframes badgePulse {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--white);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-bottom: 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@media (max-width: 480px) {
    .chat-widget {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    .chat-header {
        border-radius: 0;
    }
    
    .chat-input {
        border-radius: 0;
    }
}
