/* ============================================================================
   RADIO CHAT — FAB bubble + sliding panel
   ============================================================================ */

/* ?? CSS Variables (theme-aware) ?? */
.rc-panel,
.rc-fab {
    --rc-primary: var(--neuro-primary, #00D9FF);
    --rc-accent: var(--neuro-accent, #FF6B9D);
    --rc-bg: var(--neuro-bg-secondary, #10101a);
    --rc-bg-elevated: var(--neuro-bg-elevated, rgba(255,255,255,0.05));
    --rc-bg-hover: var(--neuro-bg-hover, rgba(255,255,255,0.08));
    --rc-border: rgba(255,255,255,0.08);
    --rc-text: var(--neuro-text-primary, #fff);
    --rc-text-secondary: var(--neuro-text-secondary, rgba(255,255,255,0.7));
    --rc-text-muted: var(--neuro-text-muted, rgba(255,255,255,0.4));
    --rc-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 40px rgba(0,217,255,0.08);
}

body[data-theme="evil"] .rc-panel,
body[data-theme="evil"] .rc-fab {
    --rc-primary: var(--evil-primary, #FF0066);
    --rc-accent: var(--evil-accent, #FF6B00);
    --rc-bg: var(--evil-bg-secondary, #10010a);
    --rc-bg-elevated: var(--evil-bg-elevated);
    --rc-bg-hover: var(--evil-bg-hover);
    --rc-text: var(--evil-text-primary, #fff);
    --rc-text-secondary: var(--evil-text-secondary);
    --rc-text-muted: var(--evil-text-muted);
    --rc-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 40px rgba(255,0,102,0.08);
}

body[data-theme="twins"] .rc-panel,
body[data-theme="twins"] .rc-fab {
    --rc-primary: var(--twins-primary, #9D5CFF);
    --rc-accent: var(--twins-accent, #EC4899);
    --rc-bg: var(--twins-bg-secondary, #0d0818);
    --rc-bg-elevated: var(--twins-bg-elevated);
    --rc-bg-hover: var(--twins-bg-hover);
    --rc-text: var(--twins-text-primary, #fff);
    --rc-text-secondary: var(--twins-text-secondary);
    --rc-text-muted: var(--twins-text-muted);
    --rc-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 40px rgba(157,92,255,0.08);
}

/* ============================================================================
   FAB BUTTON
   ============================================================================ */

.rc-fab {
    position: fixed;
    bottom: calc(var(--global-player-height, 0px) + 18px);
    right: 20px;
    z-index: 900;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rc-primary), var(--rc-accent));
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 0 16px rgba(var(--rc-primary-rgb, 0,217,255), 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.rc-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0,0,0,0.5), 0 0 24px rgba(var(--rc-primary-rgb, 0,217,255), 0.4);
}

.rc-fab:active {
    transform: scale(0.94);
}

.rc-fab.rc-fab-open {
    box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 0 0 3px var(--rc-primary);
}

.rc-fab-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rc-fab-radio-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
}

.rc-radio-svg {
    width: 22px;
    height: 22px;
}

/* Unread badge */
.rc-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: #ff3d3d;
    border: 2px solid var(--rc-bg, #10101a);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    animation: rcBadgePop 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

.rc-fab-badge span {
    font-size: 0.625rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
}

/* Connection status dot */
.rc-fab-status {
    position: absolute;
    bottom: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--rc-bg, #10101a);
}

.rc-fab-status-connected { background: #22c55e; }
.rc-fab-status-reconnecting {
    background: #f59e0b;
    animation: rcStatusPulse 1s infinite;
}

/* FAB pulse animation for new messages */
.rc-fab-pulse {
    animation: rcFabPulse 0.6s ease;
}

@keyframes rcFabPulse {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.18); }
    65%  { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes rcBadgePop {
    0%   { transform: scale(0); opacity: 0; }
    70%  { transform: scale(1.25); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes rcStatusPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* ============================================================================
   PANEL
   ============================================================================ */

.rc-panel {
    position: fixed;
    bottom: calc(var(--global-player-height, 0px) + 82px);
    right: 20px;
    z-index: 901;
    width: 360px;
    /* Full usable height — top margin of 24px so it never clips the page top */
    height: calc(100dvh - var(--global-player-height, 0px) - 112px);
    min-height: 320px;
    max-height: calc(100dvh - var(--global-player-height, 0px) - 112px);
    display: flex;
    flex-direction: column;
    background: var(--rc-bg);
    border: 1px solid var(--rc-border);
    border-radius: 16px;
    box-shadow: var(--rc-shadow);
    overflow: hidden;
    transform-origin: bottom right;
}

.rc-panel-enter {
    animation: rcPanelIn 0.25s cubic-bezier(0.34,1.4,0.64,1);
}

@keyframes rcPanelIn {
    from { opacity: 0; transform: scale(0.85) translateY(16px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ?? Panel header ?? */
.rc-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--rc-border);
    background: var(--rc-bg-elevated);
    flex-shrink: 0;
}

.rc-panel-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.rc-panel-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rc-panel-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--rc-text);
    white-space: nowrap;
}

.rc-panel-title-row .rc-radio-svg {
    width: 16px;
    height: 16px;
    color: var(--rc-primary);
}

.rc-panel-user-count {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.6875rem;
    color: var(--rc-text-muted);
    background: var(--rc-bg-hover);
    border-radius: 8px;
    padding: 2px 7px;
    white-space: nowrap;
}

.rc-panel-user-count-online {
    color: #22c55e;
    background: rgba(34,197,94,0.12);
    border: 1px solid rgba(34,197,94,0.25);
    font-weight: 600;
}

/* ?? Now Playing bar ?? */
.rc-now-playing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(0,217,255,0.08), rgba(255,107,157,0.06));
    border-bottom: 1px solid var(--rc-border);
    flex-shrink: 0;
    overflow: hidden;
}

body[data-theme="evil"] .rc-now-playing {
    background: linear-gradient(135deg, rgba(255,0,102,0.08), rgba(255,107,0,0.06));
}

body[data-theme="twins"] .rc-now-playing {
    background: linear-gradient(135deg, rgba(157,92,255,0.08), rgba(236,72,153,0.06));
}

.rc-now-playing-art {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--rc-bg-elevated);
}

.rc-now-playing-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rc-now-playing-art-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Animated equalizer overlay */
.rc-now-playing-equalizer {
    position: absolute;
    bottom: 3px;
    right: 3px;
    display: flex;
    align-items: flex-end;
    gap: 1.5px;
}

.rc-now-playing-equalizer span {
    width: 3px;
    background: var(--rc-primary);
    border-radius: 2px;
    animation: rcEqualizer 0.8s ease-in-out infinite alternate;
}

.rc-now-playing-equalizer span:nth-child(1) { height: 6px; animation-delay: 0s; }
.rc-now-playing-equalizer span:nth-child(2) { height: 10px; animation-delay: 0.15s; }
.rc-now-playing-equalizer span:nth-child(3) { height: 7px; animation-delay: 0.3s; }

@keyframes rcEqualizer {
    from { transform: scaleY(0.4); }
    to   { transform: scaleY(1); }
}

.rc-now-playing-info {
    flex: 1;
    min-width: 0;
}

.rc-now-playing-label {
    font-size: 0.5625rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--rc-primary);
    margin-bottom: 1px;
}

.rc-now-playing-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--rc-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rc-now-playing-artist {
    font-size: 0.6875rem;
    color: var(--rc-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rc-now-playing-next {
    flex-shrink: 0;
    max-width: 90px;
    text-align: right;
}

.rc-now-playing-next-label {
    font-size: 0.5rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--rc-text-muted);
}

.rc-now-playing-next-title {
    font-size: 0.625rem;
    color: var(--rc-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
}

/* ============================================================================
   ChatComponent override — fills remaining panel height flush
   ============================================================================ */

/* Connecting indicator */
.rc-connecting {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 2rem 1rem;
    font-size: 0.8125rem;
}

.rc-chat-inner {
    flex: 1;
    min-height: 0;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

/* Guest emote-only notice inside rc-chat-inner */
.rc-guest-notice {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    flex-wrap: wrap;
    line-height: 1.4;
    padding: 4px 2px;
}

.rc-emote-only-label {
    font-weight: 700;
    color: var(--rc-primary, #00D9FF);
}

/* ?? (legacy rc-messages kept for any remaining references) ?? */
.rc-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 0;
    scroll-behavior: smooth;
}

.rc-loading,
.rc-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    padding: 2rem 1rem;
    opacity: 0.6;
}

/* ?? Message rows ?? */
.rc-message {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 3px 6px;
    border-radius: 8px;
    transition: background 0.15s;
    animation: rcMsgFadeIn 0.2s ease;
    position: relative;
}

.rc-message:hover {
    background: var(--rc-bg-hover);
}

.rc-message:hover .rc-msg-actions {
    opacity: 1;
}

@keyframes rcMsgFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rc-message-system {
    align-items: center;
    justify-content: center;
}

.rc-system-msg {
    font-size: 0.6875rem;
    text-align: center;
    width: 100%;
    padding: 2px 0;
}

.rc-deleted-msg {
    font-size: 0.75rem;
    font-style: italic;
    padding: 4px 6px;
    opacity: 0.6;
}

.rc-message-bot {
    border-radius: 10px;
}

.rc-message-neuro {
    background: rgba(0, 217, 255, 0.04);
    border-left: 2px solid rgba(0, 217, 255, 0.35);
}

.rc-message-evil {
    background: rgba(255, 0, 102, 0.04);
    border-left: 2px solid rgba(255, 0, 102, 0.35);
}

/* Avatar */
.rc-msg-avatar {
    flex-shrink: 0;
    margin-top: 1px;
}

.rc-bot-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
}

.rc-bot-neuro { box-shadow: 0 0 6px rgba(0,217,255,0.4); }
.rc-bot-evil  { box-shadow: 0 0 6px rgba(255,0,102,0.4); }

.rc-user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--rc-bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--rc-text-muted);
}

.rc-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rc-guest-avatar {
    opacity: 0.7;
    border: 1px dashed rgba(255,255,255,0.2);
}

/* Message body */
.rc-msg-body {
    flex: 1;
    min-width: 0;
}

.rc-msg-header {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 1px;
}

.rc-author {
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

.rc-author.bot-name-neuro { color: #00D9FF; }
.rc-author.bot-name-evil  { color: #FF0066; }
.rc-author.admin-name     { color: #f59e0b; }

.rc-msg-time {
    font-size: 0.625rem;
    flex-shrink: 0;
}

.rc-msg-content {
    font-size: 0.8125rem;
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Badges */
.rc-bot-badge,
.rc-admin-badge,
.rc-guest-badge {
    font-size: 0.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 1px 5px;
    border-radius: 4px;
}

.rc-bot-badge-neuro { background: rgba(0,217,255,0.15); color: #00D9FF; }
.rc-bot-badge-evil  { background: rgba(255,0,102,0.15); color: #FF0066; }
.rc-admin-badge     { background: rgba(245,158,11,0.15); color: #f59e0b; }
.rc-guest-badge     { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.4); }

/* Mod actions */
.rc-msg-actions {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.15s;
}

/* ?? Suggestions dropdown ?? */
.rc-suggestions {
    background: var(--rc-bg-elevated);
    border-top: 1px solid var(--rc-border);
    max-height: 140px;
    overflow-y: auto;
    flex-shrink: 0;
}

.rc-suggestion-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.8125rem;
    transition: background 0.15s;
}

.rc-suggestion-item:hover {
    background: var(--rc-bg-hover);
}

.rc-badge-bot {
    font-size: 0.625rem;
    background: var(--rc-bg-hover);
    border-radius: 4px;
    padding: 1px 5px;
}

/* ?? Input area ?? */
.rc-input-area {
    padding: 8px 10px;
    border-top: 1px solid var(--rc-border);
    background: var(--rc-bg-elevated);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rc-notice {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    padding: 4px 2px;
}

.rc-guest-notice {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    flex-wrap: wrap;
    line-height: 1.3;
}

.rc-emote-only-label {
    font-weight: 700;
    color: var(--rc-primary);
}

.rc-input-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--rc-bg-hover);
    border: 1px solid var(--rc-border);
    border-radius: 10px;
    padding: 2px 4px;
    transition: border-color 0.2s;
}

.rc-input-wrapper:focus-within {
    border-color: var(--rc-primary);
    box-shadow: 0 0 0 2px rgba(var(--rc-primary-rgb, 0,217,255), 0.12);
}

.rc-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    font-size: 0.8125rem;
    color: var(--rc-text);
    padding: 5px 6px;
}

.rc-input::placeholder {
    color: var(--rc-text-muted);
}

.rc-input:disabled {
    opacity: 0.5;
}

.rc-emoji-btn,
.rc-send-btn {
    flex-shrink: 0;
}

/* ?? Emoji picker ?? */
.rc-emoji-picker {
    border-top: 1px solid var(--rc-border);
    background: var(--rc-bg-elevated);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    max-height: 200px;
}

.rc-emoji-picker-header {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-bottom: 1px solid var(--rc-border);
    gap: 4px;
}

.rc-emoji-search {
    flex: 1;
    background: var(--rc-bg-hover);
    border: 1px solid var(--rc-border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.75rem;
    color: var(--rc-text);
    outline: none;
}

.rc-emoji-search::placeholder { color: var(--rc-text-muted); }

.rc-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 6px;
    overflow-y: auto;
    flex: 1;
}

.rc-emoji-item {
    width: 100%;
    aspect-ratio: 1;
    padding: 3px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rc-emoji-item:hover { background: var(--rc-bg-hover); }

.rc-emoji-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

/* Small desktop / tablet: slightly narrower */
@media (max-width: 640px) {
    .rc-panel {
        width: 320px;
    }
}

/* Mobile: full-width bottom sheet */
@media (max-width: 479px) {
    .rc-panel {
        right: 0;
        left: 0;
        bottom: calc(var(--global-player-height, 0px) + 70px);
        width: 100%;
        border-radius: 16px 16px 0 0;
        height: calc(100dvh - var(--global-player-height, 0px) - 118px);
        max-height: calc(100dvh - var(--global-player-height, 0px) - 118px);
    }

    .rc-fab {
        bottom: calc(var(--global-player-height, 0px) + 16px);
        right: 16px;
        width: 48px;
        height: 48px;
    }

    @keyframes rcPanelIn {
        from { opacity: 0; transform: translateY(30px); }
        to   { opacity: 1; transform: translateY(0); }
    }
}

/* Ensure panel doesn't overlap notification bell (which is also bottom-right) */
/* Notification bell is typically at bottom: 88px; rc-fab is at bottom: 148px */
