/* ========== LAYOUT STRUCTURE ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --sidebar-width: 260px;
    --right-sidebar-width: 370px;
    --header-height: 56px;
    --primary-color: #3b82f6;
    --hover-bg: #f1f5f9;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
}

/* Dark mode sidebar variables */
[data-theme="dark"] {
    --primary-color: #60a5fa;
    --hover-bg: #2a2a2b;
    --border-color: #343536;
    --text-primary: #d7dadc;
    --text-secondary: #818384;
    --bg-primary: #1a1a1b;
    --bg-secondary: #030303;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ========== DESKTOP HEADER ========== */
.desktop-header {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    z-index: 1001;
    padding: 0 1rem;
    align-items: center;
    gap: 1rem;
}

.desktop-header-left {
    display: flex;
    align-items: center;
    width: var(--sidebar-width);
}

.desktop-header-left .logo a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.5rem;
}

.desktop-header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    max-width: 720px;
}

.search-container {
    position: relative;
    width: 100%;
    max-width: 600px;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    opacity: 0.5;
    pointer-events: none;
}

.search-container input {
    width: 100%;
    padding: 0.625rem 1rem 0.625rem 2.75rem;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    background: var(--hover-bg);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.search-container input:focus {
    background: var(--bg-primary);
    border-color: var(--primary-color);
}

.search-container input::placeholder {
    color: var(--text-secondary);
}

.desktop-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-icon-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
}

.header-icon-btn:hover {
    background: var(--hover-bg);
}

.header-icon-btn img {
    width: 20px;
    height: 20px;
    opacity: 0.7;
}

.header-icon-btn:hover img {
    opacity: 1;
}

.btn-desktop-auth {
    padding: 0.5rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 24px;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-desktop-auth:hover {
    background: var(--secondary-hover);
}

.user-avatar-link {
    text-decoration: none;
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: opacity 0.2s;
}

.user-avatar:hover {
    opacity: 0.8;
}

/* ========== MOBILE HEADER ========== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.3s ease;
}

/* Hidden state for scroll behavior */
.mobile-header.nav-hidden {
    transform: translateY(-100%);
}

.menu-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
}

.menu-toggle:hover {
    background: var(--hover-bg);
}

.mobile-logo {
    display: flex;
    align-items: center;
    margin-right: 0.5rem;
}

.mobile-logo a {
    display: flex;
    align-items: center;
}

.mobile-logo img {
    width: 28px;
    height: 28px;
    border-radius: 100%;
}

.mobile-header .logo {
    flex: 1;
    display: flex;
    justify-content: center;
}

.mobile-header .logo a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.25rem;
}

.mobile-search {
    flex: 1;
    position: relative;
    margin: 0 0.5rem;
}

.mobile-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    opacity: 0.5;
    pointer-events: none;
}

.mobile-search input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--hover-bg);
    font-size: 14px;
    outline: none;
}

.mobile-search input::placeholder {
    color: var(--text-secondary);
}

#mobile-auth-links {
    display: flex;
    align-items: center;
}

.mobile-avatar-link,
.mobile-auth-icon {
    display: flex;
    align-items: center;
}

.mobile-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
}

.mobile-auth-icon img {
    width: 24px;
    height: 24px;
    opacity: 0.7;
}

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 900;
    transition: transform 0.3s ease;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ========== SIDEBAR NAVIGATION ========== */
.sidebar-nav {
    padding: 0.5rem 0;
}

.nav-section {
    padding: 0.5rem 0;
}

.nav-section-bottom {
    margin-top: auto;
    padding-top: 1rem;
}

.section-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0.75rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.collapse-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.collapse-btn:hover {
    background: var(--hover-bg);
}

.collapse-btn img {
    transition: transform 0.2s ease;
    display: block;
}

.section-content {
    transition: opacity 0.2s ease;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    margin: 0 0.5rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
}

.nav-item:hover {
    background: var(--hover-bg);
}

.nav-item.active {
    background: var(--hover-bg);
    color: var(--primary-color);
}
@media (max-width: 767px) {
  .nav-item.active {
    margin-top: 50px;
  }
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary-color);
    border-radius: 0 3px 3px 0;
}

.nav-item-highlight {
    background: var(--primary-color);
    color: white;
}

