/* ── Launch button ─────────────────────────────────────── */
#simplechat-button {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    background: #2563eb;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#simplechat-button:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.55);
}

#simplechat-button svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Unread badge */
#simplechat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    background: #ef4444;
    color: #fff;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    padding: 0 4px;
    display: none;
    border: 2px solid #fff;
}

/* ── Chat window ───────────────────────────────────────── */
#simplechat-box {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    display: none;
    /* shown via JS: display:flex */
    animation: sc-slide-up 0.22s ease;
}

@keyframes sc-slide-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ────────────────────────────────────────────── */
#simplechat-header {
    padding: 0 16px;
    height: 60px;
    background: #2563eb;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

#simplechat-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#simplechat-avatar svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#simplechat-header-text {
    flex: 1;
    min-width: 0;
}

#simplechat-header-title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#simplechat-header-sub {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 1px;
}

#simplechat-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

#simplechat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

#simplechat-close svg {
    width: 16px;
    height: 16px;
    stroke: #fff;
    stroke-width: 2.5;
    stroke-linecap: round;
}

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

#simplechat-messages::-webkit-scrollbar {
    width: 4px;
}

#simplechat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#simplechat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Empty state */
#simplechat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    gap: 8px;
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

#simplechat-empty svg {
    width: 40px;
    height: 40px;
    stroke: #cbd5e1;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Bubbles */
.sc-msg {
    display: flex;
    flex-direction: column;
    max-width: 78%;
    gap: 3px;
}

.sc-msg.customer {
    align-self: flex-end;
    align-items: flex-end;
}

.sc-msg.admin {
    align-self: flex-start;
    align-items: flex-start;
}

.sc-bubble {
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
}

.sc-msg.customer .sc-bubble {
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.sc-msg.admin .sc-bubble {
    background: #fff;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.sc-time {
    font-size: 10px;
    color: #94a3b8;
    padding: 0 4px;
}

/* ── Typing indicator ──────────────────────────────────── */
#simplechat-typing {
    display: none;
    align-self: flex-start;
    padding: 8px 14px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    gap: 4px;
    align-items: center;
}

#simplechat-typing span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    display: inline-block;
    animation: sc-bounce 1.2s infinite ease-in-out;
}

#simplechat-typing span:nth-child(2) { animation-delay: 0.2s; }
#simplechat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sc-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-5px); }
}

/* ── Input area ────────────────────────────────────────── */
#simplechat-input {
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

#simplechat-input textarea {
    flex: 1;
    min-height: 40px;
    max-height: 100px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    resize: none;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.4;
    color: #1e293b;
    background: #f8fafc;
    transition: border-color 0.15s;
    overflow-y: auto;
}

#simplechat-input textarea:focus {
    outline: none;
    border-color: #2563eb;
    background: #fff;
}

#simplechat-input textarea::placeholder {
    color: #94a3b8;
}

#simplechat-send {
    width: 40px;
    height: 40px;
    background: #2563eb;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}

#simplechat-send:hover {
    background: #1d4ed8;
}

#simplechat-send:active {
    transform: scale(0.93);
}

#simplechat-send svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 400px) {
    #simplechat-box {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    #simplechat-button {
        right: 16px;
        bottom: 16px;
    }
}
