/* Ceyora live chat — sidebar (desktop) / fullscreen (mobile) */

.cey-chat {
    --cey-chat-sidebar-w: 420px;
    font-family: var(--cey-font-body, Inter, system-ui, sans-serif);
}

/* ── Backdrop ── */
.cey-chat-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999990;
    background: rgba(10, 22, 40, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    backdrop-filter: blur(2px);
}

body.cey-chat-open .cey-chat-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ── Sidebar panel ── */
.cey-chat-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--cey-chat-sidebar-w);
    max-width: 100vw;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: -8px 0 40px rgba(10, 22, 40, 0.12);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.4s ease;
}

body.cey-chat-open .cey-chat-sidebar {
    transform: translateX(0);
    visibility: visible;
}

/* ── Header ── */
.cey-chat-sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.35rem;
    background: linear-gradient(135deg, var(--cey-navy, #0a1628) 0%, #152a52 55%, var(--cey-blue-dark, #0d4fd4) 100%);
    color: #fff;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.cey-chat-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.cey-chat-sidebar__avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.cey-chat-sidebar__titles strong {
    display: block;
    font-family: var(--cey-font-display, 'Plus Jakarta Sans', sans-serif);
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.cey-chat-sidebar__status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.2rem;
}

.cey-chat-sidebar__status small {
    font-size: 0.75rem;
    opacity: 0.85;
}

.cey-chat-sidebar__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.25);
    animation: ceyChatDotPulse 2s ease-in-out infinite;
}

@keyframes ceyChatDotPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.cey-chat-sidebar__close {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}

.cey-chat-sidebar__close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.05);
}

/* ── Main content area ── */
.cey-chat-sidebar__main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: #f8fafc;
}

.cey-chat-sidebar__footer {
    flex-shrink: 0;
    padding: 0.65rem 1.25rem;
    text-align: center;
    font-size: 0.6875rem;
    color: var(--cey-text-muted, #64748b);
    background: #fff;
    border-top: 1px solid var(--cey-border, rgba(15, 23, 42, 0.08));
}

.cey-chat-sidebar__footer i {
    margin-right: 0.25rem;
    opacity: 0.7;
}

/* ── Pre-chat form ── */
.cey-chat-prechat {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.35rem;
}

.cey-chat-prechat__hero {
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--cey-border, rgba(15, 23, 42, 0.08));
}

.cey-chat-prechat__hero h3 {
    font-family: var(--cey-font-display, 'Plus Jakarta Sans', sans-serif);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--cey-navy, #0a1628);
    margin: 0 0 0.5rem;
    letter-spacing: -0.02em;
}

.cey-chat-prechat__hero p {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--cey-text-muted, #64748b);
}

.cey-chat-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cey-chat-field label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--cey-navy, #0a1628);
    margin-bottom: 0.4rem;
}