.nav-item-highlight:hover {
    background: #2563eb;
    color: white;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-icon.circle-avatar {
    border-radius: 50%;
    object-fit: cover;
}

.nav-item-highlight .nav-icon {
    filter: brightness(0) invert(1);
}

.nav-item .badge {
    margin-left: auto;
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* Circle item with favorite button */
.circle-item {
    display: flex;
    align-items: center;
    padding: 0.625rem 1rem;
    margin: 0 0.5rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.circle-item:hover {
    background: var(--hover-bg);
}

.circle-item .circle-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 500;
}

.circle-item .favorite-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.circle-item:hover .favorite-btn {
    opacity: 1;
}

.circle-item .favorite-btn.favorited {
    opacity: 1;
}

.circle-item .favorite-btn img {
    display: block;
}

.nav-item-disabled {
    opacity: 0.5;
    cursor: default;
}

.nav-item-disabled:hover {
    background: transparent;
}

/* ========== PAGE CONTAINER ========== */
.page-container {
    margin-left: var(--sidebar-width);
    margin-right: 370px;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding: 0.2rem;
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}

/* ========== RIGHT SIDEBAR ========== */
.right-sidebar {
    position: fixed;
    right: 0;
    top: var(--header-height);
    bottom: 0;
    width: 320px;
    background: #dae0e6;
    padding: 1rem;
    overflow-y: auto;
    z-index: 800;
}

.right-sidebar::-webkit-scrollbar {
    width: 6px;
}

.right-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.right-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.sidebar-widget {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.widget-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: #f6f7f8;
}

.widget-header h3 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.widget-content {
    padding: 0;
}

.loading-widget {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.recent-post-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.recent-post-item:last-child {
    border-bottom: none;
}

.recent-post-item:hover {
    background: var(--hover-bg);
}

.recent-post-item a {
    text-decoration: none;
    color: var(--text-primary);
}

.recent-post-content {
    flex: 1;
    min-width: 0;
}

.recent-post-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
}

.recent-post-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.recent-post-circle {
    color: var(--text-primary);
    font-weight: 600;
    text-decoration: none;
}

.recent-post-circle:hover {
    text-decoration: underline;
}

.recent-post-time {
    color: var(--text-secondary);
}

.recent-post-title {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-primary);
}

.recent-post-link {
    text-decoration: none;
}

.recent-post-link:hover .recent-post-title {
    color: var(--primary-color);
}

.recent-post-footer {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.recent-post-thumbnail {
    width: 70px;
    height: 70px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.recent-post-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.recent-video-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.recent-post-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: 0;
    font-size: 0.875rem;
}

/* ========== MOBILE SIDEBAR FOOTER ========== */
.mobile-footer-section {
    display: none;
    padding: 0.25rem 1rem 3rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.mobile-footer-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0;
    margin-bottom: 0.5rem;
}

.mobile-footer-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    text-decoration: none;
    padding: 0.25rem 0;
    transition: color 0.2s ease;
}

.mobile-footer-link:hover {
    color: var(--text-primary);
}

.mobile-footer-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.mobile-footer-separator {
    color: var(--text-muted);
    margin: 0 0.5rem;
    font-size: 0.75rem;
}

.mobile-footer-copyright {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.mobile-footer-copyright p {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin: 0;
    line-height: 1.4;
}

/* Show mobile footer only on mobile */
@media (max-width: 768px) {
    .mobile-footer-section {
        display: block;
    }
    
    .sidebar-nav {
        display: flex;
        flex-direction: column;
        min-height: 100%;
    }
}

/* ========== SIDEBAR OVERLAY (Mobile) ========== */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 850;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ========== RESPONSIVE DESIGN ========== */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }
    
    .main-content {
        padding: 0.5rem;
    }
    
    .right-sidebar {
        display: none;
    }
    
    .page-container {
        margin-right: 0;
    }
}

/* Mobile (below 768px) */
@media (max-width: 768px) {
    .desktop-header {
        display: none;
    }
    
    .mobile-header {
        display: flex;
    }
    
    .sidebar {
        top: 0;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .page-container {
        margin-left: 0;
    }
    
    .main-content {
        padding: 0.3rem;
    }
}

/* Small Mobile (below 480px) */
@media (max-width: 480px) {
    :root {
        --sidebar-width: 280px;
    }
    
    .main-content {
        padding: 0.1rem;
    }
    
    .mobile-header .logo span {
        font-size: 1rem;
    }
}

/* ========== AUTH ACTIONS ========== */
.auth-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    margin: 0.25rem 0.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.2s;
    border: none;
    background: none;
    cursor: pointer;
    width: calc(100% - 1rem);
    text-align: left;
}
@media (max-width: 1024px) {
  .auth-btn {
    margin-bottom: 3rem;
  }
}

