/* Chat Widget CSS */
#chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: all 0.3s ease;
}

#chat-widget.minimized {
    height: 60px;
    overflow: hidden;
}

#chat-widget.hidden {
    display: none;
}

#chat-header {
    background: linear-gradient(135deg, #1e88e5, #1565c0);
    color: white;
    padding: 15px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

#chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

#chat-back-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    margin: 0;
    width: 24px;
    height: 24px;
    display: none;
}

#chat-header-title {
    font-size: 16px;
    font-weight: 600;
}

#chat-header-right {
    display: flex;
    gap: 10px;
}

#chat-minimize-btn,
#chat-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chat-minimize-btn:hover,
#chat-close-btn:hover {
    opacity: 0.8;
}

#chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.chat-message-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: slideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-message-wrapper .chat-avatar {
    animation: avatarPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes avatarPop {
    0% {
        opacity: 0;
        transform: scale(0);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.chat-message-wrapper.admin {
    align-self: flex-start;
}

.chat-message-wrapper.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    cursor: pointer;
}

.chat-avatar:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.chat-avatar::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.6;
}

.chat-avatar.admin {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-avatar.admin::after {
    content: '👨‍💼';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.6);
    animation: statusPulseChat 2s infinite;
}

@keyframes statusPulseChat {

    0%,
    100% {
        box-shadow: 0 2px 6px rgba(76, 175, 80, 0.6);
    }

    50% {
        box-shadow: 0 2px 12px rgba(76, 175, 80, 0.9), 0 0 20px rgba(76, 175, 80, 0.4);
    }
}

.chat-avatar.user {
    background: linear-gradient(135deg, #FF6B6B 0%, #C44569 100%);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

.chat-avatar.user::after {
    content: '😊';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #FFA726, #FB8C00);
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    box-shadow: 0 2px 6px rgba(255, 167, 38, 0.6);
    animation: statusPulseChat 2s infinite 0.5s;
}

.chat-avatar.bot {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
    font-size: 24px;
}

.chat-avatar.bot::after {
    content: '⚡';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #FFC107, #FFA000);
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    box-shadow: 0 2px 6px rgba(255, 193, 7, 0.6);
    animation: statusPulseChat 2s infinite 1s;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

.chat-sender-name {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 6px;
    padding-left: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-sender-name.user {
    background: linear-gradient(135deg, #FF6B6B, #C44569);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chat-sender-name.user::before {
    content: '👤';
    font-size: 12px;
    -webkit-text-fill-color: initial;
}

.chat-sender-name.admin {
    /* Removed gradient text fill so [Support] badge is visible */
}

.chat-sender-name.admin::before {
    content: '👨‍💼';
    font-size: 12px;
}

.chat-sender-name.bot {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chat-sender-name.bot::before {
    content: '🤖';
    font-size: 12px;
    -webkit-text-fill-color: initial;
}

.chat-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.chat-message-content:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.chat-message-wrapper.admin .chat-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-left-radius: 4px;
}

.chat-message-wrapper.user .chat-message-content {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-right-radius: 4px;
}

.chat-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 6px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-message-time::before {
    content: '🕐';
    font-size: 10px;
}

.chat-message-wrapper.admin .chat-message-time {
    justify-content: flex-start;
}

.chat-message-wrapper.user .chat-message-time {
    justify-content: flex-end;
}

#chat-welcome {
    text-align: center;
    padding: 20px;
}

#chat-welcome-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 15px;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
    position: relative;
    animation: pulse 2s infinite;
}

#chat-welcome-avatar::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    padding: 4px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.1));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.8;
}

#chat-welcome-avatar::after {
    content: '✨';
    position: absolute;
    bottom: -3px;
    right: -3px;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    border-radius: 50%;
    border: 3px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
    }

    50% {
        box-shadow: 0 6px 30px rgba(102, 126, 234, 0.7);
    }
}

#chat-welcome-text {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
}

#chat-quick-replies {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-quick-reply {
    background: white;
    border: 2px solid #1e88e5;
    color: #1e88e5;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    text-align: center;
}

.chat-quick-reply:hover {
    background: #1e88e5;
    color: white;
}

#chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    align-items: center;
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
}

#chat-input:focus {
    border-color: #1e88e5;
}

#chat-send-btn {
    background: #1e88e5;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.2s ease;
}

#chat-send-btn:hover {
    background: #1565c0;
}

#chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e88e5, #1565c0);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(30, 136, 229, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    z-index: 9998;
    transition: all 0.3s ease;
}

#chat-toggle-btn:hover {
    transform: scale(1.1);
}

#chat-toggle-btn.show {
    display: flex;
}

.chat-typing-indicator {
    display: flex;
    padding: 12px 16px;
    background: #1e88e5;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    gap: 4px;
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    animation: typing 1.4s infinite;
}

.chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.7;
    }

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

@media (max-width: 480px) {
    #chat-widget {
        width: calc(100% - 40px);
        height: calc(100% - 40px);
        bottom: 0;
        right: 0;
        margin: 20px;
        border-radius: 12px;
    }

    #chat-widget.minimized {
        width: 200px;
        height: 60px;
        bottom: 20px;
        right: 20px;
    }
}

/* Online Status Indicator */
.online-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 8px;
    position: relative;
    vertical-align: middle;
}

.online-status.online {
    background: #4CAF50;
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    animation: onlinePulse 2s infinite;
}

.online-status.offline {
    background: #999;
}

@keyframes onlinePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(76, 175, 80, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}
