/* =============================================================
   CHUMS MEDIA HOUSE — Virtual Production Assistant (Chatbot)
   All selectors are strictly scoped to #chums-chat-* IDs.
   NO base HTML tag overrides. Fully isolated from site layout.
   ============================================================= */

/* ── FAB (Floating Action Button) ─────────────────────────── */
#chums-chat-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9990;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #F2A93B;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 0 0 0 rgba(242, 169, 59, 0.5),
        0 8px 32px rgba(0, 0, 0, 0.6);
    transition: background 0.3s ease, transform 0.2s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

#chums-chat-fab:hover {
    background: #fff;
    transform: scale(1.08);
}

#chums-chat-fab:hover svg {
    color: #F2A93B !important;
}

/* Icon wrapper spans — must be flex so inline-block whitespace doesn't offset the SVG */
#chums-fab-icon-open,
#chums-fab-icon-close {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

/* Pulse ring animation on FAB */
#chums-chat-fab::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(242, 169, 59, 0.6);
    animation: chums-pulse 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes chums-pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50%       { transform: scale(1.45); opacity: 0; }
}

/* Badge notification dot */
#chums-chat-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 13px;
    height: 13px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #050505;
    animation: chums-badge-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes chums-badge-pop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* ── Chat Window ───────────────────────────────────────────── */
#chums-chat-window {
    position: fixed;
    bottom: 104px;
    right: 28px;
    z-index: 9991;
    width: 380px;
    max-height: 600px;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #0f0f0f;
    border: 1px solid rgba(242, 169, 59, 0.18);
    box-shadow:
        0 32px 80px rgba(0, 0, 0, 0.85),
        0 0 0 1px rgba(255, 255, 255, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);

    /* Hidden by default — GSAP controls visibility */
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    transform-origin: bottom right;
}

#chums-chat-window.chums-open {
    visibility: visible;
    pointer-events: all;
}

/* Film grain overlay inside window */
#chums-chat-window::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    opacity: 0.035;
    background-image: url('data:image/svg+xml;utf8,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="n"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.75" numOctaves="4" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23n)"/%3E%3C/svg%3E');
    border-radius: 20px;
}

/* ── Header ────────────────────────────────────────────────── */
#chums-chat-header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #161616 0%, #111111 100%);
    border-bottom: 1px solid rgba(242, 169, 59, 0.15);
    flex-shrink: 0;
}

#chums-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#chums-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #F2A93B, #D98F26);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 16px rgba(242, 169, 59, 0.3);
}

#chums-chat-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: #ffffff;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 1.2;
}

#chums-chat-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    color: #888;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}

#chums-chat-online-dot {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
    animation: chums-online-pulse 2s ease-in-out infinite;
}

@keyframes chums-online-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

#chums-chat-close-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #999;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

#chums-chat-close-btn:hover {
    background: rgba(242, 169, 59, 0.12);
    color: #F2A93B;
    transform: rotate(90deg);
}

/* ── Messages Area ─────────────────────────────────────────── */
#chums-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    max-height: 380px;
    position: relative;
    z-index: 1;
}

/* Custom scrollbar inside message area */
#chums-chat-messages::-webkit-scrollbar {
    width: 4px;
}
#chums-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
#chums-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(242, 169, 59, 0.25);
    border-radius: 2px;
}
#chums-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(242, 169, 59, 0.5);
}

/* ── Message Bubbles ───────────────────────────────────────── */
.chums-msg-row {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: chums-msg-in 0.35s cubic-bezier(0.34, 1.26, 0.64, 1) both;
}

@keyframes chums-msg-in {
    from { opacity: 0; transform: translateY(10px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

.chums-msg-row.chums-user {
    align-self: flex-end;
    align-items: flex-end;
}

.chums-bubble {
    padding: 11px 15px;
    border-radius: 16px;
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}

/* Bot bubble */
.chums-msg-row.chums-bot .chums-bubble {
    background: #1a1a1a;
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom-left-radius: 4px;
}

/* User bubble */
.chums-msg-row.chums-user .chums-bubble {
    background: linear-gradient(135deg, #F2A93B, #D98F26);
    color: #000;
    font-weight: 500;
    border-bottom-right-radius: 4px;
}

.chums-msg-time {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    color: #555;
    margin-top: 4px;
    padding: 0 4px;
}

/* ── Typing Indicator ──────────────────────────────────────── */
#chums-typing-row {
    display: flex;
    align-items: flex-start;
    animation: chums-msg-in 0.35s cubic-bezier(0.34, 1.26, 0.64, 1) both;
}

#chums-typing-bubble {
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chums-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #F2A93B;
    animation: chums-typing-bounce 1.2s ease-in-out infinite;
}

.chums-typing-dot:nth-child(1) { animation-delay: 0s; }
.chums-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.chums-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes chums-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Quick Reply Chips ─────────────────────────────────────── */
#chums-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 12px;
    position: relative;
    z-index: 1;
}

.chums-chip {
    font-family: 'Inter', sans-serif;
    font-size: 11.5px;
    font-weight: 500;
    color: #F2A93B;
    background: rgba(242, 169, 59, 0.08);
    border: 1px solid rgba(242, 169, 59, 0.25);
    border-radius: 100px;
    padding: 6px 13px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    animation: chums-msg-in 0.4s cubic-bezier(0.34, 1.26, 0.64, 1) both;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chums-chip-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    opacity: 0.85;
}

.chums-chip-label {
    line-height: 1;
}

.chums-chip:hover {
    background: rgba(242, 169, 59, 0.16);
    border-color: rgba(242, 169, 59, 0.5);
    transform: translateY(-2px);
}

/* ── Input Area ────────────────────────────────────────────── */
#chums-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 16px;
    background: #111111;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

#chums-chat-input {
    flex: 1;
    background: #1c1c1c;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 14px;
    color: #e0e0e0;
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    min-height: 42px;
    max-height: 110px;
    overflow-y: auto;
    -webkit-appearance: none;
}

#chums-chat-input::placeholder {
    color: #555;
}

#chums-chat-input:focus {
    border-color: rgba(242, 169, 59, 0.45);
    box-shadow: 0 0 0 3px rgba(242, 169, 59, 0.08);
}

#chums-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #F2A93B;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

#chums-send-btn:hover {
    background: #fff;
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(242, 169, 59, 0.3);
}

#chums-send-btn:hover svg {
    color: #F2A93B !important;
}

#chums-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ── Mobile — fullscreen ───────────────────────────────────── */
@media (max-width: 480px) {
    #chums-chat-window {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 100dvh;
        border-radius: 20px 20px 0 0;
        transform-origin: bottom center !important;
    }

    #chums-chat-fab {
        bottom: 20px;
        right: 20px;
    }

    #chums-chat-messages {
        max-height: calc(100dvh - 200px);
    }
}
