/* ===========================================
   Felix Chatbot — Premium Light Theme
   WicFlow 2026
   =========================================== */

:root {
    /* Brand */
    --felix-accent: #7c3aed;
    --felix-accent-hover: #6d28d9;
    --felix-accent-light: #f5f3ff;
    --felix-accent-subtle: rgba(124, 58, 237, 0.06);
    --felix-gradient: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    --felix-gradient-dark: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #3b1d8e 100%);

    /* Surfaces */
    --felix-bg-window: #ffffff;
    --felix-bg-messages: #f9fafb;
    --felix-bg-bot: #f3f4f6;
    --felix-bg-user: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);

    /* Text */
    --felix-text: #111827;
    --felix-text-secondary: #4b5563;
    --felix-text-muted: #9ca3af;
    --felix-text-on-accent: #ffffff;

    /* Borders & Shadows */
    --felix-border: #e5e7eb;
    --felix-border-subtle: #f3f4f6;
    --felix-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --felix-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    --felix-shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.10), 0 4px 12px rgba(0, 0, 0, 0.04);
    --felix-shadow-window: 0 24px 64px rgba(0, 0, 0, 0.14), 0 8px 24px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.03);

    /* Typography */
    --felix-font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ---- Chat Bubble (Toggle) ---- */

.felix-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--felix-gradient);
    border: none;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.25),
                0 8px 40px rgba(99, 102, 241, 0.15),
                0 0 0 3px rgba(255, 255, 255, 0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease;
    animation: felix-breathe 4s ease-in-out infinite;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    padding: 0;
}

.felix-bubble img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.felix-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(124, 58, 237, 0.35),
                0 12px 48px rgba(99, 102, 241, 0.2),
                0 0 0 3px rgba(255, 255, 255, 0.95);
}

.felix-bubble:active {
    transform: scale(0.95);
}

.felix-bubble.hidden {
    display: none;
}

@keyframes felix-breathe {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(124, 58, 237, 0.25),
                    0 8px 40px rgba(99, 102, 241, 0.15),
                    0 0 0 3px rgba(255, 255, 255, 0.9);
    }
    50% {
        box-shadow: 0 6px 28px rgba(124, 58, 237, 0.35),
                    0 12px 48px rgba(99, 102, 241, 0.2),
                    0 0 0 3px rgba(255, 255, 255, 0.95);
    }
}