.auth-btn-primary {
    background: var(--primary-color);
    color: white;
}

.auth-btn-primary:hover {
    background: #2563eb;
}

.auth-btn-primary:active {
    background: #2563eb;
    transform: scale(0.98);
}

.auth-btn-secondary {
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.auth-btn-secondary:hover {
    background: var(--hover-bg);
}

.auth-btn-secondary:active {
    background: var(--hover-bg);
    transform: scale(0.98);
}

.auth-btn-logout {
    color: #ef4444;
}

.auth-btn-logout:hover {
    background: #fef2f2;
}

/* ========== UTILITY CLASSES ========== */
.container {
    max-width: 100%;
}

.loading {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
    font-size: 1rem;
}

.hidden {
    display: none !important;
}

/* ========== ANIMATIONS ========== */
@keyframes slideInRight {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.sidebar.open {
    animation: slideInRight 0.3s ease;
}

/* ========== BOTTOM NAVIGATION (Mobile Only) ========== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    z-index: 1000;
    padding: 0;
    transition: transform 0.3s ease;
}

/* Hidden state for scroll behavior */
.bottom-nav.nav-hidden {
    transform: translateY(100%);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.625rem;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
    gap: 2px;
    padding: 0.25rem 0;
}

.bottom-nav-item:active {
    background: var(--hover-bg);
}

.bottom-nav-item.active {
    color: var(--primary-color);
}

.bottom-nav-item.active .bottom-nav-icon {
    color: var(--text-primary);
}

.bottom-nav-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    transition: filter 0.2s;
}

.bottom-nav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 20px);
    background: #ef4444;
    color: white;
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    font-weight: 600;
    min-width: 16px;
    text-align: center;
    line-height: 1;
}

/* Show bottom nav only on mobile */
@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
    }
    
    .page-container {
        padding-bottom: 56px;
    }
    
    .main-content {
        padding-bottom: 1rem;
    }
}

/* Adjust for very small screens */
@media (max-width: 360px) {
    .bottom-nav-item {
        font-size: 0.5625rem;
        gap: 1px;
    }
    
    .bottom-nav-icon {
        width: 22px;
        height: 22px;
    }
}

/* ========== RIGHT SIDEBAR (DESKTOP ONLY) ========== */
.right-sidebar {
    position: fixed;
    right: 0;
    top: var(--header-height);
    bottom: 0;
    width: var(--right-sidebar-width);
    background: var(--bg-secondary);
    overflow-y: auto;
    padding: 1rem;
    z-index: 500;
}

.right-sidebar::-webkit-scrollbar {
    width: 6px;
}

