/* ── Landing Chat Widget ─────────────────────────────────────────────────── */
/* All classes prefixed .lc-* to avoid collisions                            */

/* ── Bubble ─────────────────────────────────────────────────────────────── */
.lc-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1100;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #008060;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 128, 96, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    /* Entry animation */
    animation: lc-enter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    animation-delay: 1s;
}

.lc-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(0, 128, 96, 0.5);
}

.lc-bubble:active {
    transform: scale(0.95);
}

.lc-bubble svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Entry: scale from 0 + bounce */
@keyframes lc-enter {
    0%   { transform: scale(0); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    80%  { transform: scale(0.92); }
    100% { transform: scale(1); opacity: 1; }
}

/* Persistent ring pulse on the bubble */
.lc-bubble::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid #008060;
    opacity: 0;
    animation: lc-ring 3s ease-out infinite;
    animation-delay: 3s;
}

@keyframes lc-ring {
    0%   { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* Gentle bounce to draw attention */
.lc-bubble--bounce {
    animation: lc-attention 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes lc-attention {
    0%   { transform: translateY(0); }
    30%  { transform: translateY(-10px); }
    50%  { transform: translateY(0); }
    70%  { transform: translateY(-5px); }
    100% { transform: translateY(0); }
}

/* ── Tooltip ────────────────────────────────────────────────────────────── */
.lc-tooltip {
    position: fixed;
    bottom: 92px;
    right: 24px;
    z-index: 1100;
    background: #fff;
    color: #1a1a1a;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    white-space: nowrap;
    pointer-events: none;
    /* Hidden by default */
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.lc-tooltip--visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Arrow */
.lc-tooltip::after {
    content: "";
    position: absolute;
    bottom: -6px;
    right: 22px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.05);
}

.lc-tooltip-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 16px;
    margin-left: 8px;
    padding: 0 2px;
    line-height: 1;
    vertical-align: middle;
}

.lc-tooltip-close:hover {
    color: #333;
}

/* ── Unread badge ───────────────────────────────────────────────────────── */
.lc-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e53e3e;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: lc-badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes lc-badge-pop {
    0%   { transform: scale(0); }
    100% { transform: scale(1); }
}

/* ── Window ─────────────────────────────────────────────────────────────── */
.lc-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 1100;
    width: 380px;
    height: 520px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* slide-up animation */
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.lc-window--open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.lc-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: #008060;
    color: #fff;
    flex-shrink: 0;
}

.lc-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.lc-header-info {
    flex: 1;
    min-width: 0;
}

.lc-header-name {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
}

.lc-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
}

.lc-header-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #6ff5b0;
    display: inline-block;
}

.lc-header-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.lc-header-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

.lc-header-close svg {
    width: 20px;
    height: 20px;
    stroke: #fff;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
}

/* ── Messages area ──────────────────────────────────────────────────────── */
.lc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.lc-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
    /* Fade-in for new messages */
    animation: lc-msg-in 0.25s ease-out;
}

@keyframes lc-msg-in {
    0%   { opacity: 0; transform: translateY(6px); }
    100% { opacity: 1; transform: translateY(0); }
}

.lc-msg--bot {
    align-self: flex-start;
    background: #f0f1f3;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

.lc-msg--user {
    align-self: flex-end;
    background: #008060;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* ── Typing indicator ───────────────────────────────────────────────────── */
.lc-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #f0f1f3;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.lc-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #999;
    animation: lc-bounce 1.2s infinite;
}

.lc-typing span:nth-child(2) { animation-delay: 0.15s; }
.lc-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes lc-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); }
}

/* ── Input area ─────────────────────────────────────────────────────────── */
.lc-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e8e8e8;
    flex-shrink: 0;
    background: #fff;
}

.lc-textarea {
    flex: 1;
    resize: none;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    max-height: 100px;
    overflow-y: auto;
    outline: none;
    transition: border-color 0.15s;
}

.lc-textarea:focus {
    border-color: #008060;
}

.lc-textarea::placeholder {
    color: #aaa;
}

.lc-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #008060;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.15s;
}

.lc-send:hover:not(:disabled) {
    transform: scale(1.08);
}

.lc-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.lc-send svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Responsive: Tablets ────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .lc-bubble {
        bottom: 80px;  /* above sticky CTA (z-index 1030) */
    }

    .lc-tooltip {
        bottom: 148px;
    }

    .lc-window {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100dvh;
        height: var(--lc-window-height, 100dvh);
        max-height: none;
        border-radius: 0;
        overscroll-behavior: contain;
    }
}

/* ── Responsive: Small phones ───────────────────────────────────────────── */
@media (max-width: 400px) {
    .lc-bubble {
        width: 52px;
        height: 52px;
        bottom: 76px;
        right: 16px;
    }

    .lc-bubble svg {
        width: 24px;
        height: 24px;
    }

    .lc-tooltip {
        right: 16px;
        bottom: 136px;
        font-size: 13px;
        padding: 8px 14px;
    }

    .lc-msg {
        max-width: 88%;
        font-size: 13.5px;
    }

    .lc-textarea {
        font-size: 16px; /* prevent iOS zoom on focus */
    }
}

/* ── Safe area for notch phones ─────────────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 900px) {
        .lc-input-area {
            padding-bottom: calc(12px + env(safe-area-inset-bottom));
        }
    }
}

/* ── Reduced motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .lc-bubble,
    .lc-bubble::after,
    .lc-tooltip,
    .lc-window,
    .lc-send,
    .lc-msg {
        animation: none !important;
        transition: none !important;
    }

    .lc-typing span {
        animation: none !important;
    }
}
