/* =====================================================
 * AI Chat Widget - Premium CSS
 * Floating chatbot with smooth animations
 * ===================================================== */

/* CSS Custom Properties */
:root {
    --chat-primary: #6366f1;
    --chat-primary-dark: #4f46e5;
    --chat-primary-light: #818cf8;
    --chat-bg: #ffffff;
    --chat-bg-secondary: #f8fafc;
    --chat-text: #1e293b;
    --chat-text-secondary: #64748b;
    --chat-border: #e2e8f0;
    --chat-user-bubble: #6366f1;
    --chat-user-text: #ffffff;
    --chat-bot-bubble: #f1f5f9;
    --chat-bot-text: #1e293b;
    --chat-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    --chat-radius: 16px;
    --chat-width: 400px;
    --chat-height: 600px;
    --chat-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --chat-z-index: 99999;
    --chat-transition: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Import Inter font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ===== Floating Toggle Button ===== */
.chat-widget-toggle {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    border: none;
    cursor: pointer;
    z-index: var(--chat-z-index);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: all 0.3s var(--chat-transition);
    animation: chat-pulse 2s infinite;
}

.chat-widget-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(99, 102, 241, 0.5);
}

.chat-widget-toggle:active {
    transform: scale(0.95);
}

.chat-widget-toggle svg {
    width: 28px;
    height: 28px;
    fill: white;
    transition: transform 0.3s ease;
}

.chat-widget-toggle.active svg {
    transform: rotate(90deg);
}

.chat-widget-toggle .chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--chat-font);
    animation: chat-badge-bounce 0.3s var(--chat-transition);
}

@keyframes chat-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(99, 102, 241, 0.6); }
}

@keyframes chat-badge-bounce {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

/* ===== Chat Window ===== */
.chat-widget-window {
    position: fixed;
    bottom: 96px;
    left: 24px;
    width: var(--chat-width);
    height: var(--chat-height);
    max-height: calc(100vh - 120px);
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    z-index: var(--chat-z-index);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--chat-font);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s var(--chat-transition);
    border: 1px solid var(--chat-border);
}

.chat-widget-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ===== Header ===== */
.chat-widget-header {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-widget-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-widget-header-avatar svg {
    width: 22px;
    height: 22px;
    fill: white;
}

.chat-widget-header-info {
    flex: 1;
    min-width: 0;
}

.chat-widget-header-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.chat-widget-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-widget-header-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: chat-status-pulse 1.5s infinite;
}

@keyframes chat-status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-widget-header-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chat-widget-header-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== Messages Area ===== */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--chat-bg-secondary);
    scroll-behavior: smooth;
}

.chat-widget-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-widget-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 10px;
}

/* ===== Message Bubbles ===== */
.chat-msg {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: chat-msg-in 0.3s var(--chat-transition);
}

@keyframes chat-msg-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg.assistant {
    align-self: flex-start;
    position: relative;
}

.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.chat-msg.user .chat-msg-bubble {
    background: var(--chat-user-bubble);
    color: var(--chat-user-text);
    border-bottom-right-radius: 4px;
}

.chat-msg.assistant .chat-msg-bubble {
    background: var(--chat-bot-bubble);
    color: var(--chat-bot-text);
    border-bottom-left-radius: 4px;
}

.chat-msg-time {
    font-size: 11px;
    color: var(--chat-text-secondary);
    margin-top: 4px;
    opacity: 0.7;
}

.chat-msg.user .chat-msg-time {
    text-align: right;
}

/* Feedback buttons */
.chat-msg-feedback {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    position: absolute;
    bottom: 8px;
    right: 17px;
}

.chat-msg-feedback button {
    background: none;
    border: 1px solid var(--chat-border);
    border-radius: 6px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--chat-text-secondary);
    transition: all 0.2s;
}

.chat-msg-feedback button:hover {
    border-color: var(--chat-primary);
    color: var(--chat-primary);
}

.chat-msg-feedback button.active {
    background: var(--chat-primary);
    color: white;
    border-color: var(--chat-primary);
}

/* ===== Typing Indicator ===== */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--chat-bot-bubble);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 70px;
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--chat-text-secondary);
    border-radius: 50%;
    animation: chat-typing-bounce 1.4s infinite ease-in-out;
}

.chat-typing-dot:nth-child(1) { animation-delay: 0s; }
.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chat-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== Input Area ===== */
.chat-widget-input {
    padding: 12px 16px;
    background: var(--chat-bg);
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-widget-input textarea {
    flex: 1;
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    padding: 10px 14px;
    font-family: var(--chat-font);
    font-size: 14px;
    resize: none;
    outline: none;
    min-height: 40px;
    max-height: 120px;
    line-height: 1.4;
    background: var(--chat-bg-secondary);
    color: var(--chat-text);
    transition: border-color 0.2s;
}

.chat-widget-input textarea:focus {
    border-color: var(--chat-primary-light);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.chat-widget-input textarea::placeholder {
    color: var(--chat-text-secondary);
}

.chat-widget-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chat-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-widget-send-btn:hover {
    background: var(--chat-primary-dark);
    transform: scale(1.05);
}

.chat-widget-send-btn:disabled {
    background: var(--chat-border);
    cursor: not-allowed;
    transform: none;
}

.chat-widget-send-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* ===== Welcome Screen ===== */
.chat-welcome {
    text-align: center;
    padding: 30px 20px;
}

.chat-welcome-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--chat-primary-light), var(--chat-primary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-welcome-icon svg {
    width: 32px;
    height: 32px;
    fill: white;
}

.chat-welcome h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--chat-text);
    margin: 0 0 8px;
}

.chat-welcome p {
    font-size: 14px;
    color: var(--chat-text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .chat-widget-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .chat-widget-toggle {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }
}

/* ===== Powered By ===== */
.chat-widget-footer {
    text-align: center;
    padding: 6px;
    font-size: 11px;
    color: var(--chat-text-secondary);
    opacity: 0.6;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-bg);
    flex-shrink: 0;
}

/* ===== Language Selector ===== */
.chat-lang-select {
    display: inline-flex;
    gap: 4px;
    margin-left: auto;
}

.chat-lang-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    font-family: var(--chat-font);
    transition: background 0.2s;
}

.chat-lang-btn.active,
.chat-lang-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

