/* ── TOPBAR ── */
.topbar {
    --tb-bg:      #ffffff;
    --tb-border:  #e8ddd4;
    --tb-text:    #1a1a1a;
    --tb-muted:   #7a7063;
    --tb-orange:  #e85d04;
    --tb-page-bg: #f0e8e0;

    background: var(--tb-bg);
    border-bottom: 2px solid var(--tb-border);
    padding: 0 24px;
    height: 48px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    line-height: 1.6;
}

.topbar-logo {
    font-weight: 700;
    font-size: 18px;
    color: var(--tb-orange);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    flex-shrink: 0;
}

.topbar-logo svg {
    width: 32px;
    height: 32px;
    fill: var(--tb-orange);
}

/* ── SEARCH BAR ── */
.topbar-search {
    flex: 1;
    max-width: 540px;
    margin: 0 auto;
}

.search-input-wrap {
    display: flex;
    align-items: center;
    background: var(--tb-page-bg);
    border: 1.5px solid var(--tb-border);
    border-radius: 20px;
    padding: 0 12px;
    height: 34px;
    gap: 6px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input-wrap:focus-within {
    border-color: var(--tb-orange);
    box-shadow: 0 0 0 2px rgba(232, 93, 4, 0.12);
    background: #fff;
}

.search-icon {
    width: 15px;
    height: 15px;
    color: var(--tb-muted);
    flex-shrink: 0;
}

.search-input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    color: var(--tb-text);
    width: 100%;
    min-width: 0;
}

.search-input::placeholder {
    color: var(--tb-muted);
}

/* Scope chip (u/username or r/subreddit) */
.search-chip {
    display: inline-flex;
    align-items: center;
    background: var(--tb-orange);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.2px;
}

/* ── NAV ── */
.topbar-nav {
    display: flex;
    gap: 6px;
    margin-left: auto;
    align-items: center;
    flex-shrink: 0;
}

.topbar-nav a {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: var(--tb-muted);
    transition: background 0.15s;
}

.topbar-nav a:hover {
    background: var(--tb-page-bg);
    color: var(--tb-text);
}

.topbar-nav a.btn-primary {
    background: var(--tb-orange);
    color: white;
}

.topbar-nav a.btn-primary:hover {
    background: #d04e00;
}
/* ── Hamburger (mobile sidebar toggle in topbar) ── */
.topbar-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--tb-muted);
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.topbar-hamburger:hover {
    background: var(--tb-page-bg);
    color: var(--tb-orange);
}

.topbar-hamburger svg {
    width: 20px;
    height: 20px;
}

@media (max-width: 768px) {
    .topbar-hamburger {
        display: flex;
    }
}

/* ═══════════════════════════════════════════
   NAV-SIDEBAR  –  Vertical left navigation
   All classes use .nav-sidebar prefix to
   avoid conflicts with page-level .sidebar
   classes in profile, subreddit, chat etc.
   ═══════════════════════════════════════════ */

:root {
    --nsb-width:       220px;
    --nsb-width-col:   56px;
    --nsb-bg:          #ffffff;
    --nsb-border:      #e8ddd4;
    --nsb-text:        #1a1a1a;
    --nsb-muted:       #7a7063;
    --nsb-orange:      #e85d04;
    --nsb-hover-bg:    #f0e8e0;
    --nsb-active-bg:   #fde8dc;
    --nsb-transition:  0.22s ease;
    --topbar-height:   48px;
}

/* ── Layout wrapper ── */
.sidebar-content-area {
    margin-left: var(--nsb-width);
    transition: margin-left var(--nsb-transition);
}

/* ── Sidebar shell ── */
.nav-sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    width: var(--nsb-width);
    background: var(--nsb-bg);
    border-right: 1.5px solid var(--nsb-border);
    display: flex;
    flex-direction: column;
    z-index: 90;
    transition: width var(--nsb-transition);
    overflow: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--nsb-border) transparent;
}

.nav-sidebar::-webkit-scrollbar { width: 4px; }
.nav-sidebar::-webkit-scrollbar-track { background: transparent; }
.nav-sidebar::-webkit-scrollbar-thumb { background: var(--nsb-border); border-radius: 2px; }

/* ── Collapsed state ── */
.nav-sidebar.collapsed {
    width: var(--nsb-width-col);
}

.nav-sidebar.collapsed ~ .sidebar-content-area,
body:has(.nav-sidebar.collapsed) .sidebar-content-area {
    margin-left: var(--nsb-width-col);
}

.nav-sidebar.collapsed .nav-sidebar-label,
.nav-sidebar.collapsed .nav-sidebar-section-header .nav-sidebar-label,
.nav-sidebar.collapsed .nav-sidebar-section-body,
.nav-sidebar.collapsed .nav-sidebar-divider,
.nav-sidebar.collapsed .nav-sidebar-section,
.nav-sidebar.collapsed .nav-community-private-badge {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.nav-sidebar.collapsed .nav-sidebar-item {
    justify-content: center;
    padding: 10px 0;
}

.nav-sidebar.collapsed .nav-sidebar-item svg:first-child,
.nav-sidebar.collapsed .nav-sidebar-item .nav-community-avatar:first-child,
.nav-sidebar.collapsed .nav-sidebar-item .nav-recent-avatar:first-child {
    margin: 0;
}

.nav-sidebar.collapsed .icon-collapse {
    transform: rotate(180deg);
}

/* ── Toggle button ── */
.nav-sidebar-toggle {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 8px 10px;
    background: var(--nsb-bg);
    border: none;
    cursor: pointer;
    color: var(--nsb-muted);
    z-index: 1;
    min-height: 36px;
    transition: color var(--nsb-transition);
    flex-shrink: 0;
    width: 100%;
}

.nav-sidebar-toggle:hover { color: var(--nsb-orange); }

.nav-sidebar-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform var(--nsb-transition);
    flex-shrink: 0;
}

