/* R1 Service Avatar — Chat Widget v1.0 by RESTONE */

/* ── Floating Bubble ──────────────────────────────── */

.rsa-floating {
    position: fixed;
    bottom: 36px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.rsa-bubble-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.rsa-bubble-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0,0,0,0.45);
}

.rsa-bubble-btn:active {
    transform: scale(0.96);
}

/* Pulsing dot indicator */
.rsa-bubble-btn::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #fff;
    animation: rsa-pulse 2s infinite;
}

@keyframes rsa-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.6; transform: scale(0.85); }
}

/* ── Chat Window ──────────────────────────────────── */

.rsa-chat-window {
    position: fixed;
    bottom: 108px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 560px;
    max-height: calc(100vh - 140px);
    border-radius: 14px;
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    overflow: hidden;
    display: none;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    animation: rsa-slide-up 0.25s ease;
}

.rsa-chat-window.open {
    display: flex;
}

@keyframes rsa-slide-up {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ───────────────────────────────────────── */

.rsa-chat-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, #16213e 0%, #1a1a2e 100%);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.rsa-avatar-canvas {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(249,115,22,0.4);
    transition: border-color 0.3s;
}

.rsa-avatar-canvas.rsa-listening {
    border-color: #f97316;
    box-shadow: 0 0 12px rgba(249,115,22,0.3);
    animation: rsa-avatar-glow 0.6s ease-in-out infinite alternate;
}

@keyframes rsa-avatar-glow {
    from { box-shadow: 0 0 8px rgba(249,115,22,0.2); }
    to   { box-shadow: 0 0 20px rgba(249,115,22,0.5); }
}

.rsa-header-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.rsa-chat-title {
    font-size: 15px;
    font-weight: 700;
    color: #e8eaed;
}

.rsa-chat-subtitle {
    font-size: 11px;
    font-weight: 400;
    color: #8ab4f8;
}

.rsa-header-actions {
    margin-left: auto;
    display: flex;
    gap: 4px;
    align-items: center;
}

.rsa-new-chat-btn,
.rsa-close-btn {
    background: none;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    color: #8ab4f8;
    padding: 0;
}

.rsa-close-btn { font-size: 22px; }

.rsa-new-chat-btn:hover,
.rsa-close-btn:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

/* ── Messages ─────────────────────────────────────── */

.rsa-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.rsa-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.rsa-chat-messages::-webkit-scrollbar-thumb {
    border-radius: 3px;
    background: #3a3a5a;
}

.rsa-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: rsa-msg-in 0.2s ease;
}

@keyframes rsa-msg-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rsa-message-agent {
    align-self: flex-start;
}

.rsa-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.rsa-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
}

.rsa-user-avatar {
    background: linear-gradient(135deg, #f7a44a, #f7d08a);
}

.rsa-bubble {
    padding: 10px 13px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.rsa-message-agent .rsa-bubble {
    background: #2a2a4a;
    color: #e8eaed;
    border-bottom-left-radius: 4px;
}

.rsa-message-user .rsa-bubble {
    background: #3a4f8a;
    color: #e8eaed;
    border-bottom-right-radius: 4px;
}

.rsa-bubble a {
    color: #8ab4f8;
    text-decoration: underline;
}

.rsa-bubble code {
    background: rgba(255,255,255,0.08);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}

.rsa-bubble strong {
    color: #f97316;
}

/* ── Input Area ───────────────────────────────────── */

.rsa-chat-input-area {
    display: flex;
    padding: 10px 14px;
    gap: 8px;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: #1a1a2e;
    flex-shrink: 0;
}

.rsa-chat-input {
    flex: 1;
    border: 1px solid #3a3a5a;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    outline: none;
    background: #2a2a4a;
    color: #e8eaed;
    transition: border-color 0.15s;
    min-width: 0;
}

.rsa-chat-input:focus {
    border-color: #f97316;
}

.rsa-chat-input::placeholder {
    color: #6a6a8a;
}

.rsa-send-btn {
    border: none;
    border-radius: 8px;
    padding: 9px 13px;
    cursor: pointer;
    background: #f97316;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.rsa-send-btn:hover {
    background: #ea580c;
}

.rsa-send-btn:active {
    transform: scale(0.95);
}

.rsa-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #6a6a8a;
}

/* ── Typing Indicator ─────────────────────────────── */

.rsa-typing {
    display: flex;
    gap: 4px;
    padding: 8px 18px;
    align-items: center;
    flex-shrink: 0;
    background: #1a1a2e;
}

.rsa-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f97316;
    animation: rsa-bounce 1.2s infinite;
}

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

@keyframes rsa-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Responsive (Mobile) ──────────────────────────── */

@media (max-width: 480px) {
    .rsa-floating {
        bottom: 12px;
        right: 12px;
    }
    .rsa-bubble-btn {
        width: 50px;
        height: 50px;
    }
    .rsa-chat-window {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 100dvh;
        max-width: none;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        animation: rsa-slide-up-mobile 0.2s ease;
    }
    @keyframes rsa-slide-up-mobile {
        from { opacity: 0; transform: translateY(10px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .rsa-chat-header {
        padding: 12px 14px;
        flex-shrink: 0;
    }
    .rsa-chat-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .rsa-chat-input-area {
        padding: 8px 12px;
        flex-shrink: 0;
    }
    .rsa-chat-input {
        font-size: 16px; /* prevent iOS zoom */
    }
    .rsa-close-btn {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
}
