:root {
    --text: #0f172a;
    --text-faint: #94a3b8;
    --border: #e2e8f0;
    --bg-input: #ffffff;
    --bg-elevated: #f1f5f9;
}

/* ── LIVE CHAT WIDGET (WhatsApp palette) ── */
.lcsw-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: inherit;
}

.lcsw-fab {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #25D366, #128C7E, #075E54);
    background-size: 200% 200%;
    animation: lcswFabGradient 4s ease infinite;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.35), 0 0 0 0 rgba(37, 211, 102, 0.3);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s;
    position: relative;
}

@keyframes lcswFabGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.lcsw-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(37, 211, 102, 0.5), 0 0 0 0 rgba(37, 211, 102, 0);
}

.lcsw-fab:active {
    transform: scale(0.95);
}

.lcsw-fab-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: #ef4444;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.45);
    border: 2px solid #fff;
    animation: lcswBadgePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes lcswBadgePop {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

.lcsw-window {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 340px;
    height: 440px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: lcswSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lcsw-window.lcsw-no-anim {
    animation: none;
}

@keyframes lcswSlideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.lcsw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: linear-gradient(135deg, #075E54 0%, #128C7E 60%, #0D6E5F 100%);
    color: #fff;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.lcsw-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 80% 20%, rgba(255,255,255,0.08) 0%, transparent 60%);
    pointer-events: none;
}

.lcsw-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.lcsw-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.lcsw-header-avatar::after {
    content: '';
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #075E54;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.lcsw-header-ended .lcsw-header-avatar::after {
    background: #94a3b8;
    box-shadow: none;
}

.lcsw-header-ended .lcsw-header-subtitle {
    opacity: 0.65;
}

.lcsw-header-title {
    font-weight: 700;
    font-size: 0.88rem;
    letter-spacing: -0.01em;
}

.lcsw-header-subtitle {
    font-size: 0.68rem;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 5px;
}

.lcsw-header-actions {
    position: relative;
    z-index: 1;
}

.lcsw-header-close {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(4px);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
}

.lcsw-header-close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.08);
}

.lcsw-prechat {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.1) transparent;
}

.lcsw-prechat::-webkit-scrollbar { width: 4px; }
.lcsw-prechat::-webkit-scrollbar-track { background: transparent; }
.lcsw-prechat::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 2px; }

.lcsw-prechat-inner {
    padding: 24px 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    flex: 1;
    justify-content: center;
}

.lcsw-prechat-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.15), rgba(18, 140, 126, 0.1));
    border: 1px solid rgba(37, 211, 102, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #128C7E;
    margin-bottom: 4px;
}

.lcsw-prechat-inner h3 {
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.lcsw-prechat-inner p {
    color: var(--text-faint);
    font-size: 0.78rem;
    margin: 0 0 10px 0;
    line-height: 1.45;
    max-width: 260px;
}

.lcsw-prechat-inner form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lcsw-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.84rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.lcsw-input:focus {
    border-color: rgba(37, 211, 102, 0.5);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.lcsw-input::placeholder {
    color: var(--text-faint);
}

.lcsw-start-btn {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: #fff;
    font-weight: 700;
    font-size: 0.84rem;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: all 0.2s ease;
    margin-top: 4px;
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.3);
    position: relative;
    overflow: hidden;
}

.lcsw-start-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}

.lcsw-start-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(37, 211, 102, 0.4);
}

.lcsw-start-btn:hover::before {
    opacity: 1;
}

.lcsw-start-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(37, 211, 102, 0.35);
}

.lcsw-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.lcsw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.08) transparent;
}

.lcsw-messages::-webkit-scrollbar { width: 4px; }
.lcsw-messages::-webkit-scrollbar-track { background: transparent; }
.lcsw-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 2px; }

.lcsw-msg-loading, .lcsw-msg-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-faint);
    font-size: 0.82rem;
}

.lcsw-msg {
    display: flex;
    max-width: 82%;
    animation: lcswMsgIn 0.2s ease-out;
}

@keyframes lcswMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.lcsw-msg-system {
    align-self: center;
    max-width: 100%;
    font-size: 0.7rem;
    color: var(--text-faint);
    text-align: center;
    padding: 6px 12px;
    gap: 6px;
    background: var(--bg-elevated);
    border-radius: 8px;
}

.lcsw-msg-me {
    align-self: flex-end;
    margin-left: auto;
}

.lcsw-msg-admin {
    align-self: flex-start;
}

