/* ═══════════════════════════════════════════════════
   Slack Chat Widget — Frontend Styles v2.2
   ═══════════════════════════════════════════════════ */

/* ── Widget positioning ─────────────────────────── */
#sc-widget {
    position: fixed;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}
.sc-pos-bottom-right { bottom: 20px; right: 20px; }
.sc-pos-bottom-left  { bottom: 20px; left: 20px; }

/* Push widget above the cart banner when it is present on the page */
body:has(#cart-banner) .sc-pos-bottom-right,
body:has(#cart-banner) .sc-pos-bottom-left {
    bottom: 128px;
}
@media (min-width: 768px) {
    body:has(#cart-banner) .sc-pos-bottom-right,
    body:has(#cart-banner) .sc-pos-bottom-left {
        bottom: 150px;
    }
}

/* ── Main toggle button (opens chat) ──────────── */
#sc-toggle {
    width: 50px;
    height: 50px;
    margin-bottom: 10px;
    border-radius: 50%;
    border: none;
    background: var(--sc-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
    transition: transform .2s;
    position: relative;
    padding: 0;
}
#sc-toggle:hover {
    transform: scale(1.08);
}

/* Chat icon inside main button */
#sc-icon-chat {
    width: 25px;
    height: 25px;
}

/* Notification dot (unread messages) — hidden by default */
#sc-dot {
    display: none;
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #e74c3c;
    border-radius: 50%;
    border: 2px solid #fff;
}

/* Online indicator — only on main button */
#sc-online-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: #2ecc71;
}

/* ── Header action buttons (minimize + close) ──────────── */
#sc-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#sc-minimize {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1.5px solid #fff;
    background: transparent;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color .2s, transform .2s;
    padding: 0;
}
#sc-minimize:hover {
    background: rgba(255, 255, 255, .15);
    transform: scale(1.05);
}

#sc-icon-minimize,
#sc-icon-close {
    width: 16px;
    height: 16px;
}

/* ── Chat window ────────────────────────────────── */
#sc-window {
    display: none;
    width: 370px;
    max-height: 520px;
    flex-direction: column;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .18);
    overflow: hidden;
    margin-bottom: 12px;
}

/* ── Header ─────────────────────────────────────── */
#sc-header {
    background: var(--sc-header);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
#sc-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
#sc-header-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #2ecc71;
    flex-shrink: 0;
}
#sc-header-text strong {
    display: block;
    font-size: 15px;
}
#sc-header-text small {
    opacity: .8;
    font-size: 12px;
}
#sc-end-btn {
    width: 26px;
    height: 26px;
    background: transparent;
    border: 1.5px solid #fff;
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color .2s, transform .2s;
}
#sc-end-btn:hover {
    background: rgba(255, 255, 255, .15);
    transform: scale(1.05);
}

/* ── Messages ───────────────────────────────────── */
#sc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    min-height: 200px;
    max-height: 320px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sc-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    word-wrap: break-word;
    animation: sc-fade .25s ease;
}
.sc-msg-user {
    align-self: flex-end;
    background: var(--sc-user-bg);
    color: var(--sc-user-text);
    border-bottom-right-radius: 4px;
}
.sc-msg-admin {
    align-self: flex-start;
    background: var(--sc-admin-bg);
    color: var(--sc-admin-text);
    border-bottom-left-radius: 4px;
}
.sc-msg small {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    opacity: .6;
}
@keyframes sc-fade {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Typing indicator — hidden by default ───────── */
#sc-typing {
    display: none;
    padding: 6px 16px;
    gap: 4px;
    align-items: center;
}
#sc-typing span {
    width: 6px;
    height: 6px;
    background: #bbb;
    border-radius: 50%;
    animation: sc-bounce .6s infinite alternate;
}
#sc-typing span:nth-child(2) { animation-delay: .15s; }
#sc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes sc-bounce {
    to { opacity: .3; transform: translateY(-4px); }
}

/* ── Input area ─────────────────────────────────── */
#sc-form {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    background: #fafafa;
}
#sc-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    transition: border-color .2s;
}
#sc-input:focus {
    border-color: var(--sc-primary);
}
#sc-send {
    background: var(--sc-btn);
    color: var(--sc-btn-text);
    border: none;
    border-radius: 20px;
    padding: 8px 18px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: opacity .2s;
}
#sc-send:hover {
    opacity: .9;
}
#sc-send:disabled {
    opacity: .5;
    cursor: default;
}

/* ── Ended state — hidden by default ────────────── */
#sc-ended {
    display: none;
    padding: 20px;
    text-align: center;
}
#sc-ended p {
    color: #666;
    margin-bottom: 12px;
}
#sc-new-chat {
    background: var(--sc-primary);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 20px;
    cursor: pointer;
    font-size: 13px;
}
#sc-new-chat:hover {
    opacity: .9;
}

/* ── Mobile responsive ──────────────────────────── */
@media (max-width: 440px) {
    #sc-window {
        width: calc(100vw - 32px);
        max-height: 70vh;
    }
}