/* =============================================================================
   Live Support Chat – Chatter Login & Dashboard
   Fully responsive: desktop sidebar + mobile drawer
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─────────────────────────────────────────────────────────────────────────────
   LOGIN
   ───────────────────────────────────────────────────────────────────────────── */
.lsc-login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    background-image: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(37,99,235,.35) 0%, transparent 70%);
    padding: 24px;
    font-family: 'Inter', system-ui, sans-serif;
}
.lsc-login-box {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 20px;
    padding: 44px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 32px 80px rgba(0,0,0,.5);
}
@media (max-width: 480px) {
    .lsc-login-box { padding: 32px 24px; border-radius: 16px; }
}
.lsc-login-logo {
    display: flex; align-items: center; gap: 12px; margin-bottom: 32px;
}
.lsc-login-logo span { font-size: 1rem; font-weight: 700; color: #f1f5f9; letter-spacing: -.02em; }
.lsc-login-box h2 { font-size: 1.6rem; font-weight: 700; color: #f8fafc; letter-spacing: -.03em; margin-bottom: 28px; }

.lsc-alert {
    padding: 12px 16px; border-radius: 10px; font-size: .875rem;
    margin-bottom: 22px; display: flex; align-items: center; gap: 8px;
}
.lsc-alert-error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.lsc-alert-error::before { content: '⚠'; font-size: 1rem; }

.lsc-form-group { margin-bottom: 20px; }
.lsc-form-group label {
    display: block; font-size: .8rem; font-weight: 600; color: #94a3b8;
    text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px;
}
.lsc-form-control {
    width: 100%; padding: 12px 16px; background: #0f172a;
    border: 1.5px solid #334155; border-radius: 10px;
    font-size: .95rem; color: #f1f5f9; outline: none;
    transition: border-color .2s, box-shadow .2s; font-family: inherit;
}
.lsc-form-control::placeholder { color: #475569; }
.lsc-form-control:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.2); }

.lsc-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; padding: 13px 24px; border: none; border-radius: 10px;
    font-size: .95rem; font-weight: 600; cursor: pointer;
    transition: all .2s; font-family: inherit; text-decoration: none;
}
.lsc-btn-primary { background: #2563eb; color: #fff; box-shadow: 0 4px 14px rgba(37,99,235,.4); }
.lsc-btn-primary:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,.5); }
.lsc-btn-full { width: 100%; }

/* ─────────────────────────────────────────────────────────────────────────────
   DASHBOARD SHELL
   ───────────────────────────────────────────────────────────────────────────── */
.lsc-chatter-wrap {
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-family: 'Inter', system-ui, sans-serif;
    background: #f8fafc;
    color: #1e293b;
    position: relative;
}

/* ─── MOBILE OVERLAY ─────────────────────────────────────────────────────── */
.lsc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 200;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.lsc-overlay.active { display: block; }

/* ─── SIDEBAR ─────────────────────────────────────────────────────────────── */
.lsc-sidebar {
    width: 300px;
    min-width: 300px;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid #1e293b;
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 210;
    flex-shrink: 0;
}

/* Mobile: sidebar is a fixed drawer */
@media (max-width: 768px) {
    .lsc-sidebar {
        position: fixed;
        inset: 0;
        width: min(320px, 85vw);
        min-width: 0;
        transform: translateX(-100%);
        box-shadow: 4px 0 32px rgba(0,0,0,.4);
    }
    .lsc-sidebar.open {
        transform: translateX(0);
    }
}

/* Sidebar header */
.lsc-sidebar-header { padding: 20px 20px 0; flex-shrink: 0; }

