/* --- Variables & Reset --- */
/* :root {
    --fr-primary-start: #185AFE;
    --fr-primary-end: #C766EF;
    --fr-primary-color: var(--fr-primary-start);

    --fr-bg-light: #1a1a2e;
    --fr-white: #16213e;
    --fr-text-dark: #e0e0e0;
    --fr-text-gray: #a0a0b0;
    --fr-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
    --fr-radius: 16px;
    --fr-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;

    --fr-header-bg: linear-gradient(135deg, #202049 0%, #0b0b63 100%);
    --fr-footer-bg: #16213e;
    --fr-input-bg: #1a1a2e;
    --fr-input-border: #2a2a4a;
    --fr-scrollbar: #2a2a4a;
    --fr-message-ai-bg: #1e1e3a;
    --fr-border: #2a2a4a;
} */

:root {
    --fr-primary-start: #185AFE;
    --fr-primary-end: #C766EF;
    --fr-primary-color: var(--fr-primary-start);

    --fr-bg-light: #f4f6f9;
    --fr-white: #ffffff;
    --fr-text-dark: #333333;
    --fr-text-gray: #666666;
    --fr-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
    --fr-radius: 16px;
    --fr-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;

    --fr-light-start: color-mix(in srgb, var(--fr-primary-start), white 90%);
    --fr-light-end: color-mix(in srgb, var(--fr-primary-end), white 90%);

    --fr-header-bg: linear-gradient(135deg, var(--fr-light-start) 0%, var(--fr-light-end) 100%);
    --fr-footer-bg: #ffffff;
    --fr-input-bg: #f9f9f9;
    --fr-input-border: #e0e0e0;
    --fr-scrollbar: #cccccc;
    --fr-message-ai-bg: #ffffff;
    --fr-border: #eeeeee;
}

/* Scoped Reset */
.fr-chat-window *,
.fr-chat-launcher * {
    box-sizing: border-box;
    font-family: var(--fr-font);
}

.fr-typing-cursor::after {
    content: '|';
    display: inline-block;
    animation: blink 0.7s step-end infinite;
    color: var(--fr-primary-end);
    font-weight: 300;
    margin-left: 1px;
}

.fr-message-ai ul,
.fr-message-ai ol {
    margin: 6px 0 0 0;
    padding-left: 18px;
}

.fr-message-ai li {
    margin-bottom: 4px;
    line-height: 1.5;
}

.fr-message-ai p {
    margin: 0 0 6px 0;
}

.fr-message-ai p:last-child {
    margin-bottom: 0;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}
.fr-chat-launcher {
    position: fixed;
    bottom: 15px;
    z-index: 99999;
    height: 48px;
    padding: 0 16px 0 8px;
    border-radius: 30px;
    
    /* 1. Set a transparent border */
    border: 1px solid transparent; 
    
    /* 2. Layer 1: Solid White background (clipto content) 
       2. Layer 2: The Gradient border (clipto border box) */
    background: 
        linear-gradient(#fff, #fff) padding-box, 
        linear-gradient(90deg, #e2e8f0, #e2e8f0) border-box; 
    
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* --- The Hover State: Only animates the border-box layer --- */
.fr-chat-launcher:hover {
    background: 
        linear-gradient(#fff, #fff) padding-box, 
        linear-gradient(90deg, var(--fr-primary-start), var(--fr-primary-end), var(--fr-primary-start)) border-box;
    
    background-size: 100% 100%, 200% 100%; /* Second value is for the gradient */
    animation: border-march 2s linear infinite;
}

@keyframes border-march {
    from { background-position: 0 0, 0 0; }
    to { background-position: 0 0, 200% 0; }
}

.fr-chat-launcher.fr-position-right {
    right: 15px;
}

.fr-chat-launcher.fr-position-left {
    left: 15px;
}

/* Smaller Purple Avatar */
.fr-launcher-avatar {
    width: 32px;
    /* Reduced from 40px */
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.27);

    background: linear-gradient(125deg,
            var(--fr-primary-start) 0%,
            var(--fr-primary-end) 25%,
            var(--fr-primary-start) 50%,
            var(--fr-primary-end) 75%,
            var(--fr-primary-start) 100%);
    background-size: 400% 400%;
    animation: ai-move 6s ease-in-out infinite;
}

/* Compact Text Container */
.fr-launcher-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    line-height: 1.1;
}

.fr-launcher-title {
    font-size: 13px;
    /* Smaller font */
    font-weight: 600;
    color: #1f2937;
    /* Dark text for light mode */
}

.fr-launcher-subtitle {
    font-size: 11px;
    font-weight: 400;
    color: #6b7280;
    /* Muted gray guide text */
}

/* --- Chat Window Container --- */
.fr-chat-window {
    position: fixed;
    bottom: 80px;
    width: 380px;
    height: 550px;
    max-height: calc(100vh - 120px);
    max-width: calc(100vw - 50px);
    background: var(--fr-white);
    border-radius: var(--fr-radius);
    box-shadow: var(--fr-shadow);
    border: 1px solid var(--fr-border);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: frFadeInUp 0.3s ease;
}

.fr-chat-window.fr-position-right {
    right: 25px;
}

.fr-chat-window.fr-position-left {
    left: 25px;
}

/* --- Header --- */
.fr-chat-header {
    position: relative;
    background: var(--fr-header-bg);
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    border-bottom: 1px solid var(--fr-border);
}

.fr-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fr-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.fr-header-title h5 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--fr-text-dark);
    line-height: 1;
}

