/**
 * Majlese - Reddit-style Light Theme
 */

/* Remove stacking context from #app so fixed sidebar can exceed backdrop z-index */
#app {
    position: static !important;
    z-index: auto !important;
}

/* ==========================================
   Light Theme Variables
   ========================================== */
:root {
    --upvote: #D4A853;
    --downvote: #7193ff;
    --page-bg: #F6F7F8;
    --card-bg: #FFFFFF;
    --navbar-bg: #FFFFFF;
    --sidebar-bg: #FFFFFF;
    --border: #EDEFF1;
    --border-subtle: #F0F2F3;
    --text-primary: #1C1C1C;
    --text-secondary: #878A8C;
    --text-muted: #ADAEAF;
    --accent: #D4A853;
    --hover-bg: #F6F7F8;
    --sidebar-width: 270px;
    --right-panel-width: 312px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --pill-border: #EDEFF1;

    /* Legacy aliases used by other components */
    --bg-surface: #FFFFFF;
    --bg-elevated: #F6F7F8;
    --bg-hover: #F6F7F8;
    --bg-deep: #F6F7F8;
    --border-subtle: #F0F2F3;
    --accent-gold: #D4A853;
    --accent-gold-dim: #b8913f;
}

/* ==========================================
   Reset / Base
   ========================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Outfit', sans-serif;
    background: var(--page-bg) !important;
    color: var(--text-primary) !important;
    min-height: 100vh;
}

/* ==========================================
   Top Navbar
   ========================================== */
.top-navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 48px;
    background: var(--navbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    z-index: 100;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 200px;
}

.navbar-hamburger {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    display: none;
    padding: 8px;
    border-radius: 50%;
}

.navbar-hamburger:hover { background: var(--hover-bg); }

.navbar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 800;
    color: var(--accent);
    text-decoration: none;
}

.navbar-logo-img {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    object-fit: contain;
    background: transparent;
    border: 1.5px solid rgba(212,168,83,0.3);
    flex-shrink: 0;
}

.navbar-search {
    flex: 1;
    max-width: 690px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--page-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0 16px;
    height: 36px;
    transition: border-color 0.2s;
}

.navbar-search:focus-within {
    border-color: var(--accent);
    background: #fff;
}

.navbar-search svg { color: var(--text-muted); flex-shrink: 0; }

.navbar-search input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 14px;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
}

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

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.navbar-create-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: none;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
    font-family: 'Outfit', sans-serif;
}

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

.navbar-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 50%;
    display: flex;
}

.navbar-icon-btn:hover { background: var(--hover-bg); color: var(--text-primary); }

.navbar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    border: 2px solid var(--border);
}

/* Push content below fixed navbar */
#app { padding-top: 48px; }

/* ==========================================
   App Layout
   ========================================== */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--right-panel-width);
    width: 100%;
    padding: 20px;
    gap: 24px;
}

@media (max-width: 1200px) {
    .app-layout {
        grid-template-columns: var(--sidebar-width) 1fr;
    }
    .right-panel { display: none; }
}

@media (max-width: 960px) {
    .app-layout {
        grid-template-columns: 1fr;
        padding: 0 0 80px 0;
        overflow-x: hidden;
    }
    .sidebar { display: none; }
    .main-feed { max-width: 100%; }
}

body { overflow-x: hidden; }

/* ==========================================
   Sidebar
   ========================================== */
.sidebar {
    position: sticky;
    top: 68px;
    height: fit-content;
    max-height: calc(100vh - 88px);
    overflow-y: auto;
}

/* Mobile sidebar drawer */
#sidebar-mount.mobile-open {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    z-index: 1000;
    background: var(--card-bg);
    overflow-y: auto;
    padding-top: 16px;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

/* Unhide inner sidebar content when drawer is open */
#sidebar-mount.mobile-open .sidebar {
    display: block;
    position: relative;
    top: auto;
    height: auto;
    max-height: none;
    overflow-y: visible;
}

#sidebar-mount.mobile-open .sidebar-section:has(.sidebar-logo) {
    display: block;
}

