/* === THELIS CHAT WIDGET — v1.3.1 === */

@keyframes tc-enter {
    from { transform: translateY(-50%) translateX(56px); opacity: 0; }
    to   { transform: translateY(-50%) translateX(0);    opacity: 1; }
}
@keyframes tc-pulse {
    0%, 100% { transform: scale(1);   opacity: 1;   }
    50%       { transform: scale(1.6); opacity: 0.4; }
}
@keyframes tc-spin {
    to { transform: rotate(360deg); }
}
@keyframes tc-panel-in {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: translateX(0); }
}


/* ── Tab Handle ─────────────────────────────────────────────────────────── */

#thelis-chat-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000001;

    width: 46px;
    height: 210px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;

    background: #111118;
    border: none;
    border-left: 2px solid #E8294A;
    border-radius: 4px 0 0 4px;
    box-shadow: -4px 0 32px rgba(0,0,0,0.65), -2px 0 12px rgba(232,41,74,0.08);
    cursor: pointer;
    padding: 0;
    overflow: hidden;

    transition:
        transform  0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        background 0.25s ease,
        opacity    0.25s ease;
    animation: tc-enter 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) 0.8s both;
}

#thelis-chat-tab:hover {
    transform: translateY(-50%) translateX(-8px);
    background: #16161f;
    box-shadow: -6px 0 40px rgba(0,0,0,0.75), -4px 0 20px rgba(232,41,74,0.20);
}

#thelis-chat-tab .tc-dot {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #E8294A;
    flex-shrink: 0;
    animation: tc-pulse 2.6s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(232,41,74,0.7);
}

#thelis-chat-tab .tc-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.38);
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    line-height: 1;
    pointer-events: none;
    transition: color 0.25s ease;
}

#thelis-chat-tab:hover .tc-label { color: rgba(255,255,255,0.65); }

#thelis-chat-tab.is-hidden {
    transform: translateY(-50%) translateX(80px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}


/* ── Backdrop ───────────────────────────────────────────────────────────── */

#thelis-chat-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.48);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999997;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

#thelis-chat-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
}


/* ── Panel — floating card ───────────────────────────────────────────────── */

#thelis-chat-panel {
    position: fixed;
    right: 0;
    top: 16px;
    width: 360px;
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);

    background: #111118;
    border-top: 3px solid #E8294A;
    border-left: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px 0 0 0;
    box-shadow:
        -12px 0 80px rgba(0,0,0,0.85),
        -2px 0 0 rgba(232,41,74,0.12);

    display: flex;
    flex-direction: column;
    overflow: hidden;

    transform: translateX(360px);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 999999;
}

#thelis-chat-panel.is-open {
    transform: translateX(0);
}

/* Left-edge glow */
#thelis-chat-panel::after {
    content: '';
    position: absolute;
    top: 0; left: -1px; bottom: 0;
    width: 1px;
    background: linear-gradient(
        to bottom,
        rgba(232,41,74,0.60),
        rgba(232,41,74,0.30) 40%,
        rgba(232,41,74,0.30) 60%,
        transparent
    );
    pointer-events: none;
    z-index: 200;
}


/* ── Top Bar (brand + close) ─────────────────────────────────────────────── */

#thelis-chat-topbar {
    position: relative;
    z-index: 100;
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    height: 46px;

    background: #0c0c14;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

#thelis-chat-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 3.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    pointer-events: none;
    user-select: none;
}

.tc-brand-dot {
    display: block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #E8294A;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(232,41,74,0.8);
    animation: tc-pulse 2.6s ease-in-out infinite;
}

#thelis-chat-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;

    background: transparent;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 4px;
    color: rgba(255,255,255,0.40);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

#thelis-chat-close:hover {
    background: rgba(232,41,74,0.15);
    border-color: rgba(232,41,74,0.45);
    color: #ffffff;
}


/* ── Body (frame area) ──────────────────────────────────────────────────── */

#thelis-chat-body {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #111118;
    min-height: 0;
}


/* ── Privacy Screen ─────────────────────────────────────────────────────── */

#thelis-chat-privacy {
    position: absolute;
    inset: 0;
    z-index: 10;
    background: #111118;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 32px;
    box-sizing: border-box;
}

#thelis-chat-privacy[hidden] { display: none; }

.tc-privacy-inner { width: 100%; }

.tc-privacy-inner p {
    font-family: 'Syne', sans-serif;
    font-size: 14px;
    line-height: 1.75;
    color: rgba(255,255,255,0.65);
    border-left: 2px solid rgba(232,41,74,0.50);
    padding-left: 16px;
    margin: 0 0 32px;
}

.tc-consent-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.55);
    cursor: pointer;
    margin-bottom: 28px;
    line-height: 1.6;
}

.tc-consent-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 2px;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 2px;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.tc-consent-label input[type="checkbox"]:checked {
    background: #E8294A;
    border-color: #E8294A;
}

.tc-consent-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px; top: 1px;
    width: 5px; height: 9px;
    border: 2px solid #ffffff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

#thelis-chat-privacy-ok {
    width: 100%;
    padding: 14px 32px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #ffffff;
    background: #E8294A;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.25s ease, transform 0.2s ease;
}

#thelis-chat-privacy-ok:hover:not(:disabled) {
    background: #c91e38;
    transform: translateY(-1px);
}

#thelis-chat-privacy-ok:disabled {
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.25);
    cursor: not-allowed;
    transform: none;
}


/* ── Loading ────────────────────────────────────────────────────────────── */

#thelis-chat-loading {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: #111118;
    display: flex;
    align-items: center;
    justify-content: center;
}

#thelis-chat-loading.is-hidden { display: none; }

.tc-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(232,41,74,0.18);
    border-top-color: #E8294A;
    animation: tc-spin 0.9s linear infinite;
}


/* ── Iframe ─────────────────────────────────────────────────────────────── */

#thelis-chat-iframe {
    position: absolute;
    top: -130px;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(100% + 130px);
    border: none;
    background: #ffffff;
}


/* ── Mobile ─────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    #thelis-chat-tab {
        height: 160px;
        width: 40px;
    }

    #thelis-chat-panel {
        top: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        transform: translateX(100vw);
    }

    #thelis-chat-panel.is-open {
        transform: translateX(0);
    }

    #thelis-chat-backdrop {
        display: none;
    }
}