/* ── Nav container ── */
.nav-sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 0 8px 24px;
    gap: 2px;
    flex: 1;
}

/* ── Nav items ── */
.nav-sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--nsb-text);
    font-size: 14px;
    font-weight: 500;
    transition: background var(--nsb-transition), color var(--nsb-transition);
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
}

.nav-sidebar-item svg:first-child {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--nsb-muted);
    transition: color var(--nsb-transition);
}

.nav-sidebar-item:hover { background: var(--nsb-hover-bg); }
.nav-sidebar-item:hover svg:first-child { color: var(--nsb-orange); }

.nav-sidebar-item.active {
    background: var(--nsb-active-bg);
    color: var(--nsb-orange);
    font-weight: 600;
}

.nav-sidebar-item.active svg:first-child { color: var(--nsb-orange); }

/* "Start a Community" action style */
.nav-sidebar-item--action {
    color: var(--nsb-orange);
    font-weight: 600;
    border: 1.5px dashed var(--nsb-orange);
}

.nav-sidebar-item--action svg:first-child { color: var(--nsb-orange); }
.nav-sidebar-item--action:hover { background: var(--nsb-active-bg); }

/* ── Divider ── */
.nav-sidebar-divider {
    height: 1px;
    background: var(--nsb-border);
    margin: 6px 4px;
    flex-shrink: 0;
    transition: opacity var(--nsb-transition), visibility var(--nsb-transition);
}

/* ── Collapsible section ── */
.nav-sidebar-section {
    display: flex;
    flex-direction: column;
}

.nav-sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--nsb-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    border-radius: 8px;
    transition: background var(--nsb-transition), color var(--nsb-transition);
    white-space: nowrap;
    overflow: hidden;
    width: 100%;
}

.nav-sidebar-section-header:hover {
    background: var(--nsb-hover-bg);
    color: var(--nsb-text);
}

.section-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform var(--nsb-transition);
}

.nav-sidebar-section-header[aria-expanded="false"] .section-chevron {
    transform: rotate(-90deg);
}

.nav-sidebar-section-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
    max-height: 600px;
    transition: max-height 0.28s ease, opacity 0.2s ease;
}

.nav-sidebar-section-body.collapsed {
    max-height: 0;
    opacity: 0;
}

/* ── Label ── */
.nav-sidebar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    transition: opacity var(--nsb-transition), visibility var(--nsb-transition);
}

/* ── Recent items ── */
.nav-recent-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--nsb-orange);
    color: #fff;
    border-radius: 50%;
    font-size: 8px;
    font-weight: 800;
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

.nav-recent-empty {
    padding: 5px 12px;
    font-size: 12px;
    color: var(--nsb-muted);
    font-style: italic;
}

/* ── Community items ── */
.nav-community-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--nsb-orange);
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.nav-community-avatar--img {
    object-fit: cover;
    background: var(--nsb-border);
}

.nav-community-private-badge {
    font-size: 11px;
    flex-shrink: 0;
    opacity: 0.7;
    margin-left: auto;
    transition: opacity var(--nsb-transition), visibility var(--nsb-transition);
}

/* ── Mobile overlay ── */
.nav-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 89;
    top: var(--topbar-height);
}

/* ── Mobile / Responsive ── */
@media (max-width: 768px) {
    .sidebar-content-area {
        margin-left: 0 !important;
    }

    .nav-sidebar {
        transform: translateX(-100%);
        width: var(--nsb-width) !important;
        box-shadow: 4px 0 16px rgba(0,0,0,0.12);
        transition: transform var(--nsb-transition), width var(--nsb-transition);
    }

    .nav-sidebar:not(.collapsed) {
        transform: translateX(0);
    }

    .nav-sidebar.collapsed {
        transform: translateX(-100%);
    }

    .nav-sidebar-overlay {
        display: block;
    }

    /* On mobile show the labels even when "collapsed" (since it slides in fully) */
    .nav-sidebar.collapsed .nav-sidebar-label,
    .nav-sidebar.collapsed .nav-sidebar-section,
    .nav-sidebar.collapsed .nav-sidebar-section-body,
    .nav-sidebar.collapsed .nav-sidebar-divider,
    .nav-sidebar.collapsed .nav-community-private-badge {
        opacity: 1;
        pointer-events: auto;
        visibility: visible;
    }

    .nav-sidebar.collapsed .nav-sidebar-item {
        justify-content: flex-start;
        padding: 8px 12px;
    }
}

/* Bell container */
.notification-icon {
    position: relative;
    font-size: 18px;
    display: inline-block;
}

/* Notification badge */
.notification-badge {
    position: absolute;
    top: -6px;
    right: -6px;

    background: red;
    color: white;

    font-size: 10px;
    font-weight: bold;

    border-radius: 50%;
    padding: 2px 6px;
    min-width: 16px;
    text-align: center;

    line-height: 1;
}

.community-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background-color: white; /* Base color */
  border: 4px solid white;
  box-shadow: 0 2px 8px rgba(232,93,4,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  color: var(--orange);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat; /* Add this */
}

.community-avatar {
    position: relative; /* Essential for absolute positioning of the icon */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible; /* Change from hidden to visible so the icon can sit on the edge */
    z-index: 10;
}

.logo-edit {
    position: absolute;
    bottom: 0;
    right: 0;
    background: #ffffff; /* Make it stand out */
    border: 1px solid #ccc;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 20; /* Ensure it sits above the avatar image/letter */
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
}