/* ========================================
   Desktop Right Sidebar
   Context-aware right panel for ≥1280px
   ======================================== */

/* Hidden by default */
.desktop-right-sidebar {
    display: none;
}

/* Show on wide screens */
@media (min-width: 1280px) {
    .desktop-right-sidebar {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 240px;
        z-index: 999;
        background: linear-gradient(180deg, rgba(10, 10, 18, 0.97) 0%, rgba(0, 0, 0, 0.99) 100%);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border-left: 1px solid var(--border-color, #333);
        padding: 0;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: thin;
        scrollbar-color: rgba(255,255,255,0.1) transparent;
        opacity: 1;
        transform: translateX(0);
        transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: auto;
    }

    .desktop-right-sidebar.hidden {
        opacity: 0;
        transform: translateX(100%);
        pointer-events: none;
    }

    /* In-grid variant (feed page): render as an in-flow sticky side column
       inside the profile-style grid rather than a fixed floating panel. */
    .desktop-right-sidebar.drs-in-grid {
        position: sticky;
        top: 82px;
        right: auto;
        bottom: auto;
        width: 100%;
        max-height: calc(100vh - 100px);
        z-index: auto;
        border-left: none;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        transform: none;
    }

    .desktop-right-sidebar::-webkit-scrollbar {
        width: 4px;
    }

    .desktop-right-sidebar::-webkit-scrollbar-track {
        background: transparent;
    }

    .desktop-right-sidebar::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 2px;
    }

    /* Section header */
    .right-sidebar-header {
        padding: 16px 16px 8px;
        border-bottom: 1px solid var(--border-color, #333);
        flex-shrink: 0;
    }

    .right-sidebar-title {
        font-size: 0.85rem;
        font-weight: 600;
        color: var(--text-primary, #fff);
        letter-spacing: 0.02em;
        margin: 0;
    }

    /* Content sections */
    .right-sidebar-section {
        padding: 12px 16px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .right-sidebar-section:last-child {
        border-bottom: none;
    }

    .right-sidebar-section-title {
        font-size: 0.7rem;
        font-weight: 600;
        color: var(--text-secondary, #a0a0a0);
        text-transform: uppercase;
        letter-spacing: 0.08em;
        margin: 0 0 10px 0;
    }

    /* User suggestion cards */
    .right-sidebar-user {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px;
        border-radius: 10px;
        transition: background-color 0.2s ease;
        cursor: pointer;
        text-decoration: none;
        color: inherit;
    }

    .right-sidebar-user:hover {
        background: rgba(255, 255, 255, 0.06);
    }

    .right-sidebar-avatar {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        object-fit: cover;
        background: var(--bg-secondary, #1a1a1a);
        flex-shrink: 0;
    }

    .right-sidebar-user-info {
        flex: 1;
        min-width: 0;
    }

    .right-sidebar-username {
        font-size: 0.8rem;
        font-weight: 500;
        color: var(--text-primary, #fff);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .right-sidebar-handle {
        font-size: 0.7rem;
        color: var(--text-secondary, #a0a0a0);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .right-sidebar-mutual {
        font-size: 0.65rem;
        color: var(--accent-primary, #7c5cfc);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-top: 1px;
    }

    .right-sidebar-action-btn {
        background: rgba(255, 255, 255, 0.1);
        border: none;
        color: var(--text-primary, #fff);
        font-size: 0.7rem;
        font-weight: 500;
        padding: 5px 12px;
        border-radius: 20px;
        cursor: pointer;
        transition: background 0.2s ease;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .right-sidebar-action-btn:hover {
        background: rgba(255, 255, 255, 0.18);
    }

    /* Trending/topic items */
    .right-sidebar-topic {
        padding: 8px;
        border-radius: 10px;
        transition: background-color 0.2s ease;
        cursor: pointer;
    }

    .right-sidebar-topic:hover {
        background: rgba(255, 255, 255, 0.06);
    }

    .right-sidebar-topic-label {
        font-size: 0.65rem;
        color: var(--text-secondary, #a0a0a0);
        margin-bottom: 2px;
    }

    .right-sidebar-topic-name {
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--text-primary, #fff);
    }

    .right-sidebar-topic-count {
        font-size: 0.65rem;
        color: var(--text-secondary, #a0a0a0);
        margin-top: 2px;
    }

    /* Activity/notification items */
    .right-sidebar-activity {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        padding: 8px;
        border-radius: 10px;
        transition: background-color 0.2s ease;
    }

    .right-sidebar-activity:hover {
        background: rgba(255, 255, 255, 0.04);
    }

    .right-sidebar-activity-icon {
        font-size: 1.1rem;
        flex-shrink: 0;
        line-height: 1;
        margin-top: 2px;
    }

    .right-sidebar-activity-text {
        font-size: 0.75rem;
        color: var(--text-secondary, #a0a0a0);
        line-height: 1.4;
    }

    .right-sidebar-activity-text strong {
        color: var(--text-primary, #fff);
        font-weight: 500;
    }

    .right-sidebar-activity-time {
        font-size: 0.6rem;
        color: rgba(255, 255, 255, 0.3);
        margin-top: 2px;
    }

    /* Quick stats */
    .right-sidebar-stats {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
        gap: 8px;
    }

    .right-sidebar-stat {
        background: rgba(255, 255, 255, 0.04);
        border-radius: 10px;
        padding: 10px;
        text-align: center;
    }

    .right-sidebar-stat-value {
        font-size: 1.1rem;
        font-weight: 700;
        color: var(--text-primary, #fff);
    }

    .right-sidebar-stat-label {
        font-size: 0.6rem;
        color: var(--text-secondary, #a0a0a0);
        margin-top: 2px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    /* Empty state */
    .right-sidebar-empty {
        padding: 20px 16px;
        text-align: center;
        color: var(--text-secondary, #a0a0a0);
        font-size: 0.75rem;
    }

    /* Footer */
    .right-sidebar-footer {
        margin-top: auto;
        padding: 12px 16px;
        border-top: 1px solid var(--border-color, #333);
    }

    .right-sidebar-footer-text {
        font-size: 0.6rem;
        color: rgba(255, 255, 255, 0.25);
        text-align: center;
    }

    .right-sidebar-footer a {
        color: rgba(255, 255, 255, 0.35);
        text-decoration: none;
    }

    .right-sidebar-footer a:hover {
        color: rgba(255, 255, 255, 0.5);
    }

    /* Vibe Room: Suggested Tracks rows */
    .rs-track-row {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 7px 8px;
        border-radius: 8px;
        cursor: pointer;
        transition: background 0.15s;
    }

    .rs-track-row:hover {
        background: rgba(255, 255, 255, 0.06);
    }

    .rs-track-art {
        width: 40px;
        height: 40px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.06);
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    .rs-track-info {
        flex: 1;
        min-width: 0;
    }

    .rs-track-title {
        font-size: 0.82rem;
        font-weight: 600;
        color: var(--text-primary, #fff);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .rs-track-artist {
        font-size: 0.7rem;
        color: var(--text-secondary, #a0a0a0);
        margin-top: 1px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .rs-track-play {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: rgba(29, 185, 84, 0.15);
        border: 1px solid rgba(29, 185, 84, 0.3);
        color: #1db954;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
        transition: background 0.15s, transform 0.12s;
        padding: 0;
    }

    .rs-track-play:hover {
        background: #1db954;
        color: #000;
        transform: scale(1.1);
    }

    .rs-track-play:active {
        transform: scale(0.9);
    }

    /* Search page: filter chips */
    .right-sidebar-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .right-sidebar-chip {
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: var(--text-secondary, #a0a0a0);
        font-size: 0.7rem;
        padding: 4px 10px;
        border-radius: 16px;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .right-sidebar-chip:hover,
    .right-sidebar-chip.active {
        background: rgba(255, 255, 255, 0.12);
        border-color: rgba(255, 255, 255, 0.2);
        color: var(--text-primary, #fff);
    }

    /* Help links (settings page) */
    .right-sidebar-link {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px;
        border-radius: 8px;
        text-decoration: none;
        color: var(--text-secondary, #a0a0a0);
        font-size: 0.75rem;
        transition: background 0.2s ease, color 0.2s ease;
    }

    .right-sidebar-link:hover {
        background: rgba(255, 255, 255, 0.06);
        color: var(--text-primary, #fff);
    }

    .right-sidebar-link-icon {
        font-size: 1rem;
    }

    /* ---- Vibes (stories) in sidebar ---- */
    .right-sidebar-vibes-ring {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .right-sidebar-vibe-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        cursor: pointer;
        padding: 6px 2px;
        border-radius: 10px;
        transition: background 0.2s ease;
    }

    .right-sidebar-vibe-item:hover {
        background: rgba(255, 255, 255, 0.06);
    }

    .right-sidebar-vibe-avatar-wrap {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        padding: 2px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .right-sidebar-vibe-avatar-wrap.unseen {
        box-shadow: 0 0 8px 2px rgba(59, 130, 246, 0.5), 0 0 16px 5px rgba(139, 92, 246, 0.3);
        animation: sidebarVibePulse 2s ease-in-out infinite;
    }

    .right-sidebar-vibe-avatar-wrap.seen {
        box-shadow: 0 0 4px 1px rgba(100, 100, 100, 0.25);
    }

    .right-sidebar-vibe-avatar-wrap.create {
        background: rgba(255, 255, 255, 0.04);
        border: 2px dashed rgba(255, 255, 255, 0.15);
    }

    @keyframes sidebarVibePulse {
        0%, 100% { box-shadow: 0 0 8px 2px rgba(59, 130, 246, 0.5), 0 0 16px 5px rgba(139, 92, 246, 0.3); }
        50% { box-shadow: 0 0 14px 4px rgba(59, 130, 246, 0.6), 0 0 24px 8px rgba(139, 92, 246, 0.4); }
    }

    .right-sidebar-vibe-avatar {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        object-fit: cover;
        background: #222;
        border: 2px solid var(--bg-color, #0a0a0a);
    }

    .right-sidebar-vibe-name {
        font-size: 0.6rem;
        color: var(--text-secondary, #a0a0a0);
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        text-align: center;
    }

    .right-sidebar-vibe-create {
        opacity: 0.7;
    }

    .right-sidebar-vibe-create:hover {
        opacity: 1;
    }

    /* ========================================
       SoundCloud Mini Player in Right Sidebar
       Keep in normal flow to avoid overlapping other sections
       ======================================== */
    .rs-soundcloud-player {
        position: relative;
        bottom: auto;
        flex-shrink: 0;
        width: 100%;
        margin-top: 8px;
        background: linear-gradient(180deg, rgba(18, 18, 28, 0.98) 0%, rgba(10, 10, 18, 1) 100%);
        border-top: 1px solid rgba(255, 85, 0, 0.15);
        padding: 0;
        z-index: 1;
    }

    .rs-soundcloud-player .sc-sidebar-inner {
        padding: 6px;
    }

    .rs-soundcloud-player iframe,
    .rs-soundcloud-player #yt-player-wrap iframe {
        width: 100%;
        border: none;
        border-radius: 8px;
    }

    .rs-soundcloud-player > .sc-sidebar-inner > iframe {
        height: 166px;
    }

    .rs-soundcloud-player #yt-player-wrap,
    .rs-soundcloud-player #yt-player-wrap iframe {
        width: 100%;
        height: 220px;
        border-radius: 8px;
        overflow: hidden;
    }

    .rs-soundcloud-player .sc-sidebar-controls {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 14px 14px;
    }

    .rs-soundcloud-player .sc-sidebar-controls .sc-vol-icon {
        color: #ff5500;
        font-size: 20px;
        flex-shrink: 0;
    }

    .rs-soundcloud-player .sc-sidebar-controls input[type="range"] {
        flex: 1;
        height: 8px;
        -webkit-appearance: none;
        appearance: none;
        background: linear-gradient(to right, #ff5500 80%, #444 80%);
        border-radius: 4px;
        outline: none;
        cursor: pointer;
        margin: 6px 0;
    }

    .rs-soundcloud-player .sc-sidebar-controls input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        background: #ff5500;
        cursor: pointer;
        box-shadow: 0 0 6px rgba(255, 85, 0, 0.5);
        transition: transform 0.15s ease;
    }

    .rs-soundcloud-player .sc-sidebar-controls input[type="range"]::-webkit-slider-thumb:hover {
        transform: scale(1.15);
        background: #ff7722;
    }

    .rs-soundcloud-player .sc-sidebar-controls input[type="range"]::-moz-range-thumb {
        width: 22px;
        height: 22px;
        border-radius: 50%;
        background: #ff5500;
    }

    /* ========================================
       Voice Sidebar Panel — persistent voice
       controls for non-hangout pages
       ======================================== */

    .voice-sidebar-panel {
        background: rgba(107, 203, 119, 0.06);
        border-bottom: 1px solid rgba(107, 203, 119, 0.15);
        padding: 12px 14px;
        flex-shrink: 0;
    }

    .vs-header {
        margin-bottom: 10px;
    }

    .vs-status {
        display: flex;
        align-items: center;
        gap: 6px;
        margin-bottom: 4px;
    }

    .vs-status-dot {
        display: inline-block;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #6BCB77;
        animation: vs-pulse 2s infinite;
    }

    @keyframes vs-pulse {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.5; }
    }

    .vs-status-text {
        font-size: 0.7rem;
        font-weight: 600;
        color: #6BCB77;
        text-transform: uppercase;
        letter-spacing: 0.06em;
    }

    .vs-channel {
        font-size: 0.8rem;
        font-weight: 500;
        color: var(--text-primary, #fff);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .vs-participants {
        display: flex;
        flex-direction: column;
        gap: 4px;
        margin-bottom: 10px;
        max-height: 160px;
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: rgba(255,255,255,0.1) transparent;
    }

    .vs-participant {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 4px 6px;
        border-radius: 8px;
    }

    .vs-participant.vs-self {
        background: rgba(255, 255, 255, 0.04);
    }

    .vs-participant-avatar {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        object-fit: cover;
        background: #333;
        flex-shrink: 0;
    }

    .vs-participant-name {
        font-size: 0.75rem;
        color: var(--text-primary, #fff);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
        min-width: 0;
    }

    .vs-mute-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        color: #FF6B6B;
        opacity: 0.85;
    }
    .vs-mute-icon svg {
        width: 11px;
        height: 11px;
        fill: currentColor;
    }

    .vs-empty {
        font-size: 0.7rem;
        color: var(--text-secondary, #888);
        text-align: center;
        padding: 4px;
    }

    .vs-controls {
        display: flex;
        gap: 8px;
        justify-content: center;
        margin-bottom: 8px;
    }

    .vs-ctrl-btn {
        width: 36px;
        height: 36px;
        border: none;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.08);
        color: #fff;
        font-size: 1rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s, transform 0.15s;
    }

    .vs-ctrl-btn:hover {
        background: rgba(255, 255, 255, 0.15);
        transform: scale(1.08);
    }

    .vs-ctrl-btn.vs-muted {
        background: rgba(255, 107, 107, 0.15);
        color: #FF6B6B;
    }

    .vs-ctrl-btn.vs-muted:hover {
        background: rgba(255, 107, 107, 0.25);
    }

    .vs-ctrl-btn.vs-disconnect {
        background: rgba(255, 71, 71, 0.2);
        color: #FF4747;
    }

    .vs-ctrl-btn.vs-disconnect:hover {
        background: rgba(255, 71, 71, 0.35);
    }

    .vs-back-link {
        text-align: center;
    }

    .vs-back-anchor {
        font-size: 0.7rem;
        color: #FFB347;
        text-decoration: none;
        transition: color 0.2s;
    }

    .vs-back-anchor:hover {
        color: #ffc06b;
        text-decoration: underline;
        cursor: pointer;
        border: none;
        box-shadow: 0 0 6px rgba(255, 85, 0, 0.5);
    }

    .rs-soundcloud-player .sc-sidebar-controls input[type="range"]::-moz-range-thumb:hover {
        background: #ff7722;
    }

    .rs-soundcloud-player .sc-sidebar-controls .sc-vol-label {
        color: #fff;
        font-size: 0.85rem;
        min-width: 36px;
        font-weight: 600;
        text-align: right;
    }

    .rs-soundcloud-player .sc-sidebar-btn-row {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        padding: 2px 14px 12px;
    }

    .rs-soundcloud-player .sc-sidebar-btn {
        background: rgba(255, 255, 255, 0.06);
        border: none;
        color: rgba(255, 255, 255, 0.5);
        width: 34px;
        height: 34px;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.85rem;
        transition: all 0.2s ease;
    }

    .rs-soundcloud-player .sc-sidebar-btn:hover {
        background: rgba(255, 85, 0, 0.2);
        color: #ff5500;
    }

    /* Orange accent bar at the bottom */
    .rs-soundcloud-player .sc-sidebar-accent {
        height: 3px;
        background: linear-gradient(90deg, #ff5500, #ff8800);
    }
}

/* Hide on narrow screens */
@media (max-width: 1279px) {
    .desktop-right-sidebar {
        display: none !important;
    }
}

/* Hide the main stories bar when vibes are in the right sidebar */
@media (min-width: 1280px) {
    body.has-right-sidebar .stories-section {
        display: none !important;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .right-sidebar-user,
    .right-sidebar-topic,
    .right-sidebar-activity,
    .right-sidebar-action-btn,
    .right-sidebar-chip,
    .right-sidebar-link {
        transition: none !important;
    }
}