.lcsw-msg-bubble {
    padding: 8px 12px;
    border-radius: 12px 12px 12px 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.lcsw-bubble-admin {
    background: #128C7E;
    border: 1px solid rgba(7, 94, 84, 0.35);
    border-radius: 12px 12px 12px 4px;
}

.lcsw-bubble-admin .lcsw-msg-text {
    color: #fff;
}

.lcsw-bubble-admin .lcsw-msg-time {
    color: rgba(255, 255, 255, 0.72);
}

.lcsw-bubble-me {
    background: #DCF8C6;
    border: 1px solid rgba(37, 211, 102, 0.15);
    border-radius: 12px 12px 4px 12px;
}

.lcsw-msg-name {
    font-size: 0.68rem;
    font-weight: 700;
    color: #128C7E;
    letter-spacing: 0.02em;
}

.lcsw-msg-text {
    font-size: 0.82rem;
    color: var(--text);
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}

.lcsw-msg-text a {
    color: #0b6e99;
    text-decoration: underline;
    word-break: break-all;
}

.lcsw-bubble-admin .lcsw-msg-text a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.lcsw-msg-time {
    font-size: 0.6rem;
    color: var(--text-faint);
    align-self: flex-end;
    margin-top: 1px;
}

.lcsw-composer {
    border-top: 1px solid var(--border);
    background: #fff;
    flex-shrink: 0;
}

.lcsw-input-error {
    margin: 8px 10px 0;
    padding: 7px 10px;
    border-radius: 8px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    font-size: 0.72rem;
    line-height: 1.35;
    font-weight: 600;
}

.lcsw-input-error[hidden] {
    display: none !important;
}

.lcsw-input-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: #fff;
}

.lcsw-msg-input {
    flex: 1;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-elevated, #f8f8fa);
    color: var(--text);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.lcsw-msg-input:focus {
    border-color: rgba(37, 211, 102, 0.45);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.08);
}

.lcsw-msg-input.is-error,
.lcsw-msg-input.is-error:focus {
    border-color: #ef4444;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.lcsw-msg-input::placeholder {
    color: var(--text-faint);
}

.lcsw-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #25D366, #128C7E);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.lcsw-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.45);
}

.lcsw-send-btn:active {
    transform: scale(0.95);
}

.lcsw-end-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: auto;
    margin: 0 auto 8px;
    padding: 5px 16px;
    border-radius: 20px;
    border: none;
    background: transparent;
    color: var(--text-faint, #999);
    font-size: 0.7rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.lcsw-end-chat:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.06);
}

.lcsw-closed-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 12px 14px;
    border-top: 1px solid var(--border);
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    flex-shrink: 0;
    animation: lcswClosedFooterIn 0.25s ease-out;
}

@keyframes lcswClosedFooterIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.lcsw-closed-footer-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(37, 211, 102, 0.07);
    border: 1px solid rgba(18, 140, 126, 0.14);
}

.lcsw-closed-footer-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.18), rgba(18, 140, 126, 0.12));
    border: 1px solid rgba(18, 140, 126, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0D6E5F;
}

.lcsw-closed-footer-text {
    margin: 0;
    padding-top: 2px;
    font-size: 0.72rem;
    color: #64748b;
    line-height: 1.45;
    text-align: left;
}

.lcsw-closed-footer .lcsw-new-chat-btn {
    width: 100%;
    margin: 0;
}

.lcsw-new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: calc(100% - 24px);
    margin: auto 12px 12px;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.lcsw-new-chat-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.12), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}

.lcsw-new-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(37, 211, 102, 0.4);
}

.lcsw-new-chat-btn:hover::before {
    opacity: 1;
}

.lcsw-new-chat-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(37, 211, 102, 0.35);
}

@media (max-width: 768px) {
    .lcsw-widget {
        inset: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        z-index: 100000;
    }

    .lcsw-fab {
        display: none !important;
    }

    .lcsw-window {
        pointer-events: auto;
        position: fixed;
        inset: 0;
        width: 100%;
        max-width: none;
        height: 100dvh;
        border-radius: 0;
        box-shadow: none;
    }

    .lcsw-header {
        padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
    }

    .lcsw-prechat-inner {
        padding: 22px 18px 18px;
        justify-content: center;
    }

    .lcsw-prechat-inner h3 {
        font-size: 1rem;
    }

    .lcsw-prechat-inner p {
        font-size: 0.8rem;
        max-width: none;
    }

    .lcsw-start-btn {
        padding: 12px;
        font-size: 0.82rem;
    }

    .lcsw-composer {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .lcsw-input-bar {
        padding: 8px 10px;
    }

    .lcsw-end-chat {
        margin-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }

    .lcsw-closed-footer {
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 480px) {
    .lcsw-prechat-inner {
        padding: 20px 16px 16px;
    }

    .lcsw-prechat-inner h3 {
        font-size: 0.95rem;
    }

    .lcsw-prechat-inner p {
        font-size: 0.76rem;
        margin-bottom: 8px;
    }

    .lcsw-header {
        padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
    }

    .lcsw-header-title {
        font-size: 0.88rem;
    }

    .lcsw-input {
        padding: 9px 12px;
        font-size: 0.82rem;
    }

    .lcsw-start-btn {
        padding: 11px;
        font-size: 0.8rem;
    }

    .lcsw-msg-input {
        font-size: 0.8rem;
    }
}
