/* ==========================================================================
   TRENDING FORUM - Modern Feed Design System
   Inspired by Reddit, ProductHunt, and Indie Hackers
   ========================================================================== */

:root {
    --primary: #4f46e5;         /* Indigo primary */
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --accent: #f97316;          /* Orange fire accent for trending */
    --accent-hover: #ea580c;
    --accent-light: #fff7ed;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-input: #f1f5f9;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    
    --text-main: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    
    --header-height: 64px;
    --sidebar-width: 320px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
    transition: all 0.15s ease;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================================
   Header Navbar
   ========================================================================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.header-container {
    max-width: 1240px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.site-logo-img {
    max-height: 38px;
    width: auto;
    object-fit: contain;
    vertical-align: middle;
}

.site-logo .logo-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.site-logo span.accent {
    color: var(--accent);
}

.header-search {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.header-search input {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    padding: 9px 16px 9px 40px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    color: var(--text-main);
    outline: none;
    transition: all 0.2s ease;
}

.header-search input:focus {
    background-color: var(--bg-card);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.header-search .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 1rem;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
    box-sizing: border-box;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(79, 70, 229, 0.25);
}

.btn-accent {
    background-color: var(--accent);
    color: #ffffff;
}

.btn-accent:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(249, 115, 22, 0.25);
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--bg-input);
    color: var(--text-main);
    border-color: var(--border-hover);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    height: 36px;
    box-sizing: border-box;
}

.btn-create-post {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #ffffff;
    border-radius: var(--radius-full);
    padding: 6px 16px;
    height: 36px;
    font-size: 0.88rem;
    box-shadow: 0 2px 6px rgba(249, 115, 22, 0.3);
    box-sizing: border-box;
}

.btn-create-post:hover {
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
    transform: translateY(-1px);
}

/* User Menu & Avatar */
.user-menu-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #e2e8f0;
    display: inline-block;
}

.avatar-sm {
    width: 28px;
    height: 28px;
}

.avatar-lg {
    width: 64px;
    height: 64px;
}

.notif-bell {
    position: relative;
    padding: 8px;
    border-radius: 50%;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
}

.notif-bell:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background-color: var(--danger);
    color: #ffffff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 9999px;
    line-height: 1;
}

/* User Dropdown */
.user-dropdown {
    position: relative;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    padding: 4px 0;
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
}

/* Cầu nối vô hình giúp con trỏ chuột di chuyển xuống menu mà không bị mất hover */
.user-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 14px;
    background: transparent;
}

.user-dropdown:hover .user-dropdown-menu,
.user-dropdown.active .user-dropdown-menu {
    display: flex;
}