/* Notification badge */
.felix-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    z-index: 3;
    animation: felix-badge-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes felix-badge-pop {
    0% { transform: scale(0); }
    70% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ---- Teaser Message ---- */

.felix-teaser {
    position: fixed;
    bottom: 98px;
    right: 24px;
    background: #ffffff;
    border: none;
    border-radius: 16px 16px 4px 16px;
    padding: 14px 18px;
    max-width: 270px;
    z-index: 10000;
    opacity: 0;
    transform: translateY(8px) scale(0.97);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
    font-family: var(--felix-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--felix-text-secondary);
    box-shadow: var(--felix-shadow-lg);
}

.felix-teaser.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.felix-teaser .teaser-name {
    font-weight: 600;
    color: var(--felix-accent);
    font-size: 11px;
    margin-bottom: 4px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.teaser-close {
    position: absolute;
    top: 6px;
    right: 10px;
    background: none;
    border: none;
    color: var(--felix-text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
}

.teaser-close:hover {
    color: var(--felix-text-secondary);
}

/* ---- Social Proof / CTA Nudge ---- */

.felix-social-proof {
    position: fixed;
    bottom: 100px;
    left: 24px;
    background: #ffffff;
    border: none;
    border-radius: 16px;
    padding: 14px 18px 14px 16px;
    max-width: 320px;
    z-index: 9999;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    opacity: 0;
    transform: translateX(-20px) scale(0.95);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: var(--felix-font);
    box-shadow: var(--felix-shadow-lg);
}

.felix-social-proof.visible {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: all;
}

.felix-social-proof-icon {
    width: 38px;
    height: 38px;
    background: var(--felix-accent-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.felix-social-proof-content {
    flex: 1;
    min-width: 0;
}

.felix-social-proof-title {
    font-weight: 600;
    color: var(--felix-text);
    font-size: 13px;
    margin-bottom: 2px;
}

.felix-social-proof-text {
    font-size: 12px;
    color: var(--felix-text-secondary);
    line-height: 1.4;
}

.felix-social-proof-time {
    font-size: 12px;
    color: var(--felix-accent);
    font-weight: 600;
    margin-top: 4px;
    cursor: pointer;
}

.felix-social-proof-time:hover {
    text-decoration: underline;
}

.felix-social-proof-close {
    position: absolute;
    top: 6px;
    right: 10px;
    background: none;
    border: none;
    color: var(--felix-text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
}

.felix-social-proof-close:hover {
    color: var(--felix-text-secondary);
}

/* ---- Chat Window ---- */

.felix-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 400px;
    height: 620px;
    max-height: calc(100vh - 48px);
    background: var(--felix-bg-window);
    border: none;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    z-index: 10001;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.95);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: var(--felix-shadow-window);
    font-family: var(--felix-font);
}

.felix-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ---- Header ---- */

.felix-header {
    padding: 18px 20px;
    background: var(--felix-gradient-dark);
    border-bottom: none;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
}

.felix-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.felix-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.felix-avatar::after {
    display: none;
}

.felix-header-info {
    flex: 1;
    min-width: 0;
}

.felix-header-name {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
}

.felix-header-status {
    font-size: 12px;
    color: #4ade80;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.felix-header-status span {
    font-size: 8px;
}

/* Language flags */
.felix-lang-flags {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.felix-lang-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.felix-lang-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.felix-lang-btn.active {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.18);
}

/* Close button */
.felix-close {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.felix-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
}

/* ---- Messages ---- */

.felix-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
    background: var(--felix-bg-messages);
}

.felix-messages::-webkit-scrollbar {
    width: 4px;
}

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

.felix-messages::-webkit-scrollbar-thumb {
    background: var(--felix-border);
    border-radius: 4px;
}

/* Message row (bot messages with avatar) */
.felix-msg-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 85%;
}

.felix-msg-row.bot {
    align-self: flex-start;
}

.felix-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.felix-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Message bubbles */
.felix-msg {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    animation: felix-msg-in 0.35s ease-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.felix-msg.bot {
    background: var(--felix-bg-bot);
    color: var(--felix-text);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.felix-msg.user {
    align-self: flex-end;
    background: var(--felix-bg-user);
    color: var(--felix-text-on-accent);
    border-bottom-right-radius: 6px;
    max-width: 85%;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.15);
}

/* Links */
.felix-msg a {
    color: var(--felix-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: rgba(124, 58, 237, 0.3);
    font-weight: 500;
    transition: text-decoration-color 0.2s;
}

.felix-msg a:hover {
    text-decoration-color: var(--felix-accent);
}

.felix-msg.user a {
    color: #e8deff;
    text-decoration-color: rgba(232, 222, 255, 0.4);
}

/* Bold text */
.felix-msg strong {
    font-weight: 600;
}

.felix-msg.user strong {
    color: #f0e6ff;
}

@keyframes felix-msg-in {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ---- Typing Indicator ---- */

.felix-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px;
    background: var(--felix-bg-bot);
    border-radius: 18px 18px 18px 6px;
    animation: felix-msg-in 0.3s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.felix-typing span {
    width: 6px;
    height: 6px;
    background: var(--felix-accent);
    border-radius: 50%;
    animation: felix-typing-pulse 1.4s ease-in-out infinite;
    opacity: 0.5;
}

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

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

@keyframes felix-typing-pulse {
    0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
    30% { opacity: 0.8; transform: scale(1.2); }
}

/* ---- Quick Replies ---- */

#quickRepliesContainer {
    flex-shrink: 0;
    background: var(--felix-bg-messages);
}

.felix-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 20px 12px;
}

.felix-quick-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1.5px solid var(--felix-border);
    background: var(--felix-bg-window);
    color: var(--felix-text-secondary);
    font-size: 13px;
    font-family: var(--felix-font);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.felix-quick-btn:hover {
    background: var(--felix-accent-light);
    border-color: rgba(124, 58, 237, 0.3);
    color: var(--felix-accent);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.08);
}

.felix-quick-btn:active {
    transform: scale(0.97);
}

/* ---- Input Area ---- */

.felix-input-area {
    padding: 14px 16px;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--felix-bg-window);
    flex-shrink: 0;
}

.felix-input {
    flex: 1;
    padding: 11px 16px;
    border-radius: 14px;
    border: 1.5px solid var(--felix-border);
    background: var(--felix-bg-messages);
    color: var(--felix-text);
    font-size: 14px;
    font-family: var(--felix-font);
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    resize: none;
    max-height: 100px;
    min-height: 44px;
    line-height: 1.4;
}

.felix-input:focus {
    border-color: var(--felix-accent);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.08),
                0 2px 8px rgba(124, 58, 237, 0.06);
}

.felix-input::placeholder {
    color: var(--felix-text-muted);
}

.felix-send {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    border: none;
    background: var(--felix-gradient);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.2);
}

.felix-send svg {
    width: 18px;
    height: 18px;
}

.felix-send:hover {
    background: var(--felix-gradient);
    transform: scale(1.05);
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.3);
    filter: brightness(1.08);
}

.felix-send:active {
    transform: scale(0.95);
}

.felix-send:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

/* ---- Powered By ---- */

.felix-powered {
    text-align: center;
    padding: 8px;
    font-size: 11px;
    color: var(--felix-text-muted);
    letter-spacing: 0.03em;
    flex-shrink: 0;
    font-family: var(--felix-font);
    opacity: 0.7;
}

.felix-powered a {
    color: var(--felix-accent);
    text-decoration: none;
    font-weight: 500;
}

.felix-powered a:hover {
    color: var(--felix-accent-hover);
}

/* ============ MOBILE ============ */

@media (max-width: 480px) {
    .felix-bubble {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .felix-window {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
    }

    .felix-header {
        padding-top: max(16px, env(safe-area-inset-top, 0px));
    }

    .felix-messages {
        padding: 16px;
    }

    .felix-input {
        font-size: 16px;
    }

    .felix-close {
        width: 40px;
        height: 40px;
    }

    .felix-lang-btn {
        width: 34px;
        height: 34px;
    }

    .felix-send {
        width: 48px;
        height: 48px;
    }

    .felix-quick-btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .felix-msg {
        font-size: 15px;
    }

    .felix-teaser {
        bottom: 82px;
        right: 16px;
    }

    .felix-social-proof {
        bottom: 82px;
        left: 16px;
        right: 16px;
        max-width: none;
    }

    .felix-bubble:hover {
        transform: none;
    }

    .felix-quick-btn:hover {
        background: var(--felix-bg-window);
        border-color: var(--felix-border);
        color: var(--felix-text-secondary);
    }

    .felix-quick-btn:active {
        background: var(--felix-accent-light);
        border-color: var(--felix-accent);
        color: var(--felix-accent);
        transform: scale(0.97);
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .felix-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .felix-bubble,
    .felix-window,
    .felix-msg,
    .felix-teaser,
    .felix-social-proof,
    .felix-typing span {
        animation: none !important;
        transition: none !important;
    }
}