.right-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.right-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.sidebar-widget {
    background: #f6f7f8;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    border-left: none;
    border-right: none;
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.widget-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.widget-header h3 {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 0;
}

.widget-content {
    padding: 0;
}

.loading-widget {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.recent-post-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.recent-post-item:last-child {
    border-bottom: none;
}

.recent-post-item:hover {
    background: var(--hover-bg);
}

.recent-post-link {
    text-decoration: none;
    color: var(--text-primary);
    display: block;
}

.recent-post-circle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.recent-post-title {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.recent-post-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Hide right sidebar on tablet and mobile */
@media (max-width: 1280px) {
    .right-sidebar {
        display: none;
    }
    
    .page-container {
        margin-right: 0;
    }
}

/* Popular Communities Widget */
.community-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
}

.community-item:last-child {
    border-bottom: none;
}

.community-item:hover {
    background: var(--hover-bg);
}

.community-link {
    text-decoration: none;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
}

.community-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.community-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.community-details {
    min-width: 0;
}

.community-name {
    font-size: 0.875rem;
    font-weight: 600;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.community-members {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-join {
    padding: 0.25rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.btn-join:hover {
    background: #2563eb;
}

.btn-join.joined {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-join.joined:hover {
    background: #cbd5e1;
}

/* Trending Topics Widget */
.trending-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.trending-item:last-child {
    border-bottom: none;
}

.trending-item:hover {
    background: var(--hover-bg);
}

.trending-link {
    text-decoration: none;
    color: var(--text-primary);
    display: block;
}

.trending-tag {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.trending-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.trending-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Related Communities Widget (shares styling with Popular Communities) */
.related-community-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
}

.related-community-item:last-child {
    border-bottom: none;
}

.related-community-item:hover {
    background: var(--hover-bg);
}

/* Footer Widget */
.footer-widget {
    background: transparent;
    border: none;
    margin-top: auto;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    align-items: center;
    justify-content: center;
}

.footer-link {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.footer-separator {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.footer-copyright {
    padding: 0.5rem 1rem;
    text-align: center;
}

.footer-copyright p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
}

/* ========== SIDEBAR AD WIDGET ========== */
#sidebar-ad-widget {
    overflow: hidden;
}

#sidebar-ad-widget .widget-content {
    padding: 0;
    min-height: auto;
    display: block;
}

#sidebar-ad-content {
    /* Allow ad's own positioning and sizing */
}

/* Only constrain max-width to prevent overflow, don't force dimensions */
#sidebar-ad-content img {
    max-width: 100%;
    height: auto;
}

#sidebar-ad-content iframe {
    max-width: 100%;
    border: none;
}

/* ========== COMMENT AD WIDGET ========== */
.comment-ad-container {
    margin: 0;
    padding: 0.3rem;
    background: var(--background-secondary, #f8fafc);
    border-radius: 12px;
    overflow: hidden;
}

#comment-ad-content {
    width: 100%;
    text-align: center;
}

#comment-ad-content * {
    max-width: 100% !important;
}

#comment-ad-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

#comment-ad-content iframe {
    max-width: 100%;
    border: none;
}

/* ========== DARK MODE OVERRIDES FOR SIDEBAR ========== */
[data-theme="dark"] .right-sidebar {
    background: var(--bg-secondary, #030303) !important;
}

[data-theme="dark"] .right-sidebar::-webkit-scrollbar-thumb {
    background: #4a4a4b !important;
}

[data-theme="dark"] .sidebar-widget {
    background: var(--bg-primary, #1a1a1b) !important;
    border-color: var(--border-color, #343536) !important;
}

[data-theme="dark"] .widget-header {
    background: #272729 !important;
}

[data-theme="dark"] .widget-header h3 {
    color: var(--text-secondary, #818384) !important;
}

[data-theme="dark"] .left-sidebar {
    background: var(--bg-primary, #1a1a1b) !important;
}

[data-theme="dark"] .sidebar-section {
    border-color: var(--border-color, #343536) !important;
}

[data-theme="dark"] .nav-item,
[data-theme="dark"] .sidebar-link {
    color: var(--text-primary, #d7dadc) !important;
}

[data-theme="dark"] .nav-item:hover,
[data-theme="dark"] .sidebar-link:hover {
    background: var(--hover-bg, #2a2a2b) !important;
}

[data-theme="dark"] .bottom-nav {
    background: var(--bg-primary, #1a1a1b) !important;
    border-top-color: var(--border-color, #343536) !important;
}

[data-theme="dark"] .bottom-nav-item {
    color: var(--text-secondary, #818384) !important;
}

[data-theme="dark"] .bottom-nav-item.active {
    color: var(--primary-color, #60a5fa) !important;
}

[data-theme="dark"] .mobile-sidebar {
    background: var(--bg-primary, #1a1a1b) !important;
}

[data-theme="dark"] .mobile-sidebar-overlay {
    background: rgba(0, 0, 0, 0.75) !important;
}

[data-theme="dark"] .pending-count {
    background: var(--error-color, #f87171) !important;
}

/* Invert sidebar SVG icons */
[data-theme="dark"] .nav-item img,
[data-theme="dark"] .sidebar-link img,
[data-theme="dark"] .bottom-nav-item img,
[data-theme="dark"] .widget-header img {
    filter: invert(0.8) brightness(1.2);
}

/* Don't invert circle avatars */
[data-theme="dark"] .circle-icon,
[data-theme="dark"] .nav-item .circle-icon,
[data-theme="dark"] .sidebar-link .circle-icon {
    filter: none !important;
}