.user-dropdown-item {
    padding: 10px 16px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-dropdown-item:hover {
    background-color: var(--bg-input);
    color: var(--primary);
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ==========================================================================
   Layout & Main Grid
   ========================================================================== */
.main-wrapper {
    max-width: 1240px;
    margin: 24px auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
    gap: 28px;
    align-items: start;
}

.main-content {
    min-width: 0;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ==========================================================================
   Feed Hero Banner (Chuẩn Onpage SEO Thẻ H1 Trang Chủ)
   ========================================================================== */
.feed-hero-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.feed-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    background: var(--accent-light);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    margin-bottom: 10px;
}

.feed-hero-title {
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1.35;
    color: var(--text-main);
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}

.feed-hero-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
    max-width: 780px;
}

/* ==========================================================================
   Feed Header & Sorting Filter Tabs
   ========================================================================== */
.feed-header-tabs {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.tab-btn {
    padding: 8px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tab-btn:hover {
    background: var(--bg-input);
    color: var(--text-main);
}

.tab-btn.active {
    background: var(--primary-light);
    color: var(--primary);
}

.tab-btn.active.trending {
    background: var(--accent-light);
    color: var(--accent);
}

/* ==========================================================================
   Post Card (Trending Feed Item)
   ========================================================================== */
.post-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 14px;
    display: flex;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.post-card:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.post-card.pinned {
    border-left: 4px solid var(--primary);
    background: linear-gradient(to right, #fafafa, #ffffff);
}

/* Upvote / Like Box */
.vote-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-width: 44px;
}

.vote-btn {
    background: var(--bg-input);
    border: 1px solid transparent;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.15s ease;
}

.vote-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    transform: scale(1.05);
}

.vote-btn.liked {
    background: #fee2e2;
    color: #ef4444;
    border-color: #fecaca;
}

.vote-count {
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 4px;
    color: var(--text-secondary);
}

.vote-btn.liked + .vote-count {
    color: #ef4444;
}

/* Post Content Body */
.post-body {
    flex: 1;
    min-width: 0;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.post-author {
    font-weight: 600;
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.post-author:hover {
    color: var(--primary);
}

.badge-role {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-admin { background: #fee2e2; color: #dc2626; }
.badge-mod { background: #e0e7ff; color: #4338ca; }
.badge-pinned { background: #fef3c7; color: #b45309; }

.post-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
    line-height: 1.4;
}

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

.post-excerpt {
    font-size: 0.92rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.tag-badge {
    background: var(--bg-input);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.tag-badge:hover {
    background: var(--primary-light);
    color: var(--primary);
    transform: translateY(-1px);
}

.post-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.post-stat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary);
}

.post-stat:hover {
    color: var(--primary);
}

/* Post Thumbnail Preview */
.post-thumb-wrap {
    width: 110px;
    height: 80px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #e2e8f0;
}

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

/* ==========================================================================
   Sidebar Widgets
   ========================================================================== */
.card-widget {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.widget-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.trending-tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-pill {
    background: var(--bg-input);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.tag-pill:hover {
    background: var(--primary);
    color: #ffffff;
}

.tag-pill .tag-count {
    background: rgba(0, 0, 0, 0.08);
    font-size: 0.72rem;
    padding: 1px 6px;
    border-radius: 9999px;
}

.tag-pill:hover .tag-count {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.hot-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hot-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 10px;
}

.hot-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.hot-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
}

.hot-title:hover {
    color: var(--primary);
}

.hot-meta {
    font-size: 0.76rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==========================================================================
   Post Detail Page & Comments
   ========================================================================== */
.post-detail-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.post-detail-title {
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1.35;
    margin-bottom: 16px;
    color: var(--text-main);
}

.post-detail-content {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-main);
    margin: 24px 0;
}

.post-detail-content p {
    margin-bottom: 16px;
}

.post-detail-content ul, .post-detail-content ol {
    margin: 16px 0 16px 24px;
}

.post-detail-content li {
    margin-bottom: 6px;
}

.post-detail-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 20px auto;
    display: block;
    box-shadow: var(--shadow-sm);
}

.post-detail-content table, .te-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.95rem;
}

.post-detail-content th, .te-content th {
    background: var(--bg-hover);
    padding: 10px 14px;
    border: 1px solid var(--border);
    font-weight: 700;
    text-align: left;
}

.post-detail-content td, .te-content td {
    padding: 10px 14px;
    border: 1px solid var(--border);
}

.post-detail-content figcaption, .te-content figcaption {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    margin-top: -10px;
    margin-bottom: 20px;
}

.post-detail-content blockquote {
    border-left: 4px solid var(--primary);
    padding: 10px 18px;
    margin: 18px 0;
    background: var(--bg-input);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* Comments Section */
.comments-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-sm);
}

.comments-header {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.comment-form {
    margin-bottom: 28px;
}

.comment-textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    resize: vertical;
    min-height: 90px;
    transition: all 0.2s ease;
}

.comment-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.comment-item {
    display: flex;
    gap: 14px;
    margin-bottom: 20px;
    position: relative;
}

.comment-avatar {
    flex-shrink: 0;
}

.comment-bubble {
    flex: 1;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
}

.comment-author-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.comment-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.comment-action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.comment-action-btn:hover {
    color: var(--primary);
}

.replies-list {
    margin-left: 48px;
    margin-top: 14px;
    border-left: 2px solid var(--border);
    padding-left: 16px;
}

/* ==========================================================================
   Create Post Form
   ========================================================================== */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-sm);
}

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

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-main);
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-help {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Tag Picker Suggestions */
.tag-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tag-suggest-chip {
    background: var(--bg-input);
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
}

.tag-suggest-chip:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* ==========================================================================
   Custom TinyMCE-style Rich WYSIWYG Editor (TrendingEditor)
   ========================================================================== */
.trending-editor {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.trending-editor:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* Toolbar */
.te-toolbar {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    padding: 6px 10px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    user-select: none;
}

.te-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.te-divider {
    width: 1px;
    height: 22px;
    background: var(--border);
    margin: 0 4px;
}

.te-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 30px;
    height: 30px;
    line-height: 1;
    transition: all 0.15s ease;
}

.te-btn:hover {
    background: #e2e8f0;
    color: var(--text-main);
    border-color: #cbd5e1;
}

.te-btn.active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.te-btn-locked {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.te-btn-locked:hover {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

.te-select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    background: var(--bg-card);
    color: var(--text-main);
    height: 30px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.te-select:focus {
    border-color: var(--primary);
}

.te-color-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.te-color-input, .te-bg-color-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Editor Body & Content */
.te-body {
    position: relative;
    background: var(--bg-card);
    color: var(--text-main);
    min-height: 320px;
    max-height: 650px;
    overflow-y: auto;
}

.te-content {
    min-height: 320px;
    padding: 20px 24px;
    outline: none;
    font-size: 1.05rem;
    line-height: 1.8;
    color: #1e293b;
    word-break: break-word;
}

.te-content:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    cursor: text;
    pointer-events: none;
}

.te-content p {
    margin-bottom: 14px;
}

.te-content h2 {
    font-size: 1.45rem;
    font-weight: 800;
    margin: 24px 0 12px;
    color: var(--text-main);
}

.te-content h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 20px 0 10px;
    color: var(--text-main);
}

.te-content h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 16px 0 8px;
    color: var(--text-main);
}

.te-content blockquote {
    border-left: 4px solid var(--primary);
    background: var(--bg-input);
    padding: 12px 18px;
    margin: 16px 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-style: italic;
    color: var(--text-secondary);
}

.te-content pre {
    background: #0f172a;
    color: #f8fafc;
    padding: 14px 18px;
    border-radius: var(--radius);
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    margin: 16px 0;
}

.te-content ul, .te-content ol {
    margin: 14px 0 14px 28px;
}

.te-content li {
    margin-bottom: 6px;
}

.te-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 14px 0;
    box-shadow: var(--shadow-sm);
}

.te-content a {
    color: var(--primary);
    text-decoration: underline;
}

.te-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.te-content.te-dragover {
    background-color: #eff6ff !important;
    outline: 2px dashed var(--primary) !important;
    outline-offset: -4px;
}

.te-uploading-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: #f1f5f9;
    border-radius: 6px;
    color: var(--primary);
    font-size: 0.9rem;
    font-style: italic;
    margin: 10px 0;
}

