/* ==========================================
   AI CHATBOT WIDGET — Premium Styles
   ========================================== */

/* CSS Variables — Tematizare */
:root {
    --chat-primary: #6366f1;
    --chat-primary-dark: #4f46e5;
    --chat-accent: #8b5cf6;
    --chat-bg: #0f172a;
    --chat-surface: #1e293b;
    --chat-surface-2: #334155;
    --chat-text: #f1f5f9;
    --chat-text-muted: #94a3b8;
    --chat-border: rgba(99, 102, 241, 0.15);
    --chat-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    --chat-radius: 20px;
    --chat-width: 400px;
    --chat-height: 600px;
}

/* ==========================================
   TRIGGER BUTTON — Floating
   ========================================== */
.chat-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}
.chat-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.5);
}
.chat-trigger:active {
    transform: scale(0.95);
}

.chat-trigger-icon {
    font-size: 1.6rem;
    transition: transform 0.3s;
}
.chat-trigger.is-open .chat-trigger-icon {
    transform: rotate(90deg);
}

/* Pulse ring animation */
.chat-trigger::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--chat-primary);
    animation: triggerPulse 3s ease-in-out infinite;
}
.chat-trigger.is-open::before {
    animation: none;
    opacity: 0;
}

@keyframes triggerPulse {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.15); opacity: 0; }
}

/* Notification badge */
.chat-trigger-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    border: 2px solid #050510;
    animation: badgePop 0.3s ease;
}
@keyframes badgePop {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* ==========================================
   CHAT WINDOW
   ========================================== */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 9999;
    width: var(--chat-width);
    height: var(--chat-height);
    max-height: calc(100vh - 140px);
    border-radius: var(--chat-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    box-shadow: var(--chat-shadow);

    /* Animation */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.chat-window.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ==========================================
   HEADER
   ========================================== */
.chat-header {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.chat-header-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    backdrop-filter: blur(5px);
}
.chat-header-name {
    font-weight: 600;
    color: #fff;
    font-size: 1rem;
}
.chat-header-status {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.75);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.chat-header-status .online-dot {
    width: 7px; height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}
.chat-header-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 32px; height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.2s;
}
.chat-header-close:hover {
    background: rgba(255,255,255,0.25);
}

/* ==========================================
   GDPR NOTICE
   ========================================== */
.chat-gdpr {
    background: rgba(99, 102, 241, 0.08);
    border-bottom: 1px solid var(--chat-border);
    padding: 0.7rem 1rem;
    font-size: 0.75rem;
    color: var(--chat-text-muted);
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    flex-shrink: 0;
}
.chat-gdpr-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.chat-gdpr-dismiss {
    background: none;
    border: none;
    color: var(--chat-primary);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0;
    white-space: nowrap;
    margin-left: auto;
    flex-shrink: 0;
}

/* ==========================================
   MESSAGES AREA
   ========================================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--chat-surface-2); border-radius: 4px; }

/* Message Bubble */
.chat-msg {
    display: flex;
    gap: 0.5rem;
    animation: msgFadeIn 0.35s ease;
    max-width: 88%;
}
.chat-msg.from-bot { align-self: flex-start; }
.chat-msg.from-user { align-self: flex-end; flex-direction: row-reverse; }

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

.chat-msg-avatar {
    width: 30px; height: 30px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-top: 2px;
}
.chat-msg.from-bot .chat-msg-avatar {
    background: rgba(99, 102, 241, 0.15);
}
.chat-msg.from-user .chat-msg-avatar {
    background: rgba(139, 92, 246, 0.15);
}

.chat-msg-bubble {
    padding: 0.7rem 1rem;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-msg.from-bot .chat-msg-bubble {
    background: var(--chat-surface);
    color: var(--chat-text);
    border-bottom-left-radius: 4px;
}
.chat-msg.from-user .chat-msg-bubble {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg-time {
    font-size: 0.65rem;
    color: var(--chat-text-muted);
    margin-top: 4px;
    opacity: 0.6;
}
.chat-msg.from-user .chat-msg-time { text-align: right; }

/* Typing indicator */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    animation: msgFadeIn 0.3s ease;
}
.chat-typing-dots {
    display: flex;
    gap: 4px;
}
.chat-typing-dots span {
    width: 7px; height: 7px;
    background: var(--chat-text-muted);
    border-radius: 50%;
    animation: typingBounce 1.2s ease-in-out infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

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

/* ==========================================
   QUICK REPLIES
   ========================================== */
.chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.25rem 0;
    animation: msgFadeIn 0.4s ease;
}
.chat-quick-btn {
    padding: 0.4rem 0.85rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 100px;
    color: #a5b4fc;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.chat-quick-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--chat-primary);
    color: #fff;
}

/* ==========================================
   LEAD FORM (INLINE)
   ========================================== */
.chat-lead-form {
    background: var(--chat-surface);
    border: 1px solid var(--chat-border);
    border-radius: 14px;
    padding: 1rem;
    margin: 0.5rem 0;
    animation: msgFadeIn 0.4s ease;
}
.chat-lead-form h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--chat-text);
}
.chat-lead-form input,
.chat-lead-form textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    color: var(--chat-text);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: 'Inter', sans-serif;
}
.chat-lead-form input:focus,
.chat-lead-form textarea:focus {
    border-color: var(--chat-primary);
}
.chat-lead-form textarea {
    resize: none;
    height: 60px;
}
.chat-lead-form input::placeholder,
.chat-lead-form textarea::placeholder {
    color: var(--chat-text-muted);
}
.chat-lead-submit {
    width: 100%;
    padding: 0.6rem;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.chat-lead-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}
.chat-lead-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================
   INPUT BAR
   ========================================== */
.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-surface);
    flex-shrink: 0;
}
.chat-input {
    flex: 1;
    padding: 0.65rem 0.9rem;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    color: var(--chat-text);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: 'Inter', sans-serif;
}
.chat-input:focus {
    border-color: var(--chat-primary);
}
.chat-input::placeholder {
    color: var(--chat-text-muted);
}
.chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}
.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}
.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}
.chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* Powered by */
.chat-powered {
    text-align: center;
    padding: 0.35rem;
    font-size: 0.65rem;
    color: var(--chat-text-muted);
    opacity: 0.5;
    background: var(--chat-surface);
}

/* ==========================================
   MOBILE RESPONSIVE
   ========================================== */
@media (max-width: 480px) {
    .chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    .chat-window.is-visible {
        transform: translateY(0) scale(1);
    }
    .chat-trigger {
        bottom: 90px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
}
