/* ─── App Flex Layout ───────────────────────────────────────── */
/* Fixed sidebar + scrollable main, same on every page */

.flex-layout {
    display: flex;
    min-height: 100vh;
}

/* Footer offset for fixed sidebar */
footer {
    margin-left: 240px;
    width: calc(100% - 240px);
}

@media (max-width: 1199px) {
    footer {
        margin-left: 0;
        width: 100%;
    }
}

/* ─── Fixed Sidebar ─── */
.side-nav {
    width: 240px;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 30;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.side-nav::-webkit-scrollbar {
    width: 3px;
}

.side-nav::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

/* Logo area */
.side-logo {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
}

.side-logo svg {
    width: 100px;
    height: auto;
    color: var(--text);
    display: block;
}

/* Nav items */
.side-nav-items {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none !important;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.nav-item:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.nav-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.6;
    flex-shrink: 0;
}

.nav-item-active {
    background: var(--text);
    color: var(--bg);
    font-weight: 700;
}

.nav-item-active:hover {
    background: var(--text);
    color: var(--bg);
    opacity: 0.9;
}

.nav-item-active svg {
    opacity: 1;
    color: var(--bg);
}

.nav-item-dot {
    margin-left: auto;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c9a84c;
    flex-shrink: 0;
}

.nav-divider {
    margin: 8px 14px;
    border: none;
    border-top: 1px solid var(--border);
}

/* User section at bottom */
.side-user {
    padding: 14px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
    text-decoration: none !important;
}

.side-user:hover {
    background: var(--surface-muted);
}

.side-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
    flex-shrink: 0;
}

@media (max-width: 1199px) {
    .side-nav {
        display: none;
    }
}

/* ─── Main Area ─── */
.app-main {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

@media (max-width: 1199px) {
    .app-main {
        margin-left: 0;
    }
}

/* ─── Top Bar (sticky) ─── */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 28px;
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
}

.breadcrumb-item {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none !important;
    padding: 4px 6px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.breadcrumb-item:hover {
    color: var(--text);
    background: var(--surface-muted);
}

.breadcrumb-item.active {
    color: var(--text);
    font-weight: 700;
}

.breadcrumb-sep {
    color: var(--muted);
    opacity: 0.3;
    font-size: 13px;
    font-weight: 400;
    user-select: none;
}

/* Top bar actions */
.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.top-bell:hover {
    color: var(--text);
    border-color: var(--text);
}

.top-bell svg {
    width: 14px;
    height: 14px;
}

.top-bell-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c9a84c;
}

/* Profile inside top bar (hidden on desktop when sidebar is visible) */
.top-bar-profile {
    display: none;
    align-items: center;
    gap: 8px;
}

@media (max-width: 1199px) {
    .top-bar {
        padding: 0 16px;
        min-height: 48px;
    }

    .top-bar-profile {
        display: flex;
    }
}

/* ─── Content Area ─── */
.app-content {
    flex: 1;
    padding: 24px 28px 80px;
    background: var(--surface-soft);
}

@media (max-width: 1199px) {
    .app-content {
        padding: 16px 16px 80px;
    }
}

/* ─── Legacy page-main padding (pages that still use it) ─── */
.page-main,
main.page-main,
.main {
    padding: 28px 0 80px;
}

/* ─── Card hover effects ─── */
.post-card:hover,
.discussion-card:hover {
    border-color: var(--border-hover) !important;
    box-shadow: var(--shadow-sm) !important;
    transform: translateY(-2px);
}

.post-card,
.discussion-card {
    will-change: transform;
}

/* ─── Legacy 3-col shell classes (kept for backward compat) ─── */
:is(.discover-shell, .feed-shell, .dashboard-shell, .search-shell) {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    align-items: start;
}

@media (min-width: 1200px) {
    :is(.discover-shell, .feed-shell, .dashboard-shell, .search-shell) {
        grid-template-columns: 220px minmax(0, 1fr) 300px;
        gap: 28px;
    }
}

/* ─── Rail Cards (Right Sidebar) ─── */
.feed-rail,
.right-rail,
.dashboard-sidebar,
.search-rail {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-left: 24px;
    border-left: 1px solid var(--border);
    min-height: 100%;
}

@media (max-width: 1199px) {
    :is(.feed-rail, .right-rail, .dashboard-sidebar, .search-rail) {
        display: none;
    }
}

/* Rail cards — refined for premium feel */
.rail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow-xs);
}

