/* =========================================================
   Live Support Chat – Frontend Widget
   ========================================================= */

/* ── Wrapper ── */
#lsc-chat-wrapper {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* inline-flex so wrapper hugs button tightly (chat window is absolute, out of flow) */
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Left-side positions → align badge to left edge */
#lsc-chat-wrapper.lsc-pos-bottom-left,
#lsc-chat-wrapper.lsc-pos-top-left {
    align-items: flex-start;
}

/* ── Position anchors ── */
#lsc-chat-wrapper.lsc-pos-bottom-right { bottom: 24px; right: 24px; }
#lsc-chat-wrapper.lsc-pos-bottom-left  { bottom: 24px; left:  24px; }
#lsc-chat-wrapper.lsc-pos-top-right    { top:    24px; right: 24px; }
#lsc-chat-wrapper.lsc-pos-top-left     { top:    24px; left:  24px; }

/* ── Toggle button ── */
.lsc-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px 12px 16px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    color: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    transition: transform .2s ease, box-shadow .2s ease;
    position: relative;
    text-align: left;
    line-height: 1;
}
.lsc-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0,0,0,.3);
}
.lsc-toggle-btn:active { transform: translateY(0); }

/* Status colours */
#lsc-chat-wrapper.lsc-online  .lsc-toggle-btn { background: #16a34a; }
#lsc-chat-wrapper.lsc-offline .lsc-toggle-btn { background: #64748b; }

/* Chat / close icons */
.lsc-toggle-btn svg { width: 22px; height: 22px; flex-shrink: 0; }

/* ── Desktop text stack ── */
.lsc-btn-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Top status line: "We Are Online" */
.lsc-btn-status-line {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    opacity: .88;
    white-space: nowrap;
}

/* Small pulsing dot inside status line */
.lsc-btn-status-pip {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,.9);
    flex-shrink: 0;
}
#lsc-chat-wrapper.lsc-online .lsc-btn-status-pip {
    animation: lsc-pip-pulse 2s ease-in-out infinite;
}
@keyframes lsc-pip-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(.7); }
}

/* Main label: "How Can We Help You" */
.lsc-toggle-label {
    font-size: .95rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: -.01em;
}

/* Unread dot (new message indicator on closed widget) */
.lsc-unread-dot {
    position: absolute;
    top: 5px; right: 5px;
    width: 10px; height: 10px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: lsc-pulse 1.5s infinite;
}
@keyframes lsc-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.3); opacity: .8; }
}

/* ── Mobile: circular button, hide text stack ── */
@media (max-width: 600px) {
    .lsc-toggle-btn {
        padding: 15px;
        border-radius: 50%;
    }
    .lsc-btn-text { display: none; }
}

/* ── Mobile status badge (shown BELOW button on mobile) ── */
.lsc-mobile-badge {
    display: none; /* desktop: hidden */
    align-items: center;
    gap: 5px;
    margin-top: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
    color: #fff;
}

#lsc-chat-wrapper.lsc-online  .lsc-mobile-badge { background: rgba(22,163,74,.85); }
#lsc-chat-wrapper.lsc-offline .lsc-mobile-badge { background: rgba(100,116,139,.75); }

.lsc-mobile-badge-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: #fff;
    flex-shrink: 0;
}
#lsc-chat-wrapper.lsc-online .lsc-mobile-badge-dot {
    animation: lsc-pip-pulse 2s ease-in-out infinite;
}

@media (max-width: 600px) {
    .lsc-mobile-badge { display: inline-flex; }
}

/* ── Chat window ── */
.lsc-chat-window {
    position: absolute;
    width: 360px;
    max-width: calc(100vw - 48px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 520px;
}

/* Chat window direction per anchor */
#lsc-chat-wrapper.lsc-pos-bottom-right .lsc-chat-window {
    bottom: calc(100% + 12px);
    right: 0;
    animation: lsc-slide-up .25s ease;
}
#lsc-chat-wrapper.lsc-pos-bottom-left .lsc-chat-window {
    bottom: calc(100% + 12px);
    left: 0;
    animation: lsc-slide-up .25s ease;
}
#lsc-chat-wrapper.lsc-pos-top-right .lsc-chat-window {
    top: calc(100% + 12px);
    right: 0;
    animation: lsc-slide-down .25s ease;
}
#lsc-chat-wrapper.lsc-pos-top-left .lsc-chat-window {
    top: calc(100% + 12px);
    left: 0;
    animation: lsc-slide-down .25s ease;
}

