/* ============================================================
   Live Chat Widget styles
   Light theme by default, dark theme via prefers-color-scheme.
   ============================================================ */

#lc-root {
    --lc-gradient: linear-gradient(135deg, #4f7cff 0%, #8a5cf6 100%);
    --lc-accent: #4f7cff;
    --lc-surface: rgba(255, 255, 255, 0.85);
    --lc-surface-solid: #ffffff;
    --lc-border: rgba(0, 0, 0, 0.08);
    --lc-text: #1c2333;
    --lc-text-muted: #6b7280;
    --lc-visitor-bubble: linear-gradient(135deg, #4f7cff, #6a5cf6);
    --lc-admin-bubble: #eef1f6;
    --lc-admin-bubble-text: #1c2333;
    --lc-input-bg: #f2f4f8;
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    position: fixed;
    z-index: 999999;
    right: 0;
    bottom: 0;
}

@media (prefers-color-scheme: dark) {
    #lc-root {
        --lc-surface: rgba(28, 30, 38, 0.88);
        --lc-surface-solid: #1c1e26;
        --lc-border: rgba(255, 255, 255, 0.1);
        --lc-text: #e8eaf0;
        --lc-text-muted: #9aa0ae;
        --lc-admin-bubble: #2a2d38;
        --lc-admin-bubble-text: #e8eaf0;
        --lc-input-bg: #262933;
    }
}

/* ---------------- floating launcher ---------------- */
.lc-launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 60px;
    height: 60px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    background: var(--lc-gradient);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(79, 124, 255, 0.45), 0 2px 6px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.lc-launcher:hover {
    transform: translateY(-3px) scale(1.06);
    box-shadow: 0 14px 32px rgba(79, 124, 255, 0.55), 0 4px 10px rgba(0, 0, 0, 0.2);
}

.lc-launcher svg {
    width: 28px;
    height: 28px;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.lc-launcher .lc-launcher-close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
}

/* icon swap when the modal is open */
#lc-root.lc-open .lc-launcher-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}

#lc-root.lc-open .lc-launcher-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* pulse while there are unread admin messages */
#lc-root.lc-has-unread .lc-launcher {
    animation: lc-pulse 1.6s ease-out infinite;
}

@keyframes lc-pulse {
    0%   { box-shadow: 0 8px 24px rgba(79, 124, 255, 0.45), 0 0 0 0 rgba(79, 124, 255, 0.55); }
    70%  { box-shadow: 0 8px 24px rgba(79, 124, 255, 0.45), 0 0 0 16px rgba(79, 124, 255, 0); }
    100% { box-shadow: 0 8px 24px rgba(79, 124, 255, 0.45), 0 0 0 0 rgba(79, 124, 255, 0); }
}

/* unread badge */
.lc-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: #ff4d5e;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* ---------------- modal ---------------- */
.lc-modal {
    position: fixed;
    right: 20px;
    bottom: 92px;
    width: 360px;
    max-width: calc(100vw - 24px);
    height: 520px;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    border: 1px solid var(--lc-border);
    background: var(--lc-surface);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    opacity: 0;
    transform: translateY(24px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

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

/* header */
.lc-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--lc-gradient);
    color: #fff;
    flex-shrink: 0;
}

.lc-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    padding: 5px;
}

.lc-header-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    flex: 1;
    min-width: 0;
}

.lc-header-text strong { font-size: 15px; }

.lc-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

.lc-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9aa0ae;
    transition: background 0.3s ease;
}

