/* ── WP Live Chat Widget ── */
#wplc-widget-wrapper {
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --radius: 16px;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Trigger Button ── */
#wplc-trigger-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    transition: transform .25s, box-shadow .25s;
    position: relative;
    margin-left: auto;
}
#wplc-trigger-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(0,0,0,.3);
}
#wplc-unread-count {
    position: absolute;
    top: -4px; right: -4px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    width: 22px; height: 22px;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* ── Chat Window ── */
#wplc-chat-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 360px;
    max-height: 560px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: wplcSlideUp .25s ease;
}
@keyframes wplcSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ── */
#wplc-header {
    background: var(--brand);
    color: #fff;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
#wplc-header-info { display: flex; align-items: center; gap: 12px; }
#wplc-agent-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700;
    border: 2px solid rgba(255,255,255,.5);
}
#wplc-header-name { font-weight: 600; font-size: 15px; }
#wplc-header-status { display: flex; align-items: center; gap: 5px; font-size: 12px; opacity: .85; margin-top: 2px; }
.wplc-status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    flex-shrink: 0;
}
.wplc-status-dot.online { background: #4ade80; }
.wplc-status-dot.offline { background: #fbbf24; }
#wplc-minimize-btn {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    width: 30px; height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
    flex-shrink: 0;
}
#wplc-minimize-btn:hover { background: rgba(255,255,255,.25); }

/* ── Pre-chat Form ── */
#wplc-prechat-form {
    padding: 20px;
    overflow-y: auto;
}
#wplc-greeting-msg {
    background: #f1f5f9;
    border-radius: 12px;
    padding: 14px;
    font-size: 14px;
    color: #334155;
    line-height: 1.5;
    margin-bottom: 16px;
}
.wplc-form-group { margin-bottom: 12px; }
.wplc-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 5px;
}
.wplc-form-group input,
.wplc-form-group textarea {
    width: 100%;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    color: #1e293b;
    font-family: inherit;
    box-sizing: border-box;
    outline: none;
    transition: border-color .2s;
}
.wplc-form-group input:focus,
.wplc-form-group textarea:focus { border-color: var(--brand); }
#wplc-start-chat-btn {
    width: 100%;
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
    margin-top: 4px;
}
#wplc-start-chat-btn:hover { background: var(--brand-dark); }

/* ── Messages Area ── */
#wplc-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f8fafc;
}

.wplc-msg-wrap {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}
.wplc-msg-wrap.visitor { align-self: flex-end; }
.wplc-msg-wrap.agent, .wplc-msg-wrap.bot { align-self: flex-start; }

.wplc-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}
.wplc-msg-wrap.visitor .wplc-msg-bubble {
    background: var(--brand);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.wplc-msg-wrap.agent .wplc-msg-bubble {
    background: #fff;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.wplc-msg-wrap.bot .wplc-msg-bubble {
    background: #f5f3ff;
    color: #4c1d95;
    border-bottom-left-radius: 4px;
    border-left: 3px solid #a855f7;
}
.wplc-msg-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 3px;
    padding: 0 4px;
}
.wplc-msg-wrap.visitor .wplc-msg-time { text-align: right; }

/* ── Typing Indicator ── */
#wplc-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
#wplc-typing-indicator span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: wplcTyping 1.2s infinite;
}
#wplc-typing-indicator span:nth-child(2) { animation-delay: .2s; }
#wplc-typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes wplcTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Offline Form ── */
#wplc-offline-form {
    padding: 20px;
    text-align: left;
    overflow-y: auto;
}
.wplc-offline-icon { font-size: 40px; text-align: center; margin-bottom: 10px; }
#wplc-offline-form p { color: #475569; font-size: 14px; text-align: center; margin-bottom: 16px; }
#wplc-offline-submit-btn {
    width: 100%;
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

/* ── Input Area ── */
#wplc-input-area {
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}
#wplc-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 8px 10px;
}
#wplc-msg-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 100px;
    font-family: inherit;
    color: #1e293b;
    line-height: 1.4;
}
#wplc-attach-btn {
    cursor: pointer;
    color: #94a3b8;
    display: flex;
    align-items: center;
    padding: 2px;
    transition: color .15s;
}
#wplc-attach-btn:hover { color: var(--brand); }
#wplc-send-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, transform .1s;
}
#wplc-send-btn:hover { background: var(--brand-dark); transform: scale(1.05); }
#wplc-powered-by { font-size: 11px; color: #cbd5e1; text-align: center; margin-top: 6px; }

/* ── Left position ── */
#wplc-widget-wrapper.pos-left { right: auto; left: 24px; }
#wplc-widget-wrapper.pos-left #wplc-chat-window { right: auto; left: 0; }
#wplc-widget-wrapper.pos-left #wplc-trigger-btn { margin-left: 0; margin-right: auto; }

/* ── Mobile ── */
@media (max-width: 480px) {
    #wplc-chat-window {
        width: calc(100vw - 32px);
        max-height: 70vh;
        bottom: 76px;
        right: 0;
    }
}
