/* 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(34,197,94,0.4);
    transition: border-color 0.3s;
}

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

@keyframes rsa-avatar-glow {
    from { box-shadow: 0 0 8px rgba(34,197,94,0.15); }
    to   { box-shadow: 0 0 20px rgba(34,197,94,0.5); }
}

.rsa-shield-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 4px;
    filter: drop-shadow(0 0 4px rgba(218,165,32,0.4));
}

.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-mute-btn {
    background: none;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    color: #8ab4f8;
    padding: 0;
}

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

.rsa-mute-btn.rsa-muted .rsa-mute-waves {
    display: none;
}

.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;
}


/* ── Mic Button (Voice) ───────────────────────────── */

.rsa-mic-btn {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8ab4f8;
    padding: 0;
    flex-shrink: 0;
    transition: color 0.15s;
    border-radius: 50%;
}

.rsa-mic-btn:hover {
    color: #ffffff;
}

.rsa-mic-btn.rsa-listening {
    color: #22c55e;
    animation: rsa-mic-pulse 1.2s ease-in-out infinite;
}

@keyframes rsa-mic-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.15); opacity: 0.7; }
}
/* ── Play/Pause Button ────────────────────────────── */

.rsa-message-agent {
    position: relative;
}

.rsa-play-btn {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,0.25);
    background: rgba(0,0,0,0.35);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0.35;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
    z-index: 2;
}

.rsa-message-agent:hover .rsa-play-btn {
    opacity: 1;
}

.rsa-play-btn:hover {
    background: rgba(0,0,0,0.55);
    border-color: rgba(255,255,255,0.5);
    color: #fff;
}

/* ── 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: #22c55e;
}

.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;
    }
}

/* ── Link Cards (3rd Agent) ── */
.rsa-link-cards {
    margin: 8px 0 12px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rsa-link-card {
    display: flex;
    align-items: center;
    height: 60px;
    background: #12122a;
    border: 1px solid #2a2a4a;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}

.rsa-link-card:hover {
    border-color: #f97316;
    background: #1a1a38;
}

.rsa-card-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    flex-shrink: 0;
    background: #1a1a2e;
}

.rsa-card-thumb-fallback {
    background: linear-gradient(135deg, #1a1a3a 0%, #2a2a5a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.rsa-card-thumb-fallback::after {
    content: "\2197";
    color: #4a4a7a;
    font-size: 18px;
}

.rsa-card-body {
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.rsa-card-title {
    font-size: 12px;
    font-weight: 600;
    color: #e0e0f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.rsa-card-excerpt {
    font-size: 11px;
    color: #8888aa;
    line-height: 1.3;
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Quick Response Pills ── */
.rsa-quick-responses {
    display: flex;
    align-items: center;
    padding: 6px 0;
    position: relative;
}

.rsa-qr-chevron {
    background: rgba(255,255,255,0.06);
    border: none;
    color: #8ab4f8;
    font-size: 20px;
    width: 24px;
    height: 100%;
    cursor: pointer;
    flex-shrink: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}
.rsa-qr-chevron:hover { background: rgba(255,255,255,0.12); color: #fff; }
.rsa-qr-disabled { color: #3a3a5a; pointer-events: none; }

.rsa-qr-pills {
    flex: 1;
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    gap: 6px;
    padding: 0 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.rsa-qr-pills::-webkit-scrollbar { display: none; }

.rsa-qr-pill {
    display: inline-block;
    padding: 4px 12px;
    background: #1a1a38;
    border: 1px solid #2a2a5a;
    border-radius: 14px;
    color: #c0c0e0;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.rsa-qr-pill:hover {
    border-color: #f97316;
    background: #222248;
    color: #fff;
}