.cey-chat-field label i {
    font-size: 0.6875rem;
    color: var(--cey-blue, #1062fe);
    opacity: 0.85;
}

.cey-chat-field input,
.cey-chat-field select {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 10px;
    font-size: 0.9375rem;
    background: #fff;
    color: var(--cey-navy, #0a1628);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cey-chat-field input:focus,
.cey-chat-field select:focus {
    outline: none;
    border-color: var(--cey-blue, #1062fe);
    box-shadow: 0 0 0 3px rgba(16, 98, 254, 0.12);
}

.cey-chat-btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.875rem 1.25rem;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--cey-blue, #1062fe) 0%, var(--cey-blue-dark, #0d4fd4) 100%);
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(16, 98, 254, 0.28);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cey-chat-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(16, 98, 254, 0.35);
}

/* ── Chat body & messages ── */
.cey-chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.cey-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.cey-chat-msg-row {
    display: flex;
    gap: 0.65rem;
    max-width: 92%;
}

.cey-chat-msg-row--visitor {
    margin-left: auto;
    flex-direction: row-reverse;
}

.cey-chat-msg-row--system {
    max-width: 100%;
    justify-content: center;
}

.cey-chat-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #fff;
}

.cey-chat-msg-row--visitor .cey-chat-msg-avatar {
    background: linear-gradient(135deg, var(--cey-blue, #1062fe), var(--cey-blue-dark, #0d4fd4));
}

.cey-chat-msg-row--ai .cey-chat-msg-avatar,
.cey-chat-msg-row--agent .cey-chat-msg-avatar {
    background: linear-gradient(135deg, var(--cey-navy, #0a1628), #1a3a6e);
}

.cey-chat-msg-bubble {
    padding: 0.75rem 0.95rem;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.55;
}

.cey-chat-msg-row--visitor .cey-chat-msg-bubble {
    background: linear-gradient(135deg, var(--cey-blue, #1062fe), var(--cey-blue-dark, #0d4fd4));
    color: #fff;
    border-bottom-right-radius: 4px;
}

.cey-chat-msg-row--ai .cey-chat-msg-bubble,
.cey-chat-msg-row--agent .cey-chat-msg-bubble {
    background: #fff;
    border: 1px solid var(--cey-border, rgba(15, 23, 42, 0.08));
    color: var(--cey-text, #334155);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(10, 22, 40, 0.04);
}

.cey-chat-msg-row--system .cey-chat-msg-bubble {
    background: rgba(16, 98, 254, 0.07);
    color: var(--cey-text-muted, #64748b);
    font-size: 0.8125rem;
    text-align: center;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
}

.cey-chat-msg-meta {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    opacity: 0.75;
    margin-bottom: 0.25rem;
}

.cey-chat-msg-row--visitor .cey-chat-msg-meta {
    text-align: right;
    color: rgba(255, 255, 255, 0.85);
}

/* ── Compose ── */
.cey-chat-compose {
    flex-shrink: 0;
    padding: 1rem 1.35rem 1.25rem;
    background: #fff;
    border-top: 1px solid var(--cey-border, rgba(15, 23, 42, 0.08));
}

.cey-chat-compose__wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.35rem 0.35rem 1rem;
    background: #f1f5f9;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 999px;
}

.cey-chat-compose__wrap input {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 0.5rem 0;
    font-size: 0.9375rem;
    color: var(--cey-navy, #0a1628);
}

.cey-chat-compose__wrap input:focus {
    outline: none;
}

.cey-chat-compose__send {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cey-blue, #1062fe), var(--cey-blue-dark, #0d4fd4));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.cey-chat-compose__send:hover {
    transform: scale(1.06);
}

/* ── Floating launcher (bottom-left, viewport-fixed) ── */
.cey-chat-launcher {
    position: fixed;
    left: 24px !important;
    right: auto !important;
    bottom: 24px;
    z-index: 999998;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.2rem 0.6rem 0.6rem;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--cey-blue, #1062fe) 0%, var(--cey-blue-dark, #0d4fd4) 100%);
    color: #fff;
    box-shadow: 0 12px 36px rgba(16, 98, 254, 0.38);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
}

.cey-chat-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 44px rgba(16, 98, 254, 0.45);
}

body.cey-chat-open .cey-chat-launcher {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.9);
}

.cey-chat-launcher__pulse {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: rgba(16, 98, 254, 0.35);
    animation: ceyChatPulse 2.2s ease-out infinite;
    pointer-events: none;
}

@keyframes ceyChatPulse {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.35); opacity: 0; }
}

.cey-chat-launcher__icon-wrap {
    position: relative;
    z-index: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.cey-chat-launcher__label {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
    text-align: left;
    padding-right: 0.1rem;
}

.cey-chat-launcher__label strong {
    font-size: 0.9375rem;
    font-weight: 700;
}

.cey-chat-launcher__label small {
    font-size: 0.6875rem;
    opacity: 0.88;
    margin-top: 0.1rem;
}

/* ── Mobile: fullscreen ── */
@media (max-width: 767px) {
    body.cey-chat-open {
        overflow: hidden;
    }

    .cey-chat-sidebar {
        width: 100vw;
        max-width: 100vw;
        left: 0;
        box-shadow: none;
    }

    .cey-chat-sidebar__header {
        padding: 1rem 1.15rem;
        padding-top: max(1rem, env(safe-area-inset-top));
    }

    .cey-chat-sidebar__close {
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
        background: rgba(255, 255, 255, 0.18);
    }

    .cey-chat-sidebar__footer {
        padding-bottom: max(0.65rem, env(safe-area-inset-bottom));
    }

    .cey-chat-launcher {
        left: 16px !important;
        right: auto !important;
        bottom: max(16px, env(safe-area-inset-bottom));
    }

    .cey-chat-launcher__label {
        display: none;
    }

    .cey-chat-backdrop {
        background: rgba(10, 22, 40, 0.55);
    }
}

@media (min-width: 768px) {
    body.cey-chat-open {
        overflow: hidden;
    }
}