.rail-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.rail-card-dark,
.rail-card-premium {
    background: var(--premium-rail-bg) !important;
    border-color: var(--premium-rail-bg) !important;
    color: var(--bg);
}

.rail-card-dark .rail-eyebrow,
.rail-card-premium .rail-eyebrow {
    color: var(--bg);
    opacity: 0.5;
}

.rail-card-dark :is(.rail-title, .rail-heading),
.rail-card-premium :is(.rail-title, .rail-heading) {
    color: var(--bg);
}

.rail-card-dark :is(.rail-text, .rail-copy),
.rail-card-premium :is(.rail-text, .rail-copy) {
    color: var(--bg);
    opacity: 0.75;
}

.rail-eyebrow {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.rail-title,
.rail-heading {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0;
    color: var(--text);
}

.rail-text,
.rail-copy {
    font-size: 0.82rem;
    line-height: 1.5;
    font-weight: 450;
    color: var(--text-secondary);
    margin: 0;
}

.rail-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none !important;
    transition: all 0.2s ease;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
}

.rail-btn:hover {
    border-color: var(--border-hover);
    background: var(--surface);
}

.rail-card-dark .rail-btn,
.rail-card-premium .rail-btn {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--bg);
}

.rail-card-dark .rail-btn:hover,
.rail-card-premium .rail-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.25);
}

/* ─── Knowledge Sidebar ─── */
.knowledge-box {
    margin-top: 32px;
    padding: 16px;
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
}

.kb-eyebrow {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--premium-accent);
    margin: 0 0 6px;
}

.kb-title {
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
    margin: 0 0 12px;
    line-height: 1.25;
}

.kb-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kb-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none !important;
    transition: all 0.15s ease;
}

.kb-link:hover {
    background: var(--surface);
    color: var(--text);
    opacity: 1;
}

.kb-link svg {
    flex-shrink: 0;
    opacity: 0.5;
}

@media (max-width: 767px) {

    .page-main,
    main.page-main,
    .main {
        padding: 20px 0 72px;
    }

    :is(.discover-shell, .feed-shell, .dashboard-shell, .search-shell) {
        gap: 20px;
    }
}

/* ─── Feed 2-col layout (sidebar inside new layout) ─── */
.feed-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    align-items: start;
}

@media (min-width: 1200px) {
    .feed-grid {
        grid-template-columns: minmax(0, 1fr) 300px;
    }
}

@media (max-width: 1199px) {
    .feed-grid {
        gap: 20px;
    }
}

/* ─── Sidebar Mode Switch ─── */
.side-user-section {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.side-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 10px;
    text-decoration: none;
    transition: background 0.15s;
}

.side-user:hover {
    background: var(--surface-muted);
}

.side-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--text);
    color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 11px;
    flex-shrink: 0;
    overflow: hidden;
}

.side-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.side-user-info {
    flex: 1;
    min-width: 0;
}

.side-user-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.side-user-handle {
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
}

.side-user-chevron {
    color: var(--muted);
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

.side-mode-select {
    position: relative;
    padding: 0 14px 8px;
}

.side-mode-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 5px 8px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    letter-spacing: 0.01em;
}

.side-mode-btn:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.side-mode-btn svg {
    width: 10px;
    height: 10px;
    transition: transform 0.2s;
}

.side-mode-btn[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

.side-mode-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    left: 14px;
    right: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    z-index: 100;
}

.side-mode-menu.open {
    display: block;
}

.side-mode-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    border: none;
    background: none;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    transition: background 0.1s;
}

.side-mode-option:hover {
    background: var(--surface-muted);
}

.side-mode-option+.side-mode-option {
    border-top: 1px solid var(--border);
}

.sm-option-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--surface-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sm-option-icon svg {
    width: 14px;
    height: 14px;
}

.sm-option-text {
    flex: 1;
    min-width: 0;
}

.sm-option-name {
    font-weight: 800;
    font-size: 13px;
    color: var(--text);
}

.sm-option-desc {
    font-size: 10.5px;
    color: var(--muted);
    font-weight: 600;
    margin-top: 1px;
}

.side-mode-menu-footer {
    border-top: 1px solid var(--border);
    padding: 8px 12px;
}

.side-mode-menu-footer a {
    font-size: 11px;
    font-weight: 700;
    color: var(--premium-accent);
    text-decoration: none;
    display: block;
    text-align: center;
}

.side-mode-menu-footer a:hover {
    text-decoration: underline;
}
