/* ==========================================================================
   Radio One - Front-End Live Support Chat Widget
   ========================================================================== */

:root {
    --ro-chat-red: #dc2626;
    --ro-chat-red-dark: #991b1b;
    --ro-chat-bg: #121216;
    --ro-chat-card: #18181f;
    --ro-chat-border: rgba(255, 255, 255, 0.1);
    --ro-chat-text: #f4f4f5;
    --ro-chat-muted: #a1a1aa;
    --ro-chat-online: #10b981;
}

/* Floating Launcher Button */
.ro-live-chat-launcher {
    position: fixed;
    bottom: 5.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    user-select: none;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ro-live-chat-launcher:hover {
    transform: translateY(-3px) scale(1.03);
}

.ro-live-chat-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    box-shadow: 0 10px 25px -3px rgba(220, 38, 38, 0.5), 0 4px 10px -2px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.25);
    position: relative;
    transition: all 0.3s ease;
}

.ro-live-chat-btn svg {
    width: 28px;
    height: 28px;
    stroke-width: 2;
    transition: transform 0.3s ease;
}

.ro-live-chat-btn .chat-icon-close {
    display: none;
}

.ro-live-chat-launcher.is-open .ro-live-chat-btn .chat-icon-open {
    display: none;
}

.ro-live-chat-launcher.is-open .ro-live-chat-btn .chat-icon-close {
    display: block;
}

/* Floating Staff Presence Pill */
.ro-chat-presence-pill {
    background: rgba(18, 18, 22, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    color: #f4f4f5;
    white-space: nowrap;
    pointer-events: auto;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ro-live-chat-launcher.is-open .ro-chat-presence-pill {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

.ro-presence-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--ro-chat-online);
    box-shadow: 0 0 10px var(--ro-chat-online);
    position: relative;
    flex-shrink: 0;
}

.ro-presence-dot.is-offline {
    background: #71717a;
    box-shadow: none;
}

.ro-presence-dot.is-online::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    border: 2px solid var(--ro-chat-online);
    opacity: 0.7;
    animation: ro-presence-pulse 2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes ro-presence-pulse {
    0% { transform: scale(0.9); opacity: 0.8; }
    70% { transform: scale(2); opacity: 0; }
    100% { transform: scale(2); opacity: 0; }
}

/* Badge for unread incoming messages */
.ro-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #fbbf24;
    color: #000000;
    font-size: 0.75rem;
    font-weight: 800;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border-radius: 999px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #18181f;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    animation: ro-bounce 0.5s ease infinite alternate;
}

.ro-chat-badge.show {
    display: flex;
}

@keyframes ro-bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-3px); }
}

/* Chat Window Box */
.ro-live-chat-window {
    position: fixed;
    bottom: 5.5rem;
    right: 1.5rem;
    width: 380px;
    max-width: calc(100vw - 2rem);
    height: 540px;
    max-height: calc(100vh - 7.5rem);
    background: var(--ro-chat-bg);
    border-radius: 1.25rem;
    border: 1px solid var(--ro-chat-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(220, 38, 38, 0.2);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ro-live-chat-window.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Chat Header */
.ro-chat-header {
    background: linear-gradient(135deg, #1f1f28 0%, #15151b 100%);
    border-bottom: 1px solid var(--ro-chat-border);
    padding: 0.9rem 1.15rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.ro-chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.ro-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #b91c1c 0%, #7f1d1d 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    flex-shrink: 0;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.ro-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ro-chat-meta {
    min-width: 0;
}

.ro-chat-title {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ro-chat-staff-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: #d1d5db;
    margin-top: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ro-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ro-chat-icon-btn {
    background: rgba(255, 255, 255, 0.06);
    border: none;
    border-radius: 0.5rem;
    color: #d1d5db;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ro-chat-icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

/* Chat Body / Messages Scroll Area */
.ro-chat-body {
    flex: 1;
    padding: 1rem 1.15rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    background: radial-gradient(circle at top right, rgba(220, 38, 38, 0.05) 0%, transparent 60%), #121216;
    scroll-behavior: smooth;
}

/* Welcome banner inside chat */
.ro-chat-welcome {
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 0.85rem;
    padding: 0.85rem 1rem;
    text-align: center;
    font-size: 0.82rem;
    color: #a1a1aa;
    line-height: 1.45;
}

.ro-chat-welcome strong {
    color: #ffffff;
    display: block;
    margin-bottom: 0.25rem;
}

/* Message Bubbles */
.ro-chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: ro-msg-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.ro-chat-msg.msg-visitor {
    align-self: flex-end;
    align-items: flex-end;
}

.ro-chat-msg.msg-staff {
    align-self: flex-start;
    align-items: flex-start;
}

.ro-msg-bubble {
    padding: 0.65rem 0.95rem;
    border-radius: 1rem;
    font-size: 0.88rem;
    line-height: 1.45;
    word-break: break-word;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.ro-chat-msg.msg-visitor .ro-msg-bubble {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #ffffff;
    border-bottom-right-radius: 0.25rem;
}

.ro-chat-msg.msg-staff .ro-msg-bubble {
    background: #24242e;
    color: #f4f4f5;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 0.25rem;
}

.ro-msg-info {
    font-size: 0.72rem;
    color: #71717a;
    margin-top: 0.25rem;
    padding: 0 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Real-Time Staff Typing Indicator */
.ro-chat-typing-indicator {
    display: none;
    align-items: center;
    gap: 0.5rem;
    align-self: flex-start;
    background: #24242e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    font-size: 0.78rem;
    color: #e4e4e7;
    margin-top: 0.25rem;
    animation: ro-msg-in 0.2s ease;
}

.ro-chat-typing-indicator.is-active {
    display: inline-flex;
}

.ro-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.ro-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ef4444;
    display: inline-block;
    animation: ro-dot-bounce 1.4s infinite ease-in-out both;
}

.ro-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.ro-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes ro-dot-bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Chat Footer / Input Controls */
.ro-chat-footer {
    padding: 0.75rem 1rem;
    background: #18181f;
    border-top: 1px solid var(--ro-chat-border);
}

.ro-chat-input-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #121216;
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.85rem;
    padding: 0.35rem 0.5rem 0.35rem 0.85rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ro-chat-input-form:focus-within {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

.ro-chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-family: inherit;
    font-size: 0.9rem;
    resize: none;
    height: 24px;
    max-height: 80px;
    line-height: 24px;
    padding: 0;
}

.ro-chat-input::placeholder {
    color: #71717a;
}

.ro-chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 0.65rem;
    background: #dc2626;
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ro-chat-send-btn:hover:not(:disabled) {
    background: #ef4444;
    transform: scale(1.05);
}

.ro-chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
    .ro-live-chat-launcher {
        bottom: 5.25rem;
        right: 1rem;
    }
    .ro-live-chat-btn {
        width: 52px;
        height: 52px;
    }
    .ro-chat-presence-pill {
        display: none; /* Keep launcher minimal on small mobile screens */
    }
    .ro-live-chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
    }
}