#sidebar-mount.mobile-open .sidebar-logo {
    display: flex;
}

.mobile-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}

.mobile-sidebar-backdrop.show { display: block; }

.sidebar-section {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 12px;
    margin-bottom: 12px;
}

.sidebar-section h3 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.sidebar-section:has(.sidebar-logo) {
    display: none;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0 12px;
}

.sidebar-logo-img {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    object-fit: contain;
    background: transparent;
    flex-shrink: 0;
}

.sidebar-logo .logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.sidebar-logo h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Sidebar nav */
.sidebar-nav { display: flex; flex-direction: column; }

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
}

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

.sidebar-nav-item .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

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

/* Create post button */
.create-post-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 8px 16px;
    background: var(--accent);
    border: none;
    border-radius: 20px;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.15s;
    font-family: 'Outfit', sans-serif;
}

.create-post-btn:hover { opacity: 0.9; }

/* Community list in sidebar */
.community-list { display: flex; flex-direction: column; }

.community-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.community-item:hover { background: var(--hover-bg); }
.community-item .community-icon { font-size: 18px; }
.community-item .community-name { flex: 1; }

/* DM badge */
.dm-unread-badge {
    background: #FF4500;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: auto;
}

/* ==========================================
   Main Feed
   ========================================== */
.main-feed { width: 100%; min-width: 0; }

.feed-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}

.sort-btn {
    padding: 6px 12px;
    border-radius: 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
    font-family: 'Outfit', sans-serif;
}

.sort-btn:hover { background: var(--hover-bg); color: var(--text-primary); }
.sort-btn.active { background: var(--hover-bg); color: var(--text-primary); }

.time-filter {
    padding: 6px 10px;
    background: var(--hover-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    outline: none;
}

.time-filter:focus { border-color: var(--accent); }

/* ==========================================
   Post Card - Reddit Style (no vote column)
   ========================================== */
.post-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    padding: 10px;
    cursor: pointer;
    transition: border-color 0.15s;
    display: block;
    text-decoration: none;
}

.post-card:hover { border-color: #898989; }

/* Hide old vote column if it somehow still renders */
.vote-column { display: none !important; }
.post-content { padding: 0 !important; }

.post-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.post-community-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--hover-bg);
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    overflow: hidden;
    flex-shrink: 0;
}

.post-meta a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 700;
}

.post-meta a:hover { text-decoration: underline; }

.post-community {
    color: var(--text-primary);
    font-weight: 700;
}

.post-community:hover { text-decoration: underline; }
.post-time { color: var(--text-secondary); font-weight: 400; }

/* Card inner: body + optional thumbnail */
.post-card-inner {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.post-card-body { flex: 1; min-width: 0; }

.post-thumbnail {
    width: 108px;
    height: 72px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--hover-bg);
}

.post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 8px;
    line-height: 1.4;
}

.post-title a {
    color: inherit;
    text-decoration: none;
}

.post-preview {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Full image in card */
.post-image-preview {
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin: 8px 0;
    max-height: 512px;
}

.post-image-preview img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
}

.post-link-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--hover-bg);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    margin: 8px 0;
    text-decoration: none;
}

.post-link-preview .link-icon { color: var(--accent); }
.post-link-preview:hover { background: var(--border); }

