/**
 * Shared Chat Widget Styles
 * Works across all sites with CSS variable theming
 */

/* Default CSS variables - sites can override these */
:root {
    --chat-primary: #4da6ff;
    --chat-secondary: #6366f1;
    --chat-accent: #a855f7;
}

.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.chat-toggle:active {
    transform: scale(0.95);
}

.chat-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideIn 0.3s ease;
}

.chat-container.active {
    display: flex;
}

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

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

.chat-header h5 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.chat-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--chat-primary);
    border-radius: 3px;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: messageSlideIn 0.3s ease;
}

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

.chat-message.user {
    align-self: flex-end;
}

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

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
}

.chat-message.user .message-bubble {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.bot .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.message-timestamp {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 8px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border: 1px solid #e0e0e0;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chat-primary);
    animation: typing 1.4s infinite;
}

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

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

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

.chat-input {
    display: flex;
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
    gap: 8px;
}

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

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

.chat-input input::placeholder {
    color: #999;
}

.chat-input button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    font-size: 16px;
}

.chat-input button:hover {
    transform: scale(1.05);
}

.chat-input button:active {
    transform: scale(0.95);
}

.chat-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 12px 16px;
    border-radius: 18px;
    border: 1px solid #fcc;
    font-size: 14px;
    margin: 8px 0;
}

/* Mobile Responsive */
@media (max-width: 767px) {
    .chat-container {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 70vh;
        border-radius: 20px 20px 0 0;
        max-width: none;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }

    .chat-container.active {
        animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .chat-toggle {
        width: 56px;
        height: 56px;
        font-size: 20px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    }

    .chat-header {
        padding: 14px 16px;
    }

    .chat-header h5 {
        font-size: 16px;
    }

    .chat-messages {
        padding: 16px;
    }

    .chat-input {
        padding: 12px;
    }

    .chat-input input {
        padding: 10px 14px;
        font-size: 16px;
    }

    .chat-input button {
        width: 40px;
        height: 40px;
    }
}