@keyframes lsc-slide-up   { from{opacity:0;transform:translateY(14px)} to{opacity:1;transform:none} }
@keyframes lsc-slide-down { from{opacity:0;transform:translateY(-14px)} to{opacity:1;transform:none} }

/* ── Chat header ── */
.lsc-chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    color: #fff;
    font-weight: 600;
    font-size: .9rem;
}
#lsc-chat-wrapper.lsc-online  .lsc-chat-header { background: #16a34a; }
#lsc-chat-wrapper.lsc-offline .lsc-chat-header { background: #64748b; }

.lsc-status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,.85);
    flex-shrink: 0;
}
#lsc-chat-wrapper.lsc-online .lsc-status-dot { animation: lsc-pip-pulse 2s ease-in-out infinite; }

.lsc-header-title { flex: 1; }

.lsc-close-btn {
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,.85);
    padding: 4px; display: flex; align-items: center;
    border-radius: 6px; transition: background .15s;
}
.lsc-close-btn:hover { background: rgba(255,255,255,.2); }
.lsc-close-btn svg   { width: 18px; height: 18px; }

/* ── Messages ── */
.lsc-messages {
    flex: 1; overflow-y: auto;
    padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
    min-height: 160px; max-height: 280px;
    background: #f8fafc;
}

.lsc-msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 12px;
    font-size: .88rem; line-height: 1.45;
    word-break: break-word;
    animation: lsc-msg-in .2s ease;
}
@keyframes lsc-msg-in { from{opacity:0;transform:scale(.96)} to{opacity:1;transform:scale(1)} }

.lsc-msg.visitor { background: #fff; border: 1px solid #e2e8f0; align-self: flex-end; }
.lsc-msg.chatter { background: #2563eb; color: #fff; align-self: flex-start; }
.lsc-msg.system  { background: none; color: #94a3b8; font-size: .78rem; align-self: center; font-style: italic; }

.lsc-msg-time { font-size: .7rem; opacity: .6; margin-top: 3px; text-align: right; }
.lsc-msg.chatter .lsc-msg-time { color: rgba(255,255,255,.7); }

/* ── Visitor info inputs ── */
.lsc-visitor-info {
    padding: 10px 12px 0;
    display: flex; flex-direction: column; gap: 6px;
}
.lsc-info-input {
    width: 100%; padding: 7px 10px;
    border: 1px solid #e2e8f0; border-radius: 8px;
    font-size: .83rem; outline: none; box-sizing: border-box;
    transition: border-color .2s;
}
.lsc-info-input:focus { border-color: #2563eb; }

/* ── Input row ── */
.lsc-chat-input-area { border-top: 1px solid #e2e8f0; background: #fff; padding-bottom: 6px; }
.lsc-input-row { display: flex; gap: 8px; padding: 10px 12px 6px; align-items: flex-end; }

.lsc-message-input {
    flex: 1; padding: 9px 12px;
    border: 1px solid #e2e8f0; border-radius: 10px;
    font-size: .9rem; resize: none; outline: none;
    font-family: inherit; line-height: 1.4;
    transition: border-color .2s; max-height: 100px;
}
.lsc-message-input:focus { border-color: #2563eb; }

.lsc-send-btn {
    width: 38px; height: 38px; border-radius: 10px;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: filter .15s, transform .15s;
}
#lsc-chat-wrapper.lsc-online  .lsc-send-btn { background: #16a34a; color: #fff; }
#lsc-chat-wrapper.lsc-offline .lsc-send-btn { background: #94a3b8; color: #fff; cursor: not-allowed; }
.lsc-send-btn:hover:not(:disabled) { filter: brightness(1.1); transform: scale(1.05); }
.lsc-send-btn svg { width: 17px; height: 17px; }

/* ── Offline notice ── */
.lsc-offline-notice {
    padding: 12px 16px;
    background: #fef9c3; font-size: .82rem; color: #713f12;
    text-align: center; border-bottom: 1px solid #fde68a;
}