/* Source View */
.te-source {
    width: 100%;
    min-height: 320px;
    padding: 18px 22px;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 0.9rem;
    border: none;
    outline: none;
    background: #0f172a;
    color: #38bdf8;
    line-height: 1.6;
    resize: vertical;
    box-sizing: border-box;
}

/* Statusbar */
.te-statusbar {
    background: #f8fafc;
    border-top: 1px solid var(--border);
    padding: 6px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
    user-select: none;
}

/* Fullscreen Mode */
.trending-editor.te-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    border-radius: 0;
    box-shadow: none;
}

.trending-editor.te-fullscreen .te-body {
    flex: 1;
    max-height: none;
    height: calc(100vh - 80px);
}

.trending-editor.te-fullscreen .te-content,
.trending-editor.te-fullscreen .te-source {
    min-height: 100%;
    height: 100%;
}

/* Modal Dialogs */
.te-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    backdrop-filter: blur(3px);
}

.te-modal-box {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 92%;
    max-width: 480px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    overflow: hidden;
    animation: teModalIn 0.2s ease-out;
}

@keyframes teModalIn {
    from { opacity: 0; transform: scale(0.96) translateY(-8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.te-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
}

.te-modal-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.te-modal-close {
    background: transparent;
    border: none;
    font-size: 1.3rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.te-modal-close:hover {
    color: var(--danger);
}

.te-modal-body {
    padding: 20px;
}

.te-modal-field {
    margin-bottom: 14px;
}

.te-modal-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-main);
}

.te-modal-field input[type="url"],
.te-modal-field input[type="text"] {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    outline: none;
    box-sizing: border-box;
}

.te-modal-field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.te-level-warning {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    color: #991b1b;
    font-size: 0.85rem;
    line-height: 1.5;
}

.te-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Image Tabs & Dropzone */
.te-tab-nav {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    gap: 8px;
}

.te-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: -1px;
}

