/**
 * DJC-Hub Left Sidebar - Mobile First
 * Drawer on mobile/tablet, fixed on desktop.
 */

.djc-hub-sidebar {
    position: fixed;
    left: 0;
    top: calc(var(--djc-topbar-height) + var(--djc-admin-bar-offset, 0px));
    height: calc(100dvh - var(--djc-topbar-height) - var(--djc-admin-bar-offset, 0px));
    width: 280px;
    max-width: 85vw;
    background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
    border-right: 1px solid rgba(124, 92, 255, 0.18);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 975;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.6);
    scrollbar-width: thin;
    scrollbar-color: rgba(124, 92, 255, 0.25) transparent;
    display: flex;
    flex-direction: column;
}

.djc-hub-sidebar::-webkit-scrollbar       { width: 3px; }
.djc-hub-sidebar::-webkit-scrollbar-track { background: transparent; }
.djc-hub-sidebar::-webkit-scrollbar-thumb { background: rgba(124, 92, 255, 0.3); border-radius: 2px; }

.djc-hub-sidebar.open {
    transform: translateX(0);
}

/* ============================================
   NAV SECTION LABELS
   ============================================ */

.djc-nav-section-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75) !important;
    padding: 16px 20px 6px;
    pointer-events: none;
}

/* ============================================
   NAV ITEMS
   ============================================ */

.djc-sidebar-nav {
    padding: 10px 0 8px;
    flex: 1;
}

.djc-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: #fff !important;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    font-family: "Poppins", "Segoe UI", sans-serif;
    transition: all 0.18s ease;
    position: relative;
    border-left: 3px solid transparent;
    min-height: 44px;
    border-radius: 0 8px 8px 0;
    margin: 1px 8px 1px 0;
}

.djc-nav-item .djc-nav-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    font-size: 14px;
    transition: all 0.18s ease;
}

.djc-nav-item .djc-nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.djc-nav-item:hover {
    background: rgba(124, 92, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border-left-color: rgba(124, 92, 255, 0.4);
}

.djc-nav-item:hover .djc-nav-icon {
    background: rgba(124, 92, 255, 0.15);
    color: #a78bfa;
}

.djc-nav-item:active {
    transform: scale(0.98);
}

/* Active state */
.djc-nav-item.active {
    background: linear-gradient(90deg, rgba(124, 92, 255, 0.18) 0%, rgba(124, 92, 255, 0.05) 100%);
    color: #fff;
    border-left-color: #7c5cff;
    box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.12);
}

.djc-nav-item.active .djc-nav-icon {
    background: rgba(124, 92, 255, 0.25);
    color: #a78bfa;
    box-shadow: 0 0 10px rgba(124, 92, 255, 0.2);
}

/* Discord / CTA */
.djc-nav-item.cta {
    background: linear-gradient(90deg, rgba(88, 101, 242, 0.12) 0%, rgba(88, 101, 242, 0.04) 100%);
    border-left-color: #5865f2;
    color: rgba(255, 255, 255, 0.8);
}

.djc-nav-item.cta .djc-nav-icon {
    background: rgba(88, 101, 242, 0.2);
    color: #818cf8;
}

.djc-nav-item.joined {
    border-left-color: #22c55e;
}

.djc-nav-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Badges */
.djc-nav-badge {
    background: rgba(124, 92, 255, 0.25);
    color: #fff;
    padding: 2px 7px;
    border-radius: var(--djc-radius-pill, 999px);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.4;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.djc-nav-badge.alert {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.12); }
}

.djc-nav-badge.new {
    background: #22c55e;
    color: #000;
    font-size: 10px;
}

.djc-coming-soon {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.6px;
    background: rgba(255, 255, 255, 0.07);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Divider */
.djc-nav-divider {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    margin: 8px 16px;
}

/* ============================================
   SIDEBAR WIDGETS (polls, live activity)
   ============================================ */

.djc-sidebar-widget {
    margin: 0 12px 12px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(124, 92, 255, 0.15);
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
}

.djc-sidebar-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.djc-sidebar-widget-title {
    font-size: 11px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.djc-sidebar-widget-badge {
    background: rgba(124, 92, 255, 0.3);
    color: #fff;
    padding: 2px 7px;
    border-radius: var(--djc-radius-pill, 999px);
    font-size: 10px;
    font-weight: 700;
}

/* Compact activity items */
.djc-hub-sidebar .djc-sidebar-live-activity .djc-activity-item {
    padding: 7px;
    gap: 8px;
    margin-bottom: 5px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
}

.djc-hub-sidebar .djc-sidebar-live-activity .djc-activity-avatar {
    width: 26px;
    height: 26px;
}

.djc-hub-sidebar .djc-sidebar-live-activity .djc-activity-content {
    font-size: 11px;
    line-height: 1.35;
    color: rgba(255, 255, 255, 0.85);
}

.djc-hub-sidebar .djc-sidebar-live-activity .djc-activity-time {
    font-size: 10px;
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.5);
}

/* Polls in sidebar */
.djc-sidebar-polls-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.djc-poll-item--compact {
    background: rgba(12, 18, 32, 0.8);
    border: 1px solid rgba(124, 92, 255, 0.15);
    border-radius: 10px;
    padding: 10px;
}

.djc-poll-item--compact .djc-poll-question {
    font-size: 12px;
    font-weight: 700;
    color: #e5e7eb;
    margin-bottom: 8px;
    line-height: 1.4;
}

.djc-poll-item--compact .djc-poll-options {
    display: grid;
    gap: 5px;
}

.djc-poll-item--compact .djc-poll-option {
    background: rgba(124, 92, 255, 0.1);
    border: 1px solid rgba(124, 92, 255, 0.22);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 8px;
    border-radius: 7px;
    text-align: left;
    cursor: pointer;
    transition: all 0.18s ease;
    width: 100%;
}

.djc-poll-item--compact .djc-poll-option:hover,
.djc-poll-item--compact .djc-poll-option.selected {
    background: rgba(124, 92, 255, 0.28);
    border-color: rgba(124, 92, 255, 0.5);
}

.djc-poll-item--compact .djc-poll-reward {
    margin-top: 7px;
    font-size: 11px;
    font-weight: 700;
    color: #fbbf24;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ============================================
   SIDEBAR FOOTER (logged-in user)
   ============================================ */

.djc-sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    margin-top: auto;
    flex-shrink: 0;
}

.djc-sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(124, 92, 255, 0.08);
    border: 1px solid rgba(124, 92, 255, 0.15);
    border-radius: 12px;
    transition: background 0.2s;
    cursor: default;
}

