/* Hoài An Chatbot - Frontend Styles */

:root {
    --hoaian-primary: #667eea;
    --hoaian-secondary: #764ba2;
    --hoaian-bg: #f5f7fb;
    --hoaian-text: #333;
    --hoaian-shadow: 0 5px 40px rgba(0,0,0,0.16);
}

/* Widget Container */
.hoaian-widget {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

.hoaian-widget[data-position="right"] {
    right: 20px;
}

.hoaian-widget[data-position="left"] {
    left: 20px;
}

/* Toggle Button */
.hoaian-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--hoaian-primary), var(--hoaian-secondary));
    color: white;
    font-size: 28px;
    cursor: pointer;
    box-shadow: var(--hoaian-shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hoaian-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 50px rgba(102, 126, 234, 0.4);
}

.hoaian-toggle .toggle-icon {
    line-height: 1;
}

/* Chat Window */
.hoaian-window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-height: 550px;
    background: white;
    border-radius: 16px;
    box-shadow: var(--hoaian-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.hoaian-widget[data-position="right"] .hoaian-window {
    right: 0;
}

.hoaian-widget[data-position="left"] .hoaian-window {
    left: 0;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.hoaian-header {
    background: linear-gradient(135deg, var(--hoaian-primary), var(--hoaian-secondary));
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    overflow: hidden;
    background: white;
    flex-shrink: 0;
}

.header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-info {
    flex: 1;
}

.header-name {
    font-weight: 600;
    font-size: 16px;
}

.header-status {
    font-size: 12px;
    opacity: 0.9;
}

.header-clear,
.header-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    opacity: 0.7;
    transition: opacity 0.2s;
    margin-left: 5px;
}

.header-clear:hover,
.header-close:hover {
    opacity: 1;
}

/* Messages Area */
.hoaian-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--hoaian-bg);
    min-height: 300px;
    max-height: 350px;
}

/* Message Bubbles */
.hoaian-message {
    display: flex;
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.hoaian-message.user {
    justify-content: flex-end;
}

.hoaian-message.bot {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.4;
    font-size: 14px;
}

.hoaian-message.user .message-bubble {
    background: linear-gradient(135deg, var(--hoaian-primary), var(--hoaian-secondary));
    color: white;
    border-bottom-right-radius: 4px;
}

.hoaian-message.bot .message-bubble {
    background: white;
    color: var(--hoaian-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Feedback buttons */
.hoaian-feedback {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    margin-left: 6px;
}

.hoaian-message.user .hoaian-feedback {
    display: none;
}

.hoaian-feedback-btn {
    border: 1px solid #e6e6e6;
    background: #fff;
    border-radius: 12px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    transition: transform 0.1s, box-shadow 0.2s, border-color 0.2s;
}

.hoaian-feedback-btn:hover {
    transform: scale(1.05);
    border-color: #cfcfcf;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.hoaian-feedback.submitted .hoaian-feedback-btn {
    opacity: 0.6;
    pointer-events: none;
}

.hoaian-feedback-btn.selected {
    border-color: var(--hoaian-primary);
    box-shadow: 0 2px 6px rgba(102,126,234,0.25);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.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% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* Input Area */
.hoaian-input-area {
    padding: 12px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}

#hoaian-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#hoaian-input:focus {
    border-color: var(--hoaian-primary);
}

.hoaian-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--hoaian-primary), var(--hoaian-secondary));
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: transform 0.2s;
}

.hoaian-send:hover {
    transform: scale(1.05);
}

/* Footer */
.hoaian-footer {
    padding: 8px;
    text-align: center;
    font-size: 11px;
    color: #999;
    background: #fafafa;
}

.hoaian-footer a {
    color: var(--hoaian-primary);
    text-decoration: none;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .hoaian-window {
        width: calc(100vw - 40px);
        max-height: 70vh;
        bottom: 70px;
    }
    
    .hoaian-widget[data-position="right"],
    .hoaian-widget[data-position="left"] {
        right: 10px;
        left: 10px;
    }
    
    .hoaian-widget[data-position="right"] .hoaian-window,
    .hoaian-widget[data-position="left"] .hoaian-window {
        right: 0;
        left: 0;
    }
}