.lc-status-dot.lc-online { background: #2ee66b; box-shadow: 0 0 6px #2ee66b; }
.lc-status-dot.lc-offline { background: #ffb020; }

.lc-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.lc-close:hover { background: rgba(255, 255, 255, 0.3); transform: rotate(90deg); }
.lc-close svg { width: 16px; height: 16px; }

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

.lc-welcome {
    align-self: center;
    text-align: center;
    color: var(--lc-text-muted);
    font-size: 13px;
    padding: 8px 14px;
    background: var(--lc-admin-bubble);
    border-radius: 12px;
}

.lc-welcome p { margin: 0; }

/* date separators */
.lc-date-sep {
    align-self: center;
    font-size: 11px;
    color: var(--lc-text-muted);
    background: var(--lc-admin-bubble);
    padding: 3px 10px;
    border-radius: 10px;
    margin: 4px 0;
}

/* bubbles */
.lc-msg {
    max-width: 78%;
    display: flex;
    flex-direction: column;
    animation: lc-msg-in 0.25s ease;
}

@keyframes lc-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.lc-msg .lc-bubble {
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.lc-msg .lc-time {
    font-size: 10.5px;
    color: var(--lc-text-muted);
    margin-top: 3px;
}

.lc-msg.lc-visitor { align-self: flex-end; align-items: flex-end; }
.lc-msg.lc-visitor .lc-bubble {
    background: var(--lc-visitor-bubble);
    color: #fff;
    border-bottom-right-radius: 5px;
}

.lc-msg.lc-admin { align-self: flex-start; align-items: flex-start; }
.lc-msg.lc-admin .lc-bubble {
    background: var(--lc-admin-bubble);
    color: var(--lc-admin-bubble-text);
    border-bottom-left-radius: 5px;
}

/* typing indicator */
.lc-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 16px 8px;
    font-size: 12px;
    color: var(--lc-text-muted);
    flex-shrink: 0;
}

.lc-typing-bubble {
    display: inline-flex;
    gap: 3px;
    background: var(--lc-admin-bubble);
    padding: 7px 10px;
    border-radius: 12px;
}

.lc-typing-bubble i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--lc-text-muted);
    animation: lc-bounce 1.2s infinite;
}

.lc-typing-bubble i:nth-child(2) { animation-delay: 0.15s; }
.lc-typing-bubble i: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: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--lc-border);
    background: var(--lc-surface-solid);
    position: relative;
    flex-shrink: 0;
}

.lc-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: var(--lc-input-bg);
    color: var(--lc-text);
    border-radius: 20px;
    padding: 11px 16px;
    font-size: 14px;
    transition: box-shadow 0.2s ease;
}

.lc-input:focus { box-shadow: 0 0 0 2px var(--lc-accent); }

.lc-send {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: var(--lc-gradient);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.lc-send:hover { transform: scale(1.08); }
.lc-send:disabled { opacity: 0.6; cursor: default; transform: none; }
.lc-send svg { width: 19px; height: 19px; margin-left: 2px; }

/* sending spinner */
.lc-spinner {
    width: 17px;
    height: 17px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: lc-spin 0.7s linear infinite;
}

@keyframes lc-spin { to { transform: rotate(360deg); } }

/* emoji picker */
.lc-emoji-btn {
    border: none;
    background: none;
    font-size: 21px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: transform 0.15s ease;
}

.lc-emoji-btn:hover { transform: scale(1.2); }

.lc-emoji-panel {
    position: absolute;
    bottom: 58px;
    left: 10px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    background: var(--lc-surface-solid);
    border: 1px solid var(--lc-border);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: lc-msg-in 0.2s ease;
    z-index: 5;
}

.lc-emoji-panel button {
    border: none;
    background: none;
    font-size: 20px;
    padding: 4px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s ease, transform 0.15s ease;
}

.lc-emoji-panel button:hover { background: var(--lc-input-bg); transform: scale(1.2); }

/* scrollbar */
.lc-messages::-webkit-scrollbar { width: 6px; }
.lc-messages::-webkit-scrollbar-thumb { background: var(--lc-border); border-radius: 3px; }

/* ---------------- mobile ---------------- */
@media (max-width: 480px) {
    .lc-modal {
        right: 8px;
        left: 8px;
        width: auto;
        bottom: 84px;
        height: 70vh;
        max-height: calc(100vh - 100px);
    }

    .lc-launcher {
        right: 14px;
        bottom: 14px;
        width: 54px;
        height: 54px;
    }
}