.djc-sidebar-user:hover {
    background: rgba(124, 92, 255, 0.13);
}

.djc-sidebar-user-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.djc-sidebar-user img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(124, 92, 255, 0.4);
    display: block;
}

.djc-sidebar-user-online {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 9px;
    height: 9px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #111827;
}

.djc-sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.djc-sidebar-user-name {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.djc-sidebar-user-level {
    font-size: 11px;
    color: rgba(167, 139, 250, 0.9);
    font-weight: 600;
    margin-top: 1px;
}

/* Guest promo */
.djc-sidebar-promo {
    margin: 8px 12px 12px;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid rgba(124, 92, 255, 0.2);
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.9), rgba(15, 23, 42, 0.9));
    color: #e5e7eb;
}

.djc-sidebar-promo-title {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 5px;
}

.djc-sidebar-promo-text {
    font-size: 12px;
    color: rgba(229, 231, 235, 0.65);
    margin-bottom: 10px;
    line-height: 1.5;
}

.djc-sidebar-promo-actions {
    display: flex;
    gap: 7px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (min-width: 768px) {
    /* Drawer stays 240px regardless of layout CSS var */
    .djc-hub-sidebar {
        width: 240px;
    }

    .djc-nav-item:hover {
        background: rgba(124, 92, 255, 0.08);
        color: rgba(255, 255, 255, 0.9);
    }
}

@media (min-width: 1024px) {
    /* Fixed sidebar: match the layout CSS var */
    .djc-hub-sidebar {
        width: var(--djc-left-sidebar-width, 220px);
        transform: translateX(0);
        box-shadow: none;
    }

    .djc-nav-item {
        padding: 10px 14px;
    }
}

/* ============================================
   GAME ACTIVE: sidebar slides out
   ============================================ */

/* Slide sidebar out when a game is running */
body.djc-game-active .djc-hub-sidebar {
    transform: translateX(-100%);
}

/* Expand the layout to fill sidebar space */
@media (min-width: 1024px) {
    body.djc-game-active .djc-hub-layout {
        margin-left: 0 !important;
        width: calc(100% - var(--djc-right-sidebar-width, 300px)) !important;
        transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                    width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* ============================================
   MOBILE BOTTOM NAVIGATION
   Visible only on mobile/tablet (<1024px)
   ============================================ */

.djc-mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 960;
    background: rgba(11, 15, 26, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(124, 92, 255, 0.18);
    padding: 6px 0 max(6px, env(safe-area-inset-bottom));
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
}

.djc-mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 44px;
    padding: 4px 6px;
    color: rgba(255, 255, 255, 0.45);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    font-family: "Poppins", "Segoe UI", sans-serif;
    letter-spacing: 0.3px;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    transition: color 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}

.djc-mobile-nav-item i {
    font-size: 18px;
    transition: color 0.18s ease, transform 0.18s ease;
}

.djc-mobile-nav-item span {
    color: inherit;
    font-size: 10px;
}

.djc-mobile-nav-item:active i {
    transform: scale(0.88);
}

.djc-mobile-nav-item.active {
    color: #a78bfa;
}

.djc-mobile-nav-item.active i {
    color: #7c5cff;
}

.djc-mobile-nav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 18px);
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 999px;
    padding: 0 4px;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

/* Add bottom padding to layout so content isn't hidden behind nav */
.djc-hub-layout {
    padding-bottom: calc(var(--djc-workspace-safe-padding-mobile, 12px) + 60px);
}

/* Hide on desktop — sidebar handles navigation */
@media (min-width: 1024px) {
    .djc-mobile-nav {
        display: none;
    }
    .djc-hub-layout {
        padding-bottom: var(--djc-workspace-safe-padding-desktop, 24px);
    }
}

/* Hide during full-screen game */
body.djc-game-active .djc-mobile-nav {
    display: none;
}
