/* BrightFlixx public AI chat widget — cinematic navy / brand red (no purple AI cliché). */

.visually-hidden,
.bf-ai-chat__hp {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

.bf-ai-chat__consent-hint {
    margin: 0;
    padding: 0 1rem 0.65rem;
    font-size: 0.68rem;
    line-height: 1.4;
    color: rgba(232, 69, 61, 0.9);
    background: rgba(0, 0, 0, 0.25);
}

.bf-ai-chat__consent-hint[hidden] { display: none; }

.bf-ai-chat {
    --bf-ai-z: 208;
    --bf-ai-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    --bf-ai-end: calc(1.25rem + env(safe-area-inset-right, 0px));
    position: fixed;
    inset-block-end: var(--bf-ai-bottom);
    inset-inline-end: var(--bf-ai-end);
    z-index: var(--bf-ai-z);
    font-family: var(--font-body, var(--font-sans));
    color: var(--text-invert, #f5f5f7);
}

body.bf-cookie-open .bf-ai-chat {
    --bf-ai-bottom: calc(5.75rem + env(safe-area-inset-bottom, 0px));
}

body.nav-open .bf-ai-chat {
    visibility: hidden;
    pointer-events: none;
}

.bf-ai-chat__launcher {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.7rem 1.05rem 0.7rem 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: linear-gradient(145deg, var(--navy-700, #16161c) 0%, var(--navy-900, #050507) 100%);
    color: #fff;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(209, 36, 33, 0.18);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    letter-spacing: 0.01em;
    transition: transform 0.25s var(--ease, ease), box-shadow 0.25s var(--ease, ease), border-color 0.2s;
}

.bf-ai-chat__launcher:hover {
    border-color: rgba(232, 69, 61, 0.55);
    transform: translateY(-2px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(209, 36, 33, 0.22);
}

.bf-ai-chat__launcher:focus-visible {
    outline: 2px solid var(--red-400, #e8453d);
    outline-offset: 3px;
}

.bf-ai-chat__launcher-icon {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--red-500, #d12421), var(--red-700, #8b1418));
    color: #fff;
    flex-shrink: 0;
}

.bf-ai-chat.is-open .bf-ai-chat__launcher {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92);
}

.bf-ai-chat__panel {
    position: absolute;
    inset-inline-end: 0;
    inset-block-end: 0;
    display: flex;
    flex-direction: column;
    width: min(400px, calc(100vw - 1.5rem));
    height: min(640px, calc(100dvh - 2rem - env(safe-area-inset-bottom, 0px)));
    max-height: calc(100dvh - 1.5rem - env(safe-area-inset-bottom, 0px));
    border-radius: 20px;
    overflow: hidden;
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(209, 36, 33, 0.18), transparent 55%),
        linear-gradient(165deg, #121218 0%, #0a0a0e 55%, #050507 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 28px 64px rgba(0, 0, 0, 0.5);
    transform-origin: bottom right;
    animation: bf-ai-panel-in 0.32s var(--ease-spring, cubic-bezier(0.22, 1, 0.36, 1));
}

.bf-ai-chat__panel[hidden] { display: none; }

@keyframes bf-ai-panel-in {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .bf-ai-chat__launcher,
    .bf-ai-chat__panel { transition: none; animation: none; }
    .bf-ai-chat__typing-dots i { animation: none !important; opacity: 0.7; }
}

.bf-ai-chat__chrome {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1rem 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}

.bf-ai-chat__brand {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    min-width: 0;
}

.bf-ai-chat__mark {
    display: grid;
    place-items: center;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 10px;
    background: linear-gradient(145deg, var(--red-500), var(--red-700));
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.bf-ai-chat__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
    font-family: var(--font-heading, var(--font-display));
}

.bf-ai-chat__subtitle {
    margin: 0.15rem 0 0;
    font-size: 0.78rem;
    color: var(--text-invert-muted, #a1a1a6);
    line-height: 1.35;
}

.bf-ai-chat__toolbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.bf-ai-chat__icon-btn {
    display: grid;
    place-items: center;
    width: 2.15rem;
    height: 2.15rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-invert-muted, #a1a1a6);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.bf-ai-chat__icon-btn:hover,
.bf-ai-chat__icon-btn:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    outline: none;
}

.bf-ai-chat__icon-btn:focus-visible {
    box-shadow: 0 0 0 2px rgba(232, 69, 61, 0.65);
}

.bf-ai-chat__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding: 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(209, 36, 33, 0.45) transparent;
}

.bf-ai-chat__welcome-text {
    margin: 0 0 0.85rem;
    font-size: 0.95rem;
    line-height: 1.55;
    color: rgba(245, 245, 247, 0.92);
}

.bf-ai-chat__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-block-end: 0.5rem;
}

.bf-ai-chat__suggestion {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: #f5f5f7;
    border-radius: 999px;
    padding: 0.45rem 0.8rem;
    font: inherit;
    font-size: 0.8rem;
    line-height: 1.35;
    text-align: start;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.bf-ai-chat__suggestion:hover,
.bf-ai-chat__suggestion:focus-visible {
    border-color: rgba(232, 69, 61, 0.55);
    background: rgba(209, 36, 33, 0.14);
    color: #fff;
    outline: none;
}

.bf-ai-chat__messages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bf-ai-chat__bubble {
    max-width: 92%;
    padding: 0.7rem 0.9rem;
    border-radius: 14px;
    font-size: 0.92rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.bf-ai-chat__bubble--user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--red-500), var(--red-600));
    color: #fff;
    border-bottom-right-radius: 5px;
}

.bf-ai-chat__bubble--assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #f5f5f7;
    border-bottom-left-radius: 5px;
}

.bf-ai-chat__bubble--error {
    align-self: stretch;
    background: rgba(209, 36, 33, 0.12);
    border: 1px solid rgba(232, 69, 61, 0.35);
    color: #ffd4d1;
    font-size: 0.85rem;
}

.bf-ai-chat__actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-block-start: 0.55rem;
}

.bf-ai-chat__action {
    display: block;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    transition: border-color 0.15s, background 0.15s;
}

.bf-ai-chat__action:hover,
.bf-ai-chat__action:focus-visible {
    border-color: rgba(232, 69, 61, 0.5);
    background: rgba(209, 36, 33, 0.16);
    color: #fff;
    outline: none;
}

.bf-ai-chat__feedback {
    display: flex;
    gap: 0.35rem;
    margin-block-start: 0.45rem;
}

.bf-ai-chat__feedback-btn {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: transparent;
    color: var(--text-invert-muted);
    border-radius: 8px;
    padding: 0.25rem 0.45rem;
    font-size: 0.75rem;
    cursor: pointer;
}

.bf-ai-chat__feedback-btn:hover,
.bf-ai-chat__feedback-btn:focus-visible,
.bf-ai-chat__feedback-btn[aria-pressed="true"] {
    color: #fff;
    border-color: rgba(232, 69, 61, 0.45);
    outline: none;
}

.bf-ai-chat__typing {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-block-start: 0.75rem;
    color: var(--text-invert-muted);
    font-size: 0.82rem;
}

.bf-ai-chat__typing[hidden] { display: none; }

.bf-ai-chat__typing-dots {
    display: inline-flex;
    gap: 0.22rem;
    align-items: center;
}

.bf-ai-chat__typing-dots i {
    display: block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--red-400, #e8453d);
    animation: bf-ai-dot 1.05s ease-in-out infinite;
}

.bf-ai-chat__typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.bf-ai-chat__typing-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes bf-ai-dot {
    0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.bf-ai-chat__composer {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 0.85rem 0.35rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.25);
}

.bf-ai-chat__input {
    flex: 1;
    min-height: 2.6rem;
    max-height: 7.5rem;
    resize: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    padding: 0.7rem 0.85rem;
    font: inherit;
    font-size: 0.92rem;
    line-height: 1.4;
    field-sizing: content;
}

.bf-ai-chat__input::placeholder { color: rgba(161, 161, 166, 0.85); }

.bf-ai-chat__input:focus {
    outline: none;
    border-color: rgba(232, 69, 61, 0.55);
    box-shadow: 0 0 0 3px rgba(209, 36, 33, 0.18);
}

.bf-ai-chat__send {
    display: grid;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    flex-shrink: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--red-500), var(--red-600));
    color: #fff;
    cursor: pointer;
    box-shadow: var(--shadow-red, 0 8px 24px rgba(209, 36, 33, 0.22));
    transition: transform 0.2s, filter 0.2s;
}