/* Rich link preview card */
.post-link-card {
    display: block;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin: 8px 0;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s;
}
.post-link-card:hover { border-color: var(--accent); }
.post-link-card-img {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    display: block;
}
.post-link-card-meta {
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.post-link-card-domain {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.post-link-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Post badges */
.post-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.post-badge.pinned { background: rgba(34,197,94,0.1); color: #22c55e; }
.post-badge.locked { background: rgba(239,68,68,0.1); color: #ef4444; }

/* ==========================================
   Post Actions - Pill Buttons
   ========================================== */
.post-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.post-action-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1px solid var(--pill-border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
    font-family: 'Outfit', sans-serif;
    text-decoration: none;
}

.post-action-pill:hover { background: var(--hover-bg); color: var(--text-primary); }

.post-action-pill.voted-up {
    color: var(--upvote);
    border-color: var(--upvote);
}

.post-action-pill.voted-down {
    color: var(--downvote);
    border-color: var(--downvote);
}

/* Vote pill internals */
.post-vote-pill {
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 0;
    border: 1px solid var(--pill-border);
    border-radius: 20px;
    background: transparent;
    overflow: hidden;
}

.post-vote-pill .vote-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 8px;
    transition: color 0.15s, background 0.15s;
    font-family: 'Outfit', sans-serif;
}

.post-vote-pill .vote-btn:hover { background: var(--hover-bg); }
.post-vote-pill .vote-btn.upvote:hover { color: var(--upvote); }
.post-vote-pill .vote-btn.downvote:hover { color: var(--downvote); }
.post-vote-pill .vote-btn.upvote.voted { color: var(--upvote); }
.post-vote-pill .vote-btn.downvote.voted { color: var(--downvote); }

.vote-score {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 24px;
    text-align: center;
    padding: 5px 2px;
    font-family: 'Outfit', sans-serif;
}

.vote-score.positive { color: var(--upvote); }
.vote-score.negative { color: var(--downvote); }

.vote-pill-divider {
    width: 1px;
    height: 14px;
    background: var(--border);
    flex-shrink: 0;
}

.post-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 8px;
    border: 1px solid var(--pill-border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s;
}

.post-action-icon:hover { background: var(--hover-bg); color: var(--text-primary); }
.post-action-icon.saved { color: var(--accent); border-color: var(--accent); }

/* ==========================================
   Mobile Topbar - Reddit Style
   ========================================== */
.mobile-topbar {
    display: none;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    position: sticky;
    top: 0;
    z-index: 50;
    align-items: center;
    gap: 10px;
}

.mobile-topbar-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--page-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0 12px;
    height: 36px;
}

.mobile-topbar-search input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 14px;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
}

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

.mobile-topbar-logo-icon {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    object-fit: contain;
    background: transparent;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
    color: #fff;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    position: relative;
}

.mobile-menu-btn .notif-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: #FF4500;
    border-radius: 50%;
}

/* ==========================================
   Mobile Bottom Tab Bar
   ========================================== */
.mobile-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    z-index: 100;
    flex-direction: row;
}

.bottom-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 3px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s;
}

.bottom-tab:hover { color: var(--text-primary); }
.bottom-tab.active { color: var(--text-primary); }

.bottom-tab-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border: 2px solid transparent;
}

.bottom-tab.active .bottom-tab-avatar { border-color: var(--text-primary); }

/* ==========================================
   Mobile Breakpoint Overrides
   ========================================== */
@media (max-width: 960px) {
    .mobile-topbar { display: flex; }
    .top-navbar { display: none !important; }
    .mobile-bottom-bar { display: flex !important; }
    #app { padding-top: 0; }
    main#main-mount { padding-bottom: 60px; }
}

/* ==========================================
   Right Panel
   ========================================== */
.right-panel {
    position: sticky;
    top: 68px;
    height: fit-content;
    max-height: calc(100vh - 88px);
    overflow-y: auto;
}

.panel-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 12px;
}

.panel-card h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* Recent posts in panel */
.recent-post-item {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
}

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

.recent-post-info { flex: 1; min-width: 0; }
.recent-post-meta { font-size: 11px; color: var(--text-secondary); margin-bottom: 2px; }

