/* ── SteamShop AI Chat Widget CSS ──────────────────────────── */
/* Brand: #DE3431 */

.ssai-widget *,
.ssai-toggle * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
}

/* ── Toggle bubble ─────────────────────────────────────────── */
.ssai-toggle {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(222,52,49,.35);
    z-index: 99998;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: #DE3431;
    color: #fff;
}
.ssai-toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 24px rgba(222,52,49,.45);
}
.ssai-toggle:active { transform: scale(0.97); }

/* ── Widget container ──────────────────────────────────────── */
.ssai-widget {
    position: fixed;
    bottom: 94px;
    left: 24px;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 48px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
    z-index: 99999;
    background: #fff;
    animation: ssai-slide-up 0.3s cubic-bezier(.21,1.02,.73,1);
}
@keyframes ssai-slide-up {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ────────────────────────────────────────────────── */
.ssai-widget__header {
    background: #DE3431;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 12px;
}
.ssai-widget__header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.ssai-widget__avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ssai-widget__header-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.ssai-widget__title {
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ssai-widget__status {
    font-size: 11px;
    opacity: .85;
    display: flex;
    align-items: center;
    gap: 5px;
    line-height: 1;
    margin-top: 2px;
}
.ssai-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
    flex-shrink: 0;
}
.ssai-status-dot--waiting {
    background: #fbbf24;
    animation: ssai-pulse-dot 1.2s infinite;
}
.ssai-status-dot--offline { background: #94a3b8; }
@keyframes ssai-pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: .3; }
}
.ssai-widget__header-right {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.ssai-header-btn {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.ssai-header-btn:hover { background: rgba(255,255,255,.28); }

/* ── Messages body ─────────────────────────────────────────── */
.ssai-widget__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f5f6f8;
}
.ssai-widget__loading {
    text-align: center;
    color: #999;
    font-size: 13px;
    padding: 40px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.ssai-loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e0e0e0;
    border-top-color: #DE3431;
    border-radius: 50%;
    animation: ssai-spin 0.7s linear infinite;
}
@keyframes ssai-spin { to { transform: rotate(360deg); } }

/* ── Message bubbles ───────────────────────────────────────── */
.ssai-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}
.ssai-msg--user {
    align-self: flex-end;
    background: #DE3431;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ssai-msg--assistant,
.ssai-msg--agent {
    align-self: flex-start;
    background: #fff;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.ssai-msg--system {
    align-self: center;
    background: transparent;
    color: #888;
    font-size: 12px;
    font-style: italic;
    padding: 6px 0;
    text-align: center;
    max-width: 90%;
}
.ssai-msg__sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 3px;
    opacity: .6;
}
.ssai-msg--assistant .ssai-msg__sender,
.ssai-msg--agent .ssai-msg__sender {
    color: #DE3431;
    opacity: 1;
}
.ssai-msg__time {
    font-size: 10px;
    opacity: .45;
    margin-top: 4px;
    text-align: right;
}

/* ── Typing indicator ──────────────────────────────────────── */
.ssai-typing {
    align-self: flex-start;
    background: #fff;
    padding: 12px 18px;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.ssai-typing__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #aaa;
    animation: ssai-typing-bounce 1.4s infinite;
}
.ssai-typing__dot:nth-child(2) { animation-delay: 0.15s; }
.ssai-typing__dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes ssai-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Agent request bar ─────────────────────────────────────── */
.ssai-widget__agent-bar {
    padding: 8px 14px;
    flex-shrink: 0;
    border-top: 1px solid #eaeaea;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #fff;
}
.ssai-btn-agent {
    color: #DE3431;
    background: transparent;
    border: none;
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
    transition: background .15s;
}
.ssai-btn-agent:hover { background: #fef2f2; }
.ssai-btn-agent:disabled { opacity: .5; cursor: default; }

/* ── Input area ────────────────────────────────────────────── */
.ssai-widget__input-area {
    display: flex;
    align-items: flex-end;
    padding: 10px 12px 12px;
    border-top: 1px solid #eaeaea;
    background: #fff;
    flex-shrink: 0;
    gap: 8px;
}
.ssai-widget__input {
    flex: 1;
    border: 1.5px solid #e0e0e0;
    border-radius: 12px;
    padding: 9px 14px;
    font-size: 13.5px;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    background: #fafafa;
}
.ssai-widget__input:focus {
    border-color: #DE3431;
    box-shadow: 0 0 0 3px rgba(222,52,49,.1);
    background: #fff;
}
.ssai-widget__send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, transform .1s, opacity .15s;
    background: #DE3431;
    color: #fff;
}
.ssai-widget__send-btn:hover:not(:disabled) { background: #c72e2b; }
.ssai-widget__send-btn:active:not(:disabled) { transform: scale(0.93); }
.ssai-widget__send-btn:disabled { opacity: .35; cursor: default; background: #ccc; }
.ssai-widget__send-btn svg { fill: currentColor; }

/* ── Modal ─────────────────────────────────────────────────── */
.ssai-modal {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(2px);
}
.ssai-modal__content {
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px;
    max-width: 280px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.ssai-modal__icon { margin-bottom: 12px; display: flex; justify-content: center; }
.ssai-modal__content p { margin: 0 0 20px; font-size: 14px; color: #333; line-height: 1.5; }
.ssai-modal__actions { display: flex; gap: 10px; justify-content: center; }
.ssai-btn {
    border: none;
    padding: 9px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: opacity .15s, transform .1s;
}
.ssai-btn:active { transform: scale(0.96); }
.ssai-btn--primary { background: #DE3431; color: #fff; }
.ssai-btn--primary:hover { background: #c72e2b; }
.ssai-btn--secondary { background: #f0f0f0; color: #555; }
.ssai-btn--secondary:hover { background: #e5e5e5; }

/* ── Waiting indicator ─────────────────────────────────────── */
.ssai-waiting-indicator {
    align-self: center;
    font-size: 12px;
    color: #888;
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: ssai-pulse 1.5s infinite;
}
@keyframes ssai-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}

/* ── Welcome ──────────────────────────────────────────────── */
.ssai-welcome {
    text-align: center;
    padding: 20px 10px 10px;
}
.ssai-welcome__icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #fef2f2;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}
.ssai-welcome__title { font-size: 15px; font-weight: 600; color: #1a1a1a; margin-bottom: 4px; }
.ssai-welcome__text { font-size: 12.5px; color: #888; line-height: 1.4; }

/* ── Scrollbar ─────────────────────────────────────────────── */
.ssai-widget__body::-webkit-scrollbar { width: 5px; }
.ssai-widget__body::-webkit-scrollbar-track { background: transparent; }
.ssai-widget__body::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 3px; }
.ssai-widget__body::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .ssai-widget { bottom: 0; left: 0; width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
    .ssai-toggle { bottom: 16px; left: 16px; width: 52px; height: 52px; }
}