.te-tab-btn:hover {
    color: var(--primary);
}

.te-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.te-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius);
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    background: #f8fafc;
    transition: all 0.2s ease;
}

.te-dropzone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* Alerts */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    margin-top: 60px;
    padding: 40px 0 24px;
}

.footer-container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 36px;
    margin-bottom: 30px;
}

.footer-col h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--text-main);
}

.footer-col p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-links a {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.footer-textlinks-box {
    margin-top: 24px;
    padding: 14px 18px;
    background: rgba(0, 0, 0, 0.02);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    font-size: 0.85rem;
}

.footer-textlinks-label {
    font-weight: 700;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.footer-textlinks-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
}

.footer-textlink-item {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

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

.footer-bottom {
    border-top: 1px solid var(--border);
    margin-top: 20px;
    padding-top: 20px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
    .main-wrapper {
        grid-template-columns: 1fr;
    }
    .sidebar {
        order: 2;
    }
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

@media (max-width: 600px) {
    .site-header {
        height: 56px;
    }
    .header-container {
        padding: 0 12px;
        gap: 8px;
    }
    .site-logo {
        font-size: 1.05rem;
        gap: 5px;
    }
    .site-logo .logo-icon {
        font-size: 1.25rem;
    }
    .header-search {
        display: none;
    }
    .header-nav {
        gap: 6px;
        flex-shrink: 0;
    }
    .header-nav .btn {
        height: 32px;
        padding: 0 10px;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    .btn-create-post {
        height: 32px;
        padding: 0 10px;
        font-size: 0.8rem;
        gap: 4px;
    }
    .btn-sm {
        height: 32px;
        padding: 0 10px;
        font-size: 0.8rem;
    }
    .post-card {
        padding: 14px;
        gap: 12px;
    }
    .vote-box {
        min-width: 36px;
    }
    .vote-btn {
        width: 34px;
        height: 34px;
    }
    .post-thumb-wrap {
        display: none;
    }
}

@media (max-width: 440px) {
    .header-container {
        padding: 0 8px;
        gap: 6px;
    }
    .site-logo span:not(.logo-icon) {
        font-size: 0.92rem;
    }
    .header-nav {
        gap: 4px;
    }
    .header-nav .btn {
        height: 30px;
        padding: 0 8px;
        font-size: 0.76rem;
    }
    .btn-create-post {
        height: 30px;
        padding: 0 8px;
        font-size: 0.76rem;
    }
    .btn-create-post .post-btn-text {
        display: none; /* Chỉ hiện biểu tượng ✏️ trên màn hình nhỏ để thanh header luôn cân đối */
    }
    .btn-sm {
        height: 30px;
        padding: 0 8px;
        font-size: 0.76rem;
    }
}