.recent-post-title {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.recent-post-stats { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.recent-post-thumb {
    width: 64px;
    height: 48px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--hover-bg);
}

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

/* Community info panel */
.community-info-panel .community-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.community-info-panel .community-icon-large {
    width: 48px;
    height: 48px;
    background: var(--hover-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.community-info-panel .community-title h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.community-info-panel .community-title p {
    font-size: 12px;
    color: var(--text-secondary);
}

.community-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.community-stat { text-align: center; }
.community-stat .stat-value { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.community-stat .stat-label { font-size: 11px; color: var(--text-secondary); }

.join-community-btn {
    width: 100%;
    padding: 8px;
    background: var(--accent);
    border: none;
    border-radius: 20px;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
}

.join-community-btn:hover { opacity: 0.9; }

.leave-community-btn {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
}

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

/* ==========================================
   Comment Styles
   ========================================== */
.comments-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-top: 10px;
}

.comment-sort-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.comment-count {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.comment-input-container {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--hover-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.comment-input-box { flex: 1; }

.comment-input-box textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'Outfit', sans-serif;
    resize: vertical;
    min-height: 80px;
    outline: none;
}

.comment-input-box textarea:focus { border-color: var(--accent); }

.submit-btn {
    margin-top: 8px;
    padding: 6px 16px;
    background: var(--accent);
    border: none;
    border-radius: 20px;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
}

.submit-btn:hover { opacity: 0.9; }

.comment-thread { padding: 0 16px; }

.comment {
    display: flex;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
}

.comment:last-child { border-bottom: none; }

.comment-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--hover-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    margin-top: 2px;
}

.comment-body { flex: 1; min-width: 0; }

.comment-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.comment-author {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

.comment-author:hover { text-decoration: underline; }
.comment-author.op { color: var(--accent); }
.comment-time { font-size: 12px; color: var(--text-muted); }

.comment-content {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.comment-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.comment-vote {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid var(--pill-border);
    border-radius: 20px;
}

.vote-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    padding: 0 2px;
    transition: color 0.15s;
}

.vote-btn:hover { color: var(--text-primary); }
.vote-btn.upvote:hover, .vote-btn.upvote.voted { color: var(--upvote); }
.vote-btn.downvote:hover, .vote-btn.downvote.voted { color: var(--downvote); }

.post-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 20px;
    transition: background 0.15s;
    font-family: 'Outfit', sans-serif;
}

.post-action-btn:hover { background: var(--hover-bg); color: var(--text-primary); }
.post-action-btn svg { flex-shrink: 0; }
.post-action-btn.saved { color: var(--accent); }

/* Indentation for replies */
.depth-1, .depth-2, .depth-3, .depth-4, .depth-5 {
    margin-left: 20px;
    padding-left: 12px;
    border-left: 2px solid var(--border);
}

.comment-line { display: none; }

/* Reply box */
.reply-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    resize: vertical;
    min-height: 60px;
    outline: none;
    margin-top: 8px;
}

.reply-input:focus { border-color: var(--accent); }
.cancel-reply-btn { margin-left: 8px; }

/* ==========================================
   Empty States
   ========================================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 12px 0 8px;
}

.empty-icon { font-size: 48px; color: var(--text-muted); }

/* ==========================================
   Loading Skeleton
   ========================================== */
.loading-skeleton {
    background: linear-gradient(90deg, var(--hover-bg) 25%, var(--border) 50%, var(--hover-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================
   Post Detail Header
   ========================================== */
.post-detail-header {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 10px;
}

.post-detail-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 10px;
    padding: 4px 0;
}
.post-detail-back:hover { color: var(--text-primary); }

.post-detail-card {
    cursor: default !important;
}
.post-detail-card:hover { border-color: var(--border) !important; }

/* ==========================================
   Modals
   ========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 540px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'Outfit', sans-serif;
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn-primary {
    padding: 8px 20px;
    background: var(--accent);
    border: none;
    border-radius: 20px;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
}

.btn-secondary {
    padding: 8px 20px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
}

.btn-primary:hover { opacity: 0.9; }
.btn-secondary:hover { background: var(--hover-bg); }

/* ==========================================
   Report Modal
   ========================================== */
.report-modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 400px;
    width: 100%;
}

.report-modal h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.report-reasons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.report-reason {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}

.report-reason:hover { background: var(--hover-bg); }

.report-reason.selected {
    border-color: var(--accent);
    background: rgba(212,168,83,0.05);
}

.radio-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
}

.report-reason.selected .radio-indicator {
    border-color: var(--accent);
    background: var(--accent);
}

.report-reason input { display: none; }

.report-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.report-cancel-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    color: var(--text-primary);
}

.report-submit-btn {
    padding: 8px 16px;
    background: var(--accent);
    border: none;
    border-radius: 20px;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
}

/* ==========================================
   Communities List Page
   ========================================== */
.communities-page { padding: 0; }

.communities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

@media (max-width: 600px) {
    .communities-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

.community-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s;
}
.community-card:hover { border-color: #898989; }

.community-card-link { display: block; text-decoration: none; color: inherit; }
.community-card-banner { height: 40px; background: linear-gradient(135deg, #D4A853, #f0d78c); }
.community-card-body { padding: 12px 16px 16px; }
.community-card-icon { font-size: 28px; margin-bottom: 6px; }
.community-card-name { font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.community-card-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.community-card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.community-card-footer { display: flex; align-items: center; }
.community-card-join-btn {
    padding: 6px 20px;
    background: var(--accent);
    border: none;
    border-radius: 20px;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
}
.community-card-join-btn.joined {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.community-card-join-btn:hover { opacity: 0.85; }

/* Communities page header */
.communities-page-header { margin-bottom: 16px; }
.communities-page-title { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.communities-page-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }
.communities-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.communities-search-box { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 200px; padding: 8px 12px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 20px; }
.communities-search-box:focus-within { border-color: var(--accent); }
.communities-search-icon { color: var(--text-muted); font-size: 14px; }
.communities-search-input { flex: 1; border: none; background: none; outline: none; font-size: 14px; color: var(--text-primary); font-family: 'Outfit', sans-serif; }
.communities-search-input::placeholder { color: var(--text-muted); }

/* ==========================================
   Toast
   ========================================== */
.toast {
    background: var(--text-primary) !important;
    color: var(--card-bg) !important;
    border: none !important;
}

/* ==========================================
   Utility / Misc
   ========================================== */
/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Links default */
a { color: var(--accent); }
a:hover { color: var(--accent); }

/* Select element */
select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23878A8C' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px !important;
}

/* ==========================================
   Create Post Modal (Reddit mobile style)
   ========================================== */
.create-post-overlay {
    position: fixed;
    inset: 0;
    background: var(--card-bg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.create-post-modal {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
}

.create-post-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.create-post-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    padding: 4px;
    border-radius: 50%;
}
.create-post-close:hover { background: var(--hover-bg); }

.create-post-submit-btn {
    padding: 6px 20px;
    background: var(--accent);
    border: none;
    border-radius: 20px;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    opacity: 1;
    transition: opacity 0.15s;
}
.create-post-submit-btn:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: default;
}

.create-post-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.create-post-community-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.create-post-community-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--hover-bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
}

.create-post-community-select {
    flex: 1;
    border: 2px solid #D0D3D8;
    border-radius: 8px;
    background: #fff;
    outline: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    padding: 8px 12px;
    transition: border-color 0.15s;
}
.create-post-community-select:focus { border-color: var(--accent); }

.create-post-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.create-post-title-input {
    width: 100%;
    border: 2px solid #D0D3D8;
    border-radius: 8px;
    outline: none;
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    background: #fff;
    padding: 10px 14px;
    line-height: 1.3;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.create-post-title-input:focus { border-color: var(--accent); }
.create-post-title-input::placeholder { color: #ADAEAF; }

.create-post-body-input {
    width: 100%;
    border: 2px solid #D0D3D8;
    border-radius: 8px;
    outline: none;
    font-size: 15px;
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
    background: #fff;
    resize: none;
    min-height: 120px;
    line-height: 1.5;
    padding: 12px 14px;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.create-post-body-input:focus { border-color: var(--accent); }
.create-post-body-input::placeholder { color: #ADAEAF; }

.create-post-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.create-post-tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.create-post-tool-btn:hover { background: var(--hover-bg); color: var(--text-primary); border-color: var(--text-muted); }
.create-post-tool-btn.active { color: var(--accent); border-color: var(--accent); background: var(--hover-bg); }

/* ==========================================
   Profile Page
   ========================================== */
.profile-page { }

.profile-header-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 10px;
}

.profile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.profile-username {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.profile-topbar-actions {
    display: flex;
    gap: 8px;
}

.profile-edit-btn {
    padding: 6px 20px;
    background: var(--hover-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
}

.profile-create-btn {
    padding: 6px 20px;
    background: var(--accent);
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    font-family: 'Outfit', sans-serif;
    display: inline-flex;
    align-items: center;
}

.profile-avatar-row { margin-bottom: 12px; }

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    border: 3px solid var(--card-bg);
}

.profile-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.profile-stats {
    display: flex;
    align-items: center;
    gap: 16px;
}

.profile-stat { text-align: left; }
.profile-stat-value { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.profile-stat-label { font-size: 12px; color: var(--text-secondary); }
.profile-stat-divider { width: 1px; height: 32px; background: var(--border); }

.profile-tabs {
    display: flex;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    overflow: hidden;
}

.profile-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-family: 'Outfit', sans-serif;
    transition: color 0.15s;
}
.profile-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.profile-tab:hover { color: var(--text-primary); }
.profile-post-item:hover { background: var(--bg-hover, rgba(0,0,0,0.04)); }

/* ==========================================
   Inbox Page
   ========================================== */
.inbox-page { }

.inbox-header-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 16px 0;
    margin-bottom: 10px;
}

.inbox-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.inbox-tabs {
    display: flex;
    gap: 0;
}

.inbox-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-family: 'Outfit', sans-serif;
    transition: color 0.15s;
}
.inbox-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.inbox-tab:hover { color: var(--text-primary); }

.inbox-content {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.inbox-item {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background 0.15s;
}
.inbox-item:last-child { border-bottom: none; }
.inbox-item:hover { background: var(--hover-bg); }
.inbox-item-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--hover-bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 20px; }
.inbox-item-body { flex: 1; min-width: 0; }
.inbox-item-title { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.inbox-item-text { font-size: 13px; color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.inbox-item-time { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.inbox-item-thumb { width: 56px; height: 56px; border-radius: 4px; overflow: hidden; flex-shrink: 0; background: var(--hover-bg); }
.inbox-item-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ==========================================
   RTL (Arabic) Support
   ========================================== */

/* Font */
[dir="rtl"] body,
[dir="rtl"] button,
[dir="rtl"] input,
[dir="rtl"] select,
[dir="rtl"] textarea {
    font-family: 'Cairo', 'Outfit', sans-serif;
}

/* Navbar */
[dir="rtl"] .navbar-left { flex-direction: row-reverse; }
[dir="rtl"] .navbar-actions { margin-left: 0; margin-right: auto; }

/* Sidebar drawer (slides from right on mobile in RTL) */
[dir="rtl"] #sidebar-mount.mobile-open {
    left: auto;
    right: 0;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
}

/* Sidebar nav items */
[dir="rtl"] .sidebar-nav-item { flex-direction: row-reverse; justify-content: flex-end; }
[dir="rtl"] .community-item { flex-direction: row-reverse; }

/* Unread badge */
[dir="rtl"] .dm-unread-badge { margin-left: 0; margin-right: auto; }

/* Comment threading — flip indentation */
[dir="rtl"] .comment-nested {
    margin-left: 0;
    margin-right: 20px;
    padding-left: 0;
    padding-right: 12px;
    border-left: none;
    border-right: 2px solid var(--border);
}

/* Post actions */
[dir="rtl"] .post-actions { flex-direction: row-reverse; }
[dir="rtl"] .post-meta { flex-direction: row-reverse; }

/* Select dropdown arrow */
[dir="rtl"] select { background-position: left 10px center; padding-right: 12px; padding-left: 32px; }

/* Feed sort row */
[dir="rtl"] .feed-header { flex-direction: row-reverse; }
[dir="rtl"] .feed-sort { flex-direction: row-reverse; }
