/* LuwiPress Customer Chat Widget — Minimal & Modern */
.lp-chat-widget {
    --lp-primary: #6366f1;
    --lp-text: #ffffff;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
}
.lp-chat-widget *, .lp-chat-widget *::before, .lp-chat-widget *::after { box-sizing: border-box; }
.lp-chat-widget.lp-chat-left { right: auto; left: 24px; }

/* Toggle Button */
.lp-chat-toggle {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--lp-primary);
    color: var(--lp-text);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0,0,0,.12);
    transition: transform .2s ease, box-shadow .2s ease;
}
.lp-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 20px rgba(0,0,0,.18);
}

/* Chat Window */
.lp-chat-window {
    position: absolute;
    bottom: 66px;
    right: 0;
    width: 360px;
    max-height: 500px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,.1), 0 0 0 1px rgba(0,0,0,.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(.85) translateY(16px);
    opacity: 0;
    pointer-events: none;
    transition: transform .25s cubic-bezier(.4,0,.2,1), opacity .25s ease;
    transform-origin: bottom right;
}
.lp-chat-widget.lp-chat-left .lp-chat-window {
    right: auto; left: 0;
    transform-origin: bottom left;
}
.lp-chat-widget:not(.lp-chat-closed) .lp-chat-window {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}
.lp-chat-widget:not(.lp-chat-closed) .lp-chat-toggle { display: none; }

/* Header */
.lp-chat-header {
    background: var(--lp-primary);
    color: var(--lp-text);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.lp-chat-header-info { display: flex; flex-direction: column; gap: 1px; }
.lp-chat-title { font-weight: 600; font-size: 14px; letter-spacing: .01em; }
.lp-chat-subtitle { font-size: 11px; opacity: .75; font-weight: 400; }
.lp-chat-header-actions { display: flex; gap: 4px; align-items: center; }
.lp-chat-header-actions button {
    background: rgba(255,255,255,.1);
    border: none;
    color: var(--lp-text);
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.lp-chat-header-actions button:hover { background: rgba(255,255,255,.2); }
.lp-chat-close-btn { font-size: 18px; line-height: 1; }

/* Body */
.lp-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 280px;
    max-height: 330px;
    background: #fafafa;
}
.lp-chat-body::-webkit-scrollbar { width: 4px; }
.lp-chat-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
.lp-chat-body::-webkit-scrollbar-track { background: transparent; }

/* Messages */
.lp-chat-msg { display: flex; flex-direction: column; max-width: 82%; animation: lp-msg-in .2s ease; }
.lp-chat-msg-customer { align-self: flex-end; align-items: flex-end; }
.lp-chat-msg-assistant { align-self: flex-start; align-items: flex-start; }

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

.lp-chat-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    word-break: break-word;
    font-size: 13.5px;
    line-height: 1.45;
}
.lp-chat-msg-customer .lp-chat-bubble {
    background: var(--lp-primary);
    color: var(--lp-text);
    border-bottom-right-radius: 4px;
}
.lp-chat-msg-assistant .lp-chat-bubble {
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}
.lp-chat-bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.lp-chat-msg-assistant .lp-chat-bubble a { color: var(--lp-primary); }
.lp-chat-time { font-size: 10px; color: #b0b0b0; margin-top: 3px; padding: 0 4px; }

/* Typing indicator */
.lp-chat-typing { display: flex; gap: 5px; padding: 10px 14px !important; background: #fff !important; border: 1px solid #e5e7eb !important; }
.lp-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #c0c0c0;
    animation: lp-typing 1.4s infinite;
}
.lp-chat-typing span:nth-child(2) { animation-delay: .2s; }
.lp-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes lp-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .35; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* Input Area */
.lp-chat-input-area {
    display: flex;
    padding: 10px 12px;
    gap: 8px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
}
.lp-chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13.5px;
    outline: none;
    font-family: inherit;
    transition: border-color .2s;
    background: #fafafa;
}
.lp-chat-input:focus { border-color: var(--lp-primary); background: #fff; }
.lp-chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--lp-primary);
    color: var(--lp-text);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s, transform .15s;
    flex-shrink: 0;
}
.lp-chat-send-btn:disabled { opacity: .3; cursor: default; }
.lp-chat-send-btn:not(:disabled):hover { opacity: .85; transform: scale(1.05); }

/* Footer */
.lp-chat-footer {
    text-align: center;
    padding: 5px;
    font-size: 10px;
    color: #c0c0c0;
    background: #fff;
    flex-shrink: 0;
}

/* Channel choice */
.lp-chat-channel-choice p { margin: 0 0 8px; font-size: 13px; }
.lp-chat-channel-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    margin: 0 4px 4px 0;
    transition: opacity .15s, transform .15s;
}
.lp-chat-channel-btn:hover { opacity: .85; transform: scale(1.02); }
.lp-chat-wa-btn { background: #25d366; color: #fff; }
.lp-chat-tg-btn { background: #0088cc; color: #fff; }

/* Inline escalation */
.lp-chat-inline-escalate {
    display: inline-block;
    margin-top: 6px;
    padding: 6px 14px;
    background: var(--lp-primary);
    color: var(--lp-text);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    transition: opacity .15s;
}
.lp-chat-inline-escalate:hover { opacity: .85; }

/* Mobile */
@media (max-width: 480px) {
    .lp-chat-widget { bottom: 0; right: 0; left: 0; }
    .lp-chat-widget.lp-chat-left { left: 0; }
    .lp-chat-toggle { position: fixed; bottom: 16px; right: 16px; }
    .lp-chat-widget.lp-chat-left .lp-chat-toggle { right: auto; left: 16px; }
    .lp-chat-window {
        position: fixed;
        bottom: 0; right: 0; left: 0;
        width: 100%;
        max-height: 85vh;
        border-radius: 14px 14px 0 0;
        transform-origin: bottom center;
    }
    .lp-chat-body { max-height: calc(85vh - 160px); }
}
