/**
 * EMT Chatbox - Frontend Styles
 */

/* Container */
#emt-chatbox-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Chat Button */
.emt-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0084ff 0%, #0066cc 100%);
    box-shadow: 0 4px 12px rgba(0, 132, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.emt-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 132, 255, 0.5);
}

/* Attention-grabbing animations */
.emt-chat-button.shake {
    animation: shake 0.8s ease-in-out;
}

.emt-chat-button.bounce {
    animation: bounce 1s ease-in-out;
}

.emt-chat-button.wiggle {
    animation: wiggle 1s ease-in-out;
}

.emt-chat-button.glow {
    animation: glow 2s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-20px); }
    60% { transform: translateY(-10px); }
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(0, 132, 255, 0.4);
    }
    50% {
        box-shadow: 0 0 25px rgba(0, 132, 255, 0.8),
                    0 0 50px rgba(0, 132, 255, 0.6);
    }
}

/* Ripple effect on button */
.emt-chat-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: rgba(0, 132, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: ripple 2s ease-out infinite;
}

@keyframes ripple {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

.emt-chat-button.hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

.emt-chat-button svg {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* Unread Badge */
.emt-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    animation: pulse 2s infinite;
}

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

/* Chat Window */
.emt-chat-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 40px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transform: scale(0);
    transform-origin: bottom right;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow: hidden;
}

.emt-chat-window.open {
    transform: scale(1);
    opacity: 1;
}

/* Chat Header */
.emt-chat-header {
    background: linear-gradient(135deg, #0084ff 0%, #0066cc 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.emt-header-content h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
}

.emt-status-indicator {
    display: flex;
    align-items: center;
    font-size: 12px;
    opacity: 0.9;
}

.emt-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
    margin-right: 6px;
    animation: blink 2s infinite;
}

.emt-status-dot.online {
    background: #4caf50;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

.emt-header-actions {
    display: flex;
    gap: 8px;
}

.emt-icon-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.emt-icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Container */
.emt-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f5;
    scroll-behavior: smooth;
}

.emt-messages-container::-webkit-scrollbar {
    width: 6px;
}

.emt-messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.emt-messages-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* Messages */
.emt-message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

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

.emt-message-content {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
}

.emt-message-content p {
    margin: 0;
    font-size: 14px;
}

.emt-message-received .emt-message-content {
    background: white;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.emt-message-sent .emt-message-content {
    background: #0084ff;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.emt-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    align-self: flex-end;
}

.emt-message-received .emt-message-time {
    align-self: flex-start;
}

/* Typing Indicator */
.emt-typing-indicator {
    padding: 0 20px 10px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.emt-typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: white;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.emt-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

.emt-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.emt-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.emt-typing-text {
    font-size: 12px;
    color: #999;
}

/* Input Container */
.emt-input-container {
    background: white;
    border-top: 1px solid #e5e5e5;
    padding: 12px;
}

.emt-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.emt-message-input {
    flex: 1;
    border: 1px solid #e5e5e5;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color 0.2s;
}

.emt-message-input:focus {
    outline: none;
    border-color: #0084ff;
}

.emt-message-input::-webkit-scrollbar {
    width: 4px;
}

.emt-message-input::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.emt-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #0084ff;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.emt-send-btn:hover:not(:disabled) {
    background: #0066cc;
    transform: scale(1.05);
}

.emt-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.emt-powered-by {
    text-align: center;
    font-size: 11px;
    color: #999;
    margin-top: 8px;
}

/* Welcome Notification Popup */
.emt-welcome-notification {
    position: fixed;
    bottom: 100px;
    right: 20px;
    max-width: 300px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 16px;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 999998;
    cursor: pointer;
}

.emt-welcome-notification.show {
    transform: translateY(0);
    opacity: 1;
}

.emt-welcome-notification.hide {
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
}

.emt-notification-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.emt-notification-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0084ff 0%, #0066cc 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    flex-shrink: 0;
}

.emt-notification-info {
    flex: 1;
}

.emt-notification-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    margin-bottom: 2px;
}

.emt-notification-status {
    font-size: 12px;
    color: #4caf50;
    display: flex;
    align-items: center;
    gap: 4px;
}

.emt-notification-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4caf50;
    animation: blink 2s infinite;
}

.emt-notification-message {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

.emt-notification-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}

.emt-notification-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #666;
}

/* Typing indicator in notification */
.emt-notification-typing {
    display: flex;
    gap: 3px;
    margin-top: 8px;
}

.emt-notification-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #0084ff;
    animation: typing 1.4s infinite;
}

.emt-notification-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.emt-notification-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .emt-chat-window {
        width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .emt-chat-header {
        border-radius: 0;
    }

    #emt-chatbox-container {
        bottom: 15px;
        right: 15px;
    }

    .emt-welcome-notification {
        right: 15px;
        bottom: 85px;
        max-width: calc(100% - 30px);
    }
}