.lsc-brand {
    display: flex; align-items: center; gap: 10px;
    padding-bottom: 18px; border-bottom: 1px solid #1e293b;
}
.lsc-brand-name { font-size: .9rem; font-weight: 700; color: #f8fafc; flex: 1; }

/* Sidebar close button (mobile only) */
.lsc-sidebar-close {
    display: none;
    background: none; border: none; cursor: pointer;
    color: #64748b; padding: 4px; border-radius: 6px;
    transition: color .15s, background .15s;
}
.lsc-sidebar-close:hover { color: #f1f5f9; background: #1e293b; }
@media (max-width: 768px) { .lsc-sidebar-close { display: flex; align-items: center; } }

/* Agent card */
.lsc-agent-card {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 0; border-bottom: 1px solid #1e293b;
}
.lsc-avatar-lg {
    width: 40px; height: 40px; border-radius: 10px;
    background: linear-gradient(135deg,#2563eb,#7c3aed);
    color: #fff; font-weight: 700; font-size: 1rem;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.lsc-agent-name { font-weight: 600; font-size: .88rem; color: #f1f5f9; }
.lsc-agent-role { font-size: .73rem; color: #64748b; margin-top: 1px; }

/* Status pill */
.lsc-status-pill {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 7px 12px; border-radius: 20px;
    font-size: .75rem; font-weight: 600; margin: 14px 0 0;
}
.lsc-status-pill-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.lsc-status-online  { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.25); color: #4ade80; }
.lsc-status-online  .lsc-status-pill-dot { background: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,.3); animation: lsc-blink 2s infinite; }
.lsc-status-offline { background: rgba(100,116,139,.12); border: 1px solid rgba(100,116,139,.25); color: #94a3b8; }
.lsc-status-offline .lsc-status-pill-dot { background: #64748b; }
@keyframes lsc-blink { 0%,100%{opacity:1} 50%{opacity:.35} }

/* Section label */
.lsc-section-label {
    padding: 16px 20px 8px;
    font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .1em; color: #475569;
    display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.lsc-badge-count {
    background: #2563eb; color: #fff; font-size: .65rem; font-weight: 700;
    min-width: 18px; height: 18px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}

/* Chat list */
.lsc-chat-list { flex: 1; overflow-y: auto; padding: 4px 10px 10px; }
.lsc-chat-list::-webkit-scrollbar { width: 4px; }
.lsc-chat-list::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.lsc-chat-list-empty {
    display: flex; flex-direction: column; align-items: center;
    padding: 48px 20px; gap: 10px; color: #334155; text-align: center;
}
.lsc-chat-list-empty p { font-size: .83rem; color: #475569; }

/* Chat item */
.lsc-chat-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 10px; border-radius: 12px; cursor: pointer;
    transition: background .15s; position: relative; margin-bottom: 2px;
}
.lsc-chat-item:hover  { background: #1e293b; }
.lsc-chat-item.active { background: #1e3a5f; }

.lsc-chat-avatar {
    width: 40px; height: 40px; border-radius: 10px;
    background: #1e3a5f; border: 1px solid #2d4a6e;
    color: #60a5fa; font-weight: 700; font-size: .9rem;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.lsc-chat-item.active .lsc-chat-avatar { background: #2563eb; border-color: #3b82f6; color: #fff; }

.lsc-chat-item-body { flex: 1; min-width: 0; }
.lsc-chat-item-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.lsc-chat-item-name { font-weight: 600; font-size: .85rem; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lsc-chat-item-time { font-size: .7rem; color: #475569; flex-shrink: 0; margin-left: 6px; }
.lsc-chat-item-sub  { font-size: .75rem; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lsc-unread-pip {
    width: 20px; height: 20px; border-radius: 10px;
    background: #2563eb; color: #fff; font-size: .65rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(37,99,235,.25);
}

/* Sidebar footer */
.lsc-sidebar-footer { padding: 14px 20px; border-top: 1px solid #1e293b; flex-shrink: 0; }
.lsc-logout-btn {
    display: flex; align-items: center; gap: 8px;
    color: #475569; text-decoration: none; font-size: .83rem; font-weight: 500;
    padding: 8px 10px; border-radius: 8px; transition: all .15s; width: 100%;
}
.lsc-logout-btn:hover { background: rgba(239,68,68,.1); color: #f87171; }

/* ─── MAIN PANEL ──────────────────────────────────────────────────────────── */
.lsc-main-panel {
    flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0;
}

/* Mobile top bar (hidden on desktop) */
.lsc-mobile-topbar {
    display: none;
    align-items: center; gap: 12px;
    padding: 0 16px;
    height: 56px;
    background: #0f172a;
    border-bottom: 1px solid #1e293b;
    flex-shrink: 0;
}
@media (max-width: 768px) { .lsc-mobile-topbar { display: flex; } }

.lsc-mobile-title { font-size: .9rem; font-weight: 700; color: #f1f5f9; flex: 1; }

.lsc-mobile-unread {
    background: #ef4444; color: #fff;
    font-size: .7rem; font-weight: 700;
    min-width: 20px; height: 20px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; padding: 0 6px;
}

/* Hamburger button */
.lsc-hamburger {
    display: flex; flex-direction: column; justify-content: center;
    gap: 5px; width: 36px; height: 36px;
    background: none; border: none; cursor: pointer; padding: 6px; border-radius: 8px;
    transition: background .15s;
}
.lsc-hamburger:hover { background: #1e293b; }
.lsc-hamburger span {
    display: block; width: 20px; height: 2px;
    background: #94a3b8; border-radius: 2px;
    transition: all .25s;
}

/* Back button (mobile, inside active chat topbar) */
.lsc-back-btn {
    display: none;
    background: none; border: none; cursor: pointer;
    color: #64748b; padding: 6px; border-radius: 8px;
    transition: color .15s, background .15s; flex-shrink: 0;
}
.lsc-back-btn:hover { color: #1e293b; background: #f1f5f9; }
@media (max-width: 768px) { .lsc-back-btn { display: flex; align-items: center; } }

/* Empty state */
.lsc-main-empty {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px; padding: 40px; text-align: center;
}
.lsc-empty-icon {
    width: 72px; height: 72px; border-radius: 20px;
    background: #e2e8f0; display: flex; align-items: center; justify-content: center;
}
.lsc-main-empty h3 { font-size: 1.05rem; font-weight: 600; color: #64748b; }
.lsc-main-empty p  { font-size: .875rem; color: #94a3b8; }

.lsc-open-sidebar-btn {
    display: none; /* shown only on mobile via media query */
    align-items: center; gap: 6px;
    padding: 10px 20px; border-radius: 10px;
    background: #0f172a; color: #f1f5f9;
    border: none; cursor: pointer; font-size: .875rem; font-weight: 600;
    font-family: inherit; transition: background .15s; margin-top: 8px;
}
.lsc-open-sidebar-btn:hover { background: #1e293b; }
@media (max-width: 768px) { .lsc-open-sidebar-btn { display: inline-flex; } }

/* Active chat */
.lsc-active-chat { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* Chat topbar */
.lsc-chat-topbar {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 20px;
    background: #fff; border-bottom: 1px solid #e2e8f0; flex-shrink: 0;
}
@media (max-width: 768px) {
    .lsc-chat-topbar { padding: 10px 14px; }
}

.lsc-topbar-visitor { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.lsc-topbar-avatar {
    width: 40px; height: 40px; border-radius: 10px;
    background: linear-gradient(135deg,#2563eb,#7c3aed);
    color: #fff; font-weight: 700; font-size: .95rem;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.lsc-topbar-name  { font-weight: 700; font-size: .95rem; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lsc-topbar-email { font-size: .75rem; color: #94a3b8; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lsc-topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.lsc-tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 10px; border-radius: 6px; font-size: .73rem; font-weight: 600;
    white-space: nowrap;
}
.lsc-tag-green { background: #dcfce7; color: #166534; }

/* Hide the "Active" tag on very small screens */
@media (max-width: 400px) { .lsc-tag { display: none; } }

.lsc-close-chat-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 7px 12px; border: 1.5px solid #e2e8f0; border-radius: 8px;
    background: #fff; cursor: pointer; font-size: .8rem; font-weight: 600;
    color: #64748b; transition: all .15s; font-family: inherit; white-space: nowrap;
}
.lsc-close-chat-btn:hover { border-color: #ef4444; color: #ef4444; background: #fff1f1; }

/* Hide "Close" text label on small screens, keep icon */
@media (max-width: 480px) { .lsc-close-label { display: none; } }

/* Desktop only helpers */
@media (max-width: 768px) { .lsc-desktop-only { display: none !important; } }

/* Messages panel */
.lsc-messages-panel {
    flex: 1; overflow-y: auto; padding: 20px;
    display: flex; flex-direction: column; gap: 14px; background: #f8fafc;
}
.lsc-messages-panel::-webkit-scrollbar { width: 4px; }
.lsc-messages-panel::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }
@media (max-width: 768px) {
    .lsc-messages-panel { padding: 14px; gap: 12px; }
}

/* Message bubbles */
.lsc-ch-msg { display: flex; flex-direction: column; max-width: 70%; animation: lsc-msg-in .2s ease; }
@keyframes lsc-msg-in { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }
.lsc-ch-msg.visitor { align-self: flex-start; }
.lsc-ch-msg.chatter { align-self: flex-end; }

@media (max-width: 768px) {
    .lsc-ch-msg { max-width: 88%; }
}

.lsc-ch-msg-row { display: flex; align-items: flex-end; gap: 8px; }
.lsc-ch-msg.chatter .lsc-ch-msg-row { flex-direction: row-reverse; }

.lsc-msg-icon {
    width: 26px; height: 26px; border-radius: 7px;
    font-size: .68rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.lsc-ch-msg.visitor .lsc-msg-icon { background: #e2e8f0; color: #64748b; }
.lsc-ch-msg.chatter .lsc-msg-icon { background: #2563eb; color: #fff; }

/* Hide icons on mobile to save space */
@media (max-width: 480px) { .lsc-msg-icon { display: none; } }

.lsc-ch-msg-bubble {
    padding: 11px 15px; border-radius: 16px;
    font-size: .9rem; line-height: 1.55; word-break: break-word;
}
.lsc-ch-msg.visitor .lsc-ch-msg-bubble {
    background: #fff; color: #1e293b; border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.lsc-ch-msg.chatter .lsc-ch-msg-bubble {
    background: #2563eb; color: #fff;
    border-bottom-right-radius: 4px; box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
@media (max-width: 768px) {
    .lsc-ch-msg-bubble { font-size: .875rem; padding: 10px 14px; }
}

.lsc-ch-msg-time { font-size: .7rem; color: #94a3b8; margin-top: 4px; padding: 0 4px; }
.lsc-ch-msg.chatter .lsc-ch-msg-time { text-align: right; }

/* Reply box */
.lsc-reply-box {
    background: #fff; border-top: 1px solid #e2e8f0;
    padding: 14px 18px; flex-shrink: 0;
}
@media (max-width: 768px) {
    .lsc-reply-box { padding: 10px 12px; }
}

.lsc-reply-inner {
    display: flex; gap: 10px; align-items: flex-end;
    background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 14px;
    padding: 4px 4px 4px 14px; transition: border-color .2s, box-shadow .2s;
}
.lsc-reply-inner:focus-within {
    border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.1); background: #fff;
}
.lsc-reply-input {
    flex: 1; padding: 10px 0; border: none; background: transparent;
    font-size: .9rem; color: #1e293b; resize: none; outline: none;
    font-family: inherit; line-height: 1.5; max-height: 100px;
}
.lsc-reply-input::placeholder { color: #94a3b8; }
.lsc-reply-send-btn {
    width: 40px; height: 40px; border-radius: 10px; border: none;
    background: #2563eb; color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: all .15s; box-shadow: 0 2px 8px rgba(37,99,235,.35);
}
.lsc-reply-send-btn:hover  { background: #1d4ed8; transform: scale(1.06); }
.lsc-reply-send-btn:disabled { background: #cbd5e1; cursor: not-allowed; transform: none; box-shadow: none; }
.lsc-reply-hint { font-size: .71rem; color: #94a3b8; margin-top: 7px; text-align: right; }

/* Safe area padding for iOS home bar */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .lsc-reply-box { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}

/* ─── TOAST ──────────────────────────────────────────────────────────────── */
.lsc-toast {
    position: fixed; top: 20px; right: 20px;
    background: #0f172a; color: #f1f5f9;
    padding: 12px 14px; border-radius: 14px;
    font-size: .875rem; font-weight: 500;
    box-shadow: 0 10px 32px rgba(0,0,0,.35);
    z-index: 9999;
    display: flex; align-items: center; gap: 12px;
    animation: lsc-toast-in .3s cubic-bezier(.34,1.56,.64,1);
    border: 1px solid #1e293b; max-width: 300px;
}
@keyframes lsc-toast-in { from{opacity:0;transform:translateX(20px) scale(.95)} to{opacity:1;transform:none} }
@media (max-width: 480px) {
    .lsc-toast { top: auto; bottom: 80px; right: 12px; left: 12px; max-width: none; }
}
.lsc-toast-icon {
    width: 32px; height: 32px; border-radius: 9px;
    background: #2563eb; display: flex; align-items: center;
    justify-content: center; flex-shrink: 0; font-size: .95rem;
}
.lsc-toast-body { flex: 1; min-width: 0; }
.lsc-toast-title { font-weight: 700; font-size: .83rem; }
.lsc-toast-sub   { font-size: .73rem; color: #64748b; margin-top: 1px; }
.lsc-toast-close {
    background: none; border: none; color: #475569;
    cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 2px; flex-shrink: 0;
}
.lsc-toast-close:hover { color: #f1f5f9; }