.bf-ai-chat__send:hover { transform: translateY(-1px); }
.bf-ai-chat__send:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}
.bf-ai-chat__send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.bf-ai-chat__disclaimer {
    margin: 0;
    padding: 0 1rem 0.75rem;
    font-size: 0.68rem;
    line-height: 1.4;
    color: rgba(161, 161, 166, 0.9);
    background: rgba(0, 0, 0, 0.25);
}

/* Full-bleed mobile sheet */
@media (max-width: 540px) {
    .bf-ai-chat {
        --bf-ai-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
        --bf-ai-end: calc(0.85rem + env(safe-area-inset-right, 0px));
    }

    body.bf-cookie-open .bf-ai-chat {
        --bf-ai-bottom: calc(7.25rem + env(safe-area-inset-bottom, 0px));
    }

    .bf-ai-chat.is-open {
        inset: 0;
        --bf-ai-bottom: 0;
        --bf-ai-end: 0;
        z-index: 220;
    }

    .bf-ai-chat.is-open .bf-ai-chat__panel {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        border: 0;
        animation: none;
    }

    .bf-ai-chat__launcher-label { display: none; }
    .bf-ai-chat__launcher { padding: 0.65rem; }
}

html[dir="rtl"] .bf-ai-chat__panel {
    transform-origin: bottom left;
}

html[dir="rtl"] .bf-ai-chat__bubble--user {
    border-bottom-right-radius: 14px;
    border-bottom-left-radius: 5px;
}

html[dir="rtl"] .bf-ai-chat__bubble--assistant {
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 5px;
}

body.bf-ai-open {
    overflow: hidden;
}

@media (min-width: 541px) {
    body.bf-ai-open { overflow: auto; }
}