.fr-header-subtitle {
    font-size: 11px;
    color: var(--fr-text-gray);
    font-weight: 400;
    line-height: 1;
}

.fr-ai-profile {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    animation: ai-rotate 4s linear infinite;
}

.fr-header-controls {
    display: flex;
    gap: 10px;
}

.fr-btn-icon {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--fr-text-dark);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
}

.fr-btn-icon:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* --- Body (Messages) --- */
.fr-chat-body {
    flex: 1;
    background: var(--fr-bg-light);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.fr-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

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

.fr-chat-body::-webkit-scrollbar-thumb:hover {
    background: #3a3a5a;
}

.fr-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    animation: messageSlideIn 0.3s ease;
}

.fr-message-ai {
    background: var(--fr-message-ai-bg);
    color: var(--fr-text-dark);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--fr-border);
}

.fr-message-user {
    background: linear-gradient(125deg,
            var(--fr-primary-start),
            var(--fr-primary-end));
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.fr-message a {
    color: inherit;
    text-decoration: underline;
    font-weight: bold;
}

.fr-message-user a {
    color: white;
}

/* --- Footer (Input) --- */
.fr-chat-footer {
    padding: 15px;
    background: var(--fr-footer-bg);
    border-top: 1px solid var(--fr-border);
}

#frChatForm {
    display: flex;
    gap: 10px;
    align-items: center;
}

#frChatInput {
    flex: 1;
    border: 1px solid var(--fr-input-border);
    border-radius: 25px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    background: var(--fr-input-bg);
    color: var(--fr-text-dark);
}

#frChatInput::placeholder {
    color: var(--fr-text-gray);
}

#frChatInput:focus {
    border-color: var(--fr-primary-start);
    background: var(--fr-input-bg);
}

#frChatInput:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#frSendBtn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--fr-primary-start), var(--fr-primary-end));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    padding: 0;
}

#frSendBtn:hover:not(:disabled) {
    transform: scale(1.05);
}

#frSendBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#frSendBtn svg {
    width: 20px;
    height: 20px;
    margin-left: -2px;
}

.fr-powered-by {
    text-align: center;
    font-size: 10px;
    color: var(--fr-text-gray);
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fr-powered-by a {
    font-size: 10px;
    color: var(--fr-text-gray);
    margin-top: 8px;
    text-transform: uppercase;
    text-decoration: underline;
    letter-spacing: 0.5px;
}


/* --- Mobile --- */
@media (max-width: 480px) {
    
    .fr-chat-window {
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        max-width: 100vw;
        bottom: 0;
        right: 0 !important;
        left: 0 !important;
        border-radius: 0;
        top: 0;
    }

    .fr-chat-header {
        padding-top: calc(env(safe-area-inset-top, 0px) + 15px);
        padding-bottom: 15px;
        height: auto;
        min-height: 70px;
        display: flex;
        align-items: center;
    }

    .fr-chat-body {
        padding-bottom: 20px;
    }
}

/* Print */
@media print {

    .fr-chat-launcher,
    .fr-chat-window {
        display: none !important;
    }
}

/* --- Keyframes --- */
@keyframes ai-move {
    0% {
        background-position: 0% 50%;
    }

    25% {
        background-position: 100% 0%;
    }

    50% {
        background-position: 100% 100%;
    }

    75% {
        background-position: 0% 100%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes ai-rotate {
    0% {
        transform: rotate(0deg);
        box-shadow:
            0 4px 8px 0 #fff inset,
            0 8px 16px 0 var(--fr-primary-end) inset,
            0 0 40px 20px var(--fr-primary-start) inset;
    }

    50% {
        transform: rotate(180deg);
        box-shadow:
            0 4px 8px 0 #fff inset,
            0 8px 16px 0 var(--fr-primary-start) inset,
            0 0 40px 20px var(--fr-primary-end) inset;
    }

    100% {
        transform: rotate(360deg);
        box-shadow:
            0 4px 8px 0 #fff inset,
            0 8px 16px 0 var(--fr-primary-end) inset,
            0 0 40px 20px var(--fr-primary-start) inset;
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes frFadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}