/* =========================================================
   1. CORE VARIABLES & THEME SYSTEM
   ========================================================= */
:root {
    /* --- LIGHT MODE --- */
    --bg-body: #f0f2f5;
    --card-bg: #ffffff;
    --card-border: #cbd5e1;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --primary: #24A1DE;
    
    /* Colors & Effects */
    --tech-hover: #f1f5f9;
    --vip-overlay: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    --radius-card: 16px;
    --shadow-card: 0 4px 15px rgba(0,0,0,0.05);
    --font-main: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
}

/* --- DARK MODE --- */
body.dark-mode {
    --bg-body: #0f172a;
    --card-bg: #1e293b;
    --card-border: #334155;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --primary: #38bdf8;
    
    --tech-hover: #334155;
    --vip-overlay: linear-gradient(to top, rgba(15, 23, 42, 0.95), transparent);
    --shadow-card: 0 4px 15px rgba(0,0,0,0.3);
}

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

body {
    background: var(--bg-body);
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 14px;
    line-height: 1.5;
    transition: background 0.3s, color 0.3s;
}

a { text-decoration: none; color: inherit; transition: 0.2s; }
ul { list-style: none; }
.container { max-width: 1240px; margin: 0 auto; padding: 0 15px; }

/* =========================================================
   2. HEADER & NAVIGATION
   ========================================================= */
.main-header {
    background: var(--card-bg);
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    border-bottom: 1px solid var(--card-border);
    position: sticky; top: 0; z-index: 1000;
}
.header-content {
    display: flex; align-items: center; justify-content: space-between;
    height: 60px; gap: 15px;
}
.logo { font-size: 20px; font-weight: 800; color: var(--text-main); }
.logo span { color: var(--primary); }
.logo { 
    display: flex; 
    align-items: center; 
    gap: 10px;
    text-decoration: none;
    color: var(--text-main);
}

.logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 8px;
}

.logo-text {
    font-size: 20px; 
    font-weight: 800; 
    line-height: 1;
}

.logo-text span { 
    color: var(--primary); 
}

.search-wrapper { flex: 1; max-width: 500px; }
.search-form { 
    display: flex; background: var(--bg-body); 
    border: 1px solid var(--card-border);
    border-radius: 6px; padding: 4px 10px; 
}
.search-form input { 
    flex: 1; border: none; background: transparent; 
    padding: 6px; font-size: 14px; outline: none; color: var(--text-main);
}
.search-form button { border: none; background: transparent; cursor: pointer; color: var(--text-muted); }

.header-right { display: flex; align-items: center; gap: 10px; }

.btn-upload {
    background: #222; color: #fff; padding: 6px 14px;
    border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap;
}

/* Language Switcher */
.lang-dropdown { position: relative; display: inline-block; }
.lang-btn { 
    background: var(--bg-body); border: 1px solid var(--card-border); 
    padding: 6px 10px; border-radius: 6px; cursor: pointer; 
    font-size: 13px; font-weight: 600; color: var(--text-muted); 
    display: flex; align-items: center; gap: 4px; 
}
.lang-btn:hover { background: var(--card-border); }
.lang-content { 
    display: none; position: absolute; right: 0; top: 100%; 
    background-color: var(--card-bg); min-width: 150px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); border-radius: 8px; 
    z-index: 1001; padding: 5px 0; border: 1px solid var(--card-border); 
}
.lang-content a { 
    color: var(--text-main); padding: 8px 15px; text-decoration: none; 
    display: flex; align-items: center; gap: 8px; font-size: 13px; 
}
.lang-content a:hover { background-color: var(--tech-hover); color: var(--primary); }
.lang-dropdown:hover .lang-content { display: block; }

/* =========================================================
   3. HERO & CATEGORIES (EXPANDABLE)
   ========================================================= */
.home-spacer { margin-top: 25px; }

.section-box {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-card);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    padding: 20px; margin-bottom: 25px;
}

.section-head {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 15px; padding-bottom: 10px;
    border-bottom: 1px dashed var(--card-border);
}
.section-head h2 { margin: 0; font-size: 18px; font-weight: 800; color: var(--text-main); }
.section-head p { margin: 0; font-size: 13px; color: var(--text-muted); font-weight: 500; }

.home-cat-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.home-seo-box { margin-bottom: 20px; color: var(--text-muted); font-size: 14px; line-height: 1.6; max-width: 800px; }
.home-seo-title { font-size: 16px; font-weight: 700; color: var(--text-main); margin: 0 0 5px 0; }
.home-seo-desc { margin: 0; }

/* Toggle Logic */
.cats-wrapper {
    max-height: 0; opacity: 0; overflow: hidden;
    transition: all 0.4s ease-in-out; margin-top: 0; visibility: hidden; 
}
.cats-wrapper.expanded { max-height: 2000px; opacity: 1; margin-top: 15px; visibility: visible; }

.cats-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); padding: 5px; }
@media (min-width: 768px) { .cats-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1024px) { .cats-grid { grid-template-columns: repeat(6, 1fr); } }

.cat-card {
    border: 1px solid var(--card-border);
    border-radius: 12px; padding: 10px;
    background: var(--bg-body); display: flex; gap: 10px; align-items: center;
    transition: all 0.2s ease; min-height: 56px; color: var(--text-main);
}
.cat-card:hover { border-color: var(--primary); transform: translateY(-4px); box-shadow: 0 4px 12px rgba(22,119,255,0.1); }
.cat-card .ic {
    width: 32px; height: 32px; border-radius: 8px;
    background: rgba(36, 161, 222, 0.1); display: grid; place-items: center; 
    font-size: 16px; flex: 0 0 auto;
}
.cat-card .t { margin: 0; font-weight: 700; font-size: 13px; line-height: 1.2; color: var(--text-main); }

.btn-toggle-cats {
    display: flex; align-items: center; justify-content: center; gap: 5px;
    background: var(--bg-body); border: 1px solid var(--card-border);
    padding: 8px 15px; border-radius: 8px; color: var(--primary); font-weight: 700; font-size: 13px; cursor: pointer;
}

/* =========================================================
   4. VIP & EXPLORER SECTIONS
   ========================================================= */
.section-title-neon {
    font-size: 14px; font-weight: 800; color: #f472b6; 
    letter-spacing: 1px; margin-bottom: 15px; text-transform: uppercase;
    display: flex; align-items: center; gap: 5px;
}
.section-title-light {
    font-size: 14px; font-weight: 800; color: var(--text-muted); 
    letter-spacing: 1px; margin-bottom: 15px; text-transform: uppercase;
}

/* VIP GRID */
.grid-vip { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; }
@media (min-width: 768px) { .grid-vip { grid-template-columns: repeat(4, 1fr); } }

.card-vip {
    display: block; position: relative;
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 12px; overflow: hidden; text-decoration: none;
}
.card-vip:hover { border-color: #f472b6; transform: translateY(-3px); }

.vip-cover { height: 120px; position: relative; width: 100%; }
.vip-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vip-overlay { position: absolute; inset: 0; background: var(--vip-overlay); }
.badge-vip {
    position: absolute; top: 8px; right: 8px;
    background: #db2777; color: #fff;
    font-size: 9px; font-weight: 800; padding: 2px 6px; border-radius: 4px; z-index: 2;
}
.vip-info { padding: 10px; text-align: center; }
.vip-name { 
    color: var(--text-main); font-size: 13px; font-weight: 700; 
    margin-bottom: 8px; height: auto; max-height: 2.8em;
    white-space: normal !important; display: -webkit-box !important;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.btn-vip-join {
    width: 100%; background: linear-gradient(90deg, #ec4899, #8b5cf6);
    color: #fff; border: none; padding: 6px 0; border-radius: 6px; 
    font-weight: 700; font-size: 11px; cursor: pointer;
}

.grid-explorer, .trending-grid-modern { 
    display: grid; 
    gap: 15px; 
    /* PC Mặc định: 4 Cột */
    grid-template-columns: repeat(4, 1fr); 
}

@media (max-width: 991px) { 
    .grid-explorer, .trending-grid-modern { 
        grid-template-columns: repeat(2, 1fr) !important; 
        gap: 10px; 
    } 
}

@media (max-width: 360px) {
    .grid-explorer, .trending-grid-modern { 
        gap: 8px;
    }
}

.card-tech {
    display: flex; align-items: center; gap: 12px;
    background: var(--card-bg); border: 1px solid var(--card-border);
    padding: 12px; border-radius: 12px; text-decoration: none; transition: 0.2s;
}
.card-tech:hover { background: var(--tech-hover); border-color: var(--primary); }

.tech-avatar img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #000; }
.tech-info { flex: 1; min-width: 0; }
.tech-name { 
    color: var(--text-main); font-size: 13px; font-weight: 700; margin-bottom: 2px;
    white-space: normal !important; display: -webkit-box !important;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tech-meta { display: flex; gap: 8px; align-items: center; }
.tech-badge { font-size: 9px; padding: 2px 6px; border-radius: 4px; font-weight: 700; text-transform: uppercase; }
.tech-badge.group { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.tech-badge.channel { background: rgba(251, 146, 60, 0.15); color: #fb923c; }
.tech-mem { font-size: 11px; color: var(--text-muted); }
.ver-icon { width: 14px; height: 14px; color: var(--primary); vertical-align: middle; }

/* =========================================================
   5. GROUP CARDS & LISTINGS
   ========================================================= */
.home-section-transparent { padding: 0 !important; background: transparent !important; border: none !important; box-shadow: none !important; }
.home-head-transparent { margin-bottom: 20px !important; border: none !important; }

.grid-groups { display: grid; gap: 15px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 768px) { .grid-groups { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .grid-groups { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 599px) { .grid-groups { grid-template-columns: repeat(2, 1fr); gap: 10px; } }

/* GROUP CARD STYLE */
.gcard {
    background: var(--card-bg); 
    border: 1px solid var(--card-border);
    border-radius: 18px; box-shadow: var(--shadow-card);
    overflow: hidden; position: relative;
    display: flex; flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
    color: var(--text-main);
}
.gcard:hover { transform: translateY(-4px); box-shadow: 0 20px 40px rgba(0,0,0,0.1); border-color: var(--primary); }

.gcard-header { display: flex; justify-content: space-between; align-items: flex-start; width: 100%; padding: 12px 12px 0 12px; margin-bottom: 8px; }
.gcard-flag { display: flex; align-items: center; gap: 5px; height: 22px; }
.gcard-header-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.type-badge { font-size: 8px; padding: 3px 8px; line-height: 1; display: inline-block; white-space: nowrap; border-radius: 4px; }
.badge-access { margin-bottom: 0 !important; font-size: 7px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; opacity: 0.9; }
.badge-access.private { background-color: #fef2f2; color: #ef4444; border: 1px solid #fecaca; }
.badge-access.public { background-color: #eff6ff; color: #3b82f6; border: 1px solid #dbeafe; }

.gcard-body { padding: 5px 12px 10px 12px; display: flex; flex-direction: column; align-items: center; flex: 1; }
.gcard-img-wrapper { margin-bottom: 8px; }
.gcard-avatar {
    width: 64px; height: 64px; border-radius: 50%;
    border: 3px solid var(--card-bg); box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    object-fit: cover; background: #f1f5f9;
}
.gcard-name {
    font-size: 14px; font-weight: 700; color: var(--text-main);
    text-align: center; margin: 0 0 8px 0; width: 100%;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; line-height: 1.4; height: 2.8em; word-break: break-word; white-space: normal !important;
}
.gcard-info-row { display: flex; justify-content: center; align-items: center; width: 100%; margin-bottom: 6px; }
.badge-row { gap: 6px; flex-wrap: wrap; height: 24px; }
.meta-badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--tech-hover); color: var(--text-muted); font-weight: 600; }
.member-count { font-size: 12px; color: var(--text-muted); font-weight: 500; display: flex; align-items: center; gap: 4px; }

.gcard-footer {
    padding: 12px; background: var(--bg-body);
    border-top: 1px solid var(--card-border);
    display: flex; flex-direction: column; gap: 10px;
}
.btn-join-block {
    display: flex; align-items: center; justify-content: center;
    width: 100%; padding: 10px 0; border-radius: 8px;
    font-weight: 700; font-size: 14px; text-decoration: none; color: #fff !important;
    transition: opacity 0.2s;
}
.gcard-bottom-actions { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.btn-action-small {
    background: transparent; border: 1px solid var(--card-border);
    padding: 6px 12px; border-radius: 6px;
    font-size: 12px; font-weight: 600; color: var(--text-muted);
    cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 5px;
}

/* Colors for Card Types */
.theme-channel .type-badge { background: #fff3e0; color: #e65100; }
.theme-channel .btn-join-block { background: linear-gradient(135deg, #ff9800, #f57c00); }
.theme-group .type-badge { background: #e1f5fe; color: #0288d1; }
.theme-group .btn-join-block { background: linear-gradient(135deg, #42a5f5, #1976d2); }

/* =========================================================
   6. SIDEBAR & FILTERS (MERGED & OPTIMIZED)
   ========================================================= */
.sidebar-wrapper-fix { height: 100%; }
.sidebar-widget {
    background: var(--card-bg); 
    border: 1px solid var(--card-border);
    border-radius: 16px; padding: 20px;
    margin-bottom: 20px; 
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);
}
.widget-title {
    margin: 0 0 15px; font-size: 15px; font-weight: 800;
    padding-bottom: 12px; border-bottom: 1px solid var(--card-border);
    color: var(--text-main); text-transform: uppercase; letter-spacing: 0.5px;
}

/* TRENDING LIST STYLES (Includes Ver 27/28 Fixes) */
.trending-list { padding: 0; margin: 0; list-style: none; }
.trending-list li {
    display: flex; align-items: flex-start; gap: 12px;
    margin-bottom: 15px; padding-bottom: 15px; 
    border-bottom: 1px dashed var(--card-border);
}
.trending-list li:last-child { border: none; margin: 0; padding: 0; }

.rank-num {
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px;
    background: var(--bg-body); color: var(--text-muted);
    border-radius: 8px; font-size: 13px; font-weight: 800;
    flex-shrink: 0; border: 1px solid var(--card-border); margin-top: 2px;
}
/* Rank Colors */
.rank-0 { background: #fffbeb; color: #d97706; border-color: #fcd34d; }
.rank-1 { background: #f0f9ff; color: #0284c7; border-color: #bae6fd; }
.rank-2 { background: #fff1f2; color: #e11d48; border-color: #fecdd3; }
body.dark-mode .rank-0 { background: rgba(217, 119, 6, 0.2); border-color: rgba(217, 119, 6, 0.4); color: #fbbf24; }
body.dark-mode .rank-1 { background: rgba(2, 132, 199, 0.2); border-color: rgba(2, 132, 199, 0.4); color: #38bdf8; }
body.dark-mode .rank-2 { background: rgba(225, 29, 72, 0.2); border-color: rgba(225, 29, 72, 0.4); color: #fb7185; }

.trend-info { flex: 1; min-width: 0; }
.trend-info a, .trend-info .top-link { 
    font-weight: 700; font-size: 13px; color: var(--text-main); 
    display: block; line-height: 1.4; margin-bottom: 5px;
    text-decoration: none; transition: 0.2s;
    /* Updated Text Wrap Logic */
    white-space: normal !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    text-overflow: ellipsis; word-break: break-word; height: auto;
}
.trend-info a:hover { color: var(--primary); }

.top-meta { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.badge-type { font-size: 9px; padding: 2px 5px; border-radius: 4px; font-weight: 700; }
.badge-type.ch { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.badge-type.gr { background: rgba(37, 99, 235, 0.15); color: #3b82f6; }

/* --- FILTER & TABS (OPTIMIZED VER 39) --- */
.nav-controls-wrapper {
    display: flex; flex-direction: column; gap: 15px;
    margin-bottom: 25px; 
    background: var(--card-bg); border: 1px solid var(--card-border); 
    border-radius: 12px; padding: 15px;
}
.tab-nav-container { 
    display: flex; align-items: center; gap: 12px; 
    border-bottom: none !important; padding-bottom: 0 !important; margin-bottom: 0 !important;
}

/* Big Tab Buttons */
.tab-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; height: 44px; border-radius: 10px;            
    font-size: 14px; font-weight: 800; text-transform: capitalize; text-decoration: none;
    transition: all 0.15s ease-in-out;
    background-color: #ffffff; border: 2px solid #cbd5e1; color: #334155; position: relative;
}
.tab-btn:hover { background-color: #f8fafc; border-color: #94a3b8; color: #0f172a; transform: translateY(-1px); }
.tab-btn.active {
    background-color: var(--primary); border-color: var(--primary); color: #ffffff;
    box-shadow: 0 4px 12px rgba(36, 161, 222, 0.35);
}
.tab-btn::after { display: none !important; }

/* Tab Counts */
.tab-count { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 20px; line-height: 1; }
.tab-btn .tab-count { background-color: #e2e8f0; color: #1e293b; }
.tab-btn.active .tab-count { background-color: rgba(0, 0, 0, 0.2); color: #fff; }

/* Dark Mode Tabs */
body.dark-mode .tab-btn { background-color: #1e293b; border-color: #475569; color: #cbd5e1; }
body.dark-mode .tab-btn:hover { background-color: #334155; border-color: #94a3b8; color: #fff; }
body.dark-mode .tab-btn.active { background-color: var(--primary); border-color: var(--primary); color: #fff; }
body.dark-mode .tab-btn .tab-count { background-color: #0f172a; color: #94a3b8; }
body.dark-mode .tab-btn.active .tab-count { background-color: rgba(0,0,0,0.3); color: #fff; }

/* Sort & Filter Controls */
.nav-filters-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filter-item-group { 
    display: flex; align-items: center; background: var(--bg-body); 
    border: 1px solid var(--card-border); padding: 6px 10px; border-radius: 8px; 
}
.filter-label-small { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-right: 5px; }
.dropdown-sort { position: relative; display: inline-block; }
.btn-sort-toggle {
    background: transparent; border: none; padding: 0;
    cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 5px;
}
.sort-menu {
    display: none; position: absolute; top: 100%; left: 0; min-width: 140px;
    background: var(--card-bg); border: 1px solid var(--card-border);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1); border-radius: 8px; z-index: 50; margin-top: 8px;
}
.dropdown-sort.open .sort-menu { display: block; animation: fadeIn 0.2s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.sort-item { display: block; padding: 8px 15px; font-size: 13px; color: var(--text-main); text-decoration: none; }
.sort-item:hover { background: var(--bg-body); color: var(--primary); }
.sort-item.active { font-weight: 700; color: var(--primary); background: var(--bg-body); }

/* =========================================================
   7. LIVE FEED (MINI GRID)
   ========================================================= */
.live-feed-section { margin-top: 30px; border-top: 1px dashed var(--card-border); padding-top: 20px; }
.live-feed-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 15px; }

@media (min-width: 992px) { 
    .live-feed-grid { grid-template-columns: repeat(8, 1fr); gap: 12px; } 
}

.d-card {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 8px; padding: 10px 5px;
    display: flex; flex-direction: column; align-items: center; text-align: center;
    text-decoration: none; transition: all 0.2s ease; height: 100%;
}
.d-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

.d-card-avatar {
    width: 48px; height: 48px; border-radius: 50%; object-fit: cover;
    border: 1px solid var(--card-border); margin-bottom: 8px; background: #f1f5f9;
}
.d-card-name {
    font-size: 11px; font-weight: 700; color: var(--text-main);
    line-height: 1.3; margin-bottom: 4px; width: 100%;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    height: 2.6em; white-space: normal !important;
}
.d-card-mini-foot {
    font-size: 9px; color: var(--text-muted);
    display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: auto;
}
.status-live { color: #16a34a; font-weight: 700; display: flex; align-items: center; gap: 3px; }
.pulse-dot { width: 5px; height: 5px; background: #22c55e; border-radius: 50%; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

body.dark-mode .d-card { background: #1e293b; border-color: #334155; }
body.dark-mode .d-card-avatar { border-color: #334155; }

/* =========================================================
   8. FOOTER & TAGS (FINAL VERSION)
   ========================================================= */
.home-tags-section { margin-top: 20px; }
.chip-container { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 99px;
    border: 1px solid var(--card-border); background: var(--bg-body);
    font-size: 13px; font-weight: 600; color: var(--text-muted);
}
.chip:hover { border-color: var(--primary); color: var(--primary); }

.main-footer {
    margin-top: auto; background: var(--card-bg); border-top: 1px solid var(--card-border);
    padding-top: 50px; color: var(--text-muted); font-size: 14px;
}
.footer-grid { display: grid; gap: 30px; margin-bottom: 30px; grid-template-columns: 1fr; text-align: center; }
@media (min-width: 768px) { .footer-grid { grid-template-columns: 1.5fr 1fr 1fr 1fr; text-align: left; } }

.footer-logo { font-size: 24px; font-weight: 800; color: var(--text-main); text-decoration: none; display: block; margin-bottom: 10px; }
.footer-logo span { color: var(--primary); }
.footer-desc { line-height: 1.5; margin-bottom: 15px; font-size: 13px; color: var(--text-muted); }

.footer-head { color: var(--text-main); font-size: 14px; font-weight: 700; text-transform: uppercase; margin-bottom: 15px; }
.footer-links { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.footer-link-item { color: var(--text-muted); text-decoration: none; transition: 0.2s; }
.footer-link-item:hover { color: var(--primary); padding-left: 3px; }

.footer-socials { display: flex; gap: 10px; justify-content: center; }
@media (min-width: 768px) { .footer-socials { justify-content: flex-start; } }
.social-btn {
    width: 32px; height: 32px; border-radius: 6px; background: var(--bg-body); color: var(--text-muted);
    display: flex; align-items: center; justify-content: center; text-decoration: none; font-size: 16px;
}
.social-btn:hover { background: var(--primary); color: #fff; }

.footer-copyright {
    border-top: 1px solid var(--card-border); padding: 20px 0; text-align: center;
    color: var(--text-muted); font-size: 13px; background: var(--bg-body);
}

/* =========================================================
   9. PAGES (SEARCH, DETAIL, STATIC)
   ========================================================= */
/* Search Page */
.search-header-box { text-align: center; margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px solid var(--card-border); }
.search-title { font-size: 1.8rem; font-weight: 800; color: var(--text-main); margin-bottom: 10px; }
.search-desc { color: var(--text-muted); font-size: 14px; max-width: 600px; margin: 0 auto; }
.grid-search { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 768px) { .grid-search { grid-template-columns: repeat(3, 1fr); gap: 15px; } }
@media (min-width: 1024px) { .grid-search { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 1200px) { .grid-search { grid-template-columns: repeat(6, 1fr); } }
.grid-search .gcard-body { padding: 8px 10px; }
.grid-search .gcard-name { font-size: 13px; height: 2.6em; margin-bottom: 5px; }
.grid-search .btn-join-block { padding: 8px 0; font-size: 12px; }
.search-empty { text-align: center; padding: 60px 20px; background: var(--card-bg); border: 1px dashed var(--card-border); border-radius: 16px; }

/* Detail Page */
.detail-box {
    background: var(--card-bg); border-radius: 12px; padding: 40px;
    text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    border: 1px solid var(--card-border);
}
.detail-avatar {
    width: 100px; height: 100px; border-radius: 50%; object-fit: cover; 
    border: 4px solid var(--bg-body); box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    display: block; margin: 0 auto 20px auto;
}
.detail-type-wrap { margin-bottom: 10px; display: flex; gap: 10px; justify-content: center; align-items: center; }
.detail-badge { padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 700; letter-spacing: 1px; display: inline-block; }
.detail-title { font-size: 28px; font-weight: 800; margin: 0 0 15px; color: var(--text-main); }
.detail-stats { display: flex; justify-content: center; gap: 20px; color: var(--text-muted); font-size: 16px; margin-bottom: 30px; }
.detail-stats span { display: flex; align-items: center; gap: 5px; }
.detail-stats strong { color: var(--text-main); }
.detail-desc { max-width: 600px; margin: 0 auto 30px; color: var(--text-main); line-height: 1.6; font-size: 15px; opacity: 0.9; }
.detail-btn-join {
    display: inline-block; padding: 16px 50px; border-radius: 50px; text-decoration: none;
    font-weight: 800; font-size: 18px; color: white !important;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15); transition: transform 0.2s, box-shadow 0.2s;
}
.detail-btn-join:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.2); }
.detail-note { margin-top: 15px; font-size: 13px; color: var(--text-muted); }
.theme-channel .detail-badge { background: #fff3e0; color: #e65100; }
.theme-channel .detail-btn-join { background: #e65100; }
.theme-bot .detail-badge { background: #ede7f6; color: #673ab7; }
.theme-bot .detail-btn-join { background: #673ab7; }
.theme-group .detail-badge { background: #e3f2fd; color: #1565c0; }
.theme-group .detail-btn-join { background: #24A1DE; }
.detail-tag {
    display: inline-block; background: var(--bg-body); color: var(--text-muted);
    padding: 6px 12px; border-radius: 20px; text-decoration: none;
    font-size: 14px; margin: 3px; border: 1px solid var(--card-border);
}
.detail-related-title { margin-top: 50px; font-size: 20px; font-weight: 700; color: var(--text-main); }
.detail-related-grid { margin-top: 20px; grid-template-columns: repeat(6, 1fr) !important; }

/* Category List Page */
.cat-hero-section {
    padding: 30px !important; background: var(--card-bg); position: relative; overflow: hidden; 
    border-bottom: 1px solid var(--card-border); margin-bottom: 25px; border-radius: 12px;
}
.cat-hero-line { position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: linear-gradient(90deg, #24A1DE, #1677ff); }
.cat-hero-body { display: flex; gap: 25px; align-items: flex-start; }
.cat-hero-icon {
    flex-shrink: 0; width: 80px; height: 80px; background: var(--bg-body); 
    border: 1px solid var(--card-border); border-radius: 20px; 
    display: flex; align-items: center; justify-content: center; font-size: 40px; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}
.cat-hero-content { flex: 1; }
.cat-hero-title { margin: 0 0 10px; font-size: 28px; font-weight: 800; color: var(--text-main); letter-spacing: -0.5px; }
.cat-hero-desc { font-size: 15px; color: var(--text-muted); line-height: 1.7; max-width: 900px; }
.cats-grid-page { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px; }
@media (min-width: 1200px) { .cats-grid-page { grid-template-columns: repeat(6, 1fr) !important; } }
.cat-card-item {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 16px; padding: 30px 20px; text-align: center;
    text-decoration: none; display: flex; flex-direction: column; align-items: center; transition: all 0.3s;
}
.cat-card-item:hover { transform: translateY(-5px); border-color: var(--primary); box-shadow: 0 10px 20px rgba(0,0,0,0.05); }
.cat-icon-box {
    width: 64px; height: 64px; background: var(--bg-body); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 32px;
    margin-bottom: 20px; transition: 0.3s;
}
.cat-card-item:hover .cat-icon-box { background: var(--primary); color: #fff; transform: scale(1.1); }
.cat-name { font-size: 18px; font-weight: 700; color: var(--text-muted); margin: 0 0 10px; }
.cat-card-item:hover .cat-name { color: var(--text-main); }

/* Static & Contact */
.static-page-box {
    background: var(--card-bg); padding: 40px; border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03); margin-bottom: 40px; border: 1px solid var(--card-border);
}
.static-title {
    font-size: 28px; font-weight: 800; color: var(--text-main);
    margin-bottom: 25px; padding-bottom: 15px; border-bottom: 2px solid var(--bg-body);
}
.static-content { font-size: 15px; line-height: 1.8; color: var(--text-main); }
.static-content h2, .static-content h3 { color: var(--text-main); font-weight: 700; margin-top: 30px; }
.static-content a { color: var(--primary); text-decoration: underline; }

.contact-grid { display: grid; gap: 40px; grid-template-columns: 1fr; }
@media (min-width: 768px) { .contact-grid { grid-template-columns: 1fr 1fr; } }
.contact-form label { display: block; font-weight: 600; color: var(--text-main); margin-bottom: 8px; font-size: 14px; }
.contact-form input, .contact-form textarea {
    width: 100%; padding: 12px 15px; border: 1px solid var(--card-border);
    border-radius: 8px; font-size: 14px; outline: none; background: var(--bg-body); color: var(--text-main);
}
.contact-form button {
    background: var(--primary); color: #fff; border: none; padding: 12px 30px;
    border-radius: 8px; font-weight: 700; font-size: 15px; cursor: pointer; width: 100%;
}
.info-item { display: flex; gap: 15px; margin-bottom: 20px; }
.info-icon {
    width: 40px; height: 40px; background: var(--card-bg); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); font-size: 18px; color: var(--primary);
}
.info-text h4 { margin: 0 0 5px; font-size: 15px; font-weight: 700; color: var(--text-main); }
.info-text p { margin: 0; color: var(--text-muted); font-size: 14px; }

/* Modals */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); z-index: 2000; justify-content: center; align-items: center;
}
.modal-active { display: flex; }
.modal-box {
    background: var(--card-bg); width: 90%; max-width: 400px; padding: 20px;
    border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); color: var(--text-main);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; border-bottom: 1px solid var(--card-border); padding-bottom: 10px; }
.modal-title { font-size: 18px; font-weight: 800; }
.modal-close { background: none; border: none; font-size: 28px; cursor: pointer; color: var(--text-muted); }
.report-form label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 13px; }
.report-form select, .report-form textarea {
    width: 100%; padding: 10px; border: 1px solid var(--card-border); border-radius: 8px;
    margin-bottom: 15px; background: var(--bg-body); color: var(--text-main);
}
.report-form button { width: 100%; padding: 12px; background: #ef4444; color: white; border: none; border-radius: 8px; font-weight: 700; cursor: pointer; }

/* Tags Backdrop Modal */
#tagsBackdrop {
    z-index: 9999 !important; display: none; align-items: center; justify-content: center;
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px);
}
#tagsBackdrop.active { display: flex !important; }
#tagsBackdrop .modal {
    display: flex; flex-direction: column; width: 90%; max-width: 800px; max-height: 85vh;
    background: var(--card-bg); border-radius: 16px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden; animation: modalFadeIn 0.2s ease-out;
}
@keyframes modalFadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
#tagsBackdrop .modal-head { padding: 15px 20px; border-bottom: 1px solid var(--card-border); display: flex; justify-content: space-between; align-items: center; }
#tagsBackdrop .modal-title { font-size: 18px; font-weight: 800; color: var(--text-main); }
#tagsBackdrop .modal-close { background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer; }
#tagsBackdrop .modal-body { flex: 1; overflow-y: auto; padding: 20px; }
.modal-search-box {
    display: flex; align-items: center; gap: 10px; background: var(--bg-body); padding: 12px 15px;
    border-radius: 10px; margin-bottom: 20px; border: 1px solid var(--card-border);
}
.modal-search-box input { border: none; background: transparent; width: 100%; outline: none; color: var(--text-main); font-size: 15px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-start; }
.tag-loader { text-align: center; padding: 40px; color: var(--text-muted); display: none; }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 30px; flex-wrap: wrap; }
.page-link {
    display: inline-flex; align-items: center; justify-content: center;
    height: 38px; min-width: 38px; padding: 0 10px;
    border: 1px solid var(--card-border); border-radius: 8px;
    color: var(--text-muted); background: var(--card-bg); font-weight: 700;
}
.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-link.active { background: var(--primary); color: white; border-color: var(--primary); }

/* =========================================================
   10. PC SPECIFIC LAYOUT (REVERT TO 4 COLS & STATIC)
   ========================================================= */
@media (min-width: 992px) {
    /* 1. LAYOUT CHÍNH */
    .modern-layout {
        display: grid; 
        grid-template-columns: 1fr 320px; 
        gap: 25px; 
        align-items: start;
    }
    
    .main-content { grid-column: 1 / 2; min-width: 0; }
    
    /* 2. SIDEBAR STATIC (AN TOÀN) */
    .sidebar-wrapper-fix { 
        grid-column: 2 / 3;
        position: static !important;
        height: auto !important;
        margin-top: 0;
        z-index: 1;
    }

    /* 3. CÁC KHỐI FULL-WIDTH (Live Feed, Tags, Random Block) */
    .live-feed-section,
    .home-tags-container,
    .home-tags-section {
        grid-column: 1 / -1; width: 100%;
        position: static; margin-top: 30px; clear: both;
    }
    
    /* 4. CẤU HÌNH CỘT */
    /* Icon Danh Mục: 6 Cột */
    .cats-grid {
        grid-template-columns: repeat(6, 1fr) !important;
    }
    
    /* Grid Groups: QUAY VỀ MẶC ĐỊNH (4 CỘT) */
    .grid-groups { 
        grid-template-columns: repeat(4, 1fr); 
        gap: 15px; /* Trả lại gap rộng cho thoáng */
    }

    /* Live Feed Grid (Random Block): 8 Cột trên PC */
    .live-feed-grid {
        grid-template-columns: repeat(8, 1fr) !important; 
        gap: 12px !important;
    }

    /* --- [GIỮ NGUYÊN CSS KHÁC] --- */
    .filter-status-bar {
        text-align: center; font-size: 16px; font-weight: 600;
        max-width: 700px; margin: 20px auto 15px auto;
        background: #ffffff; border: 2px solid #e2e8f0;
        border-radius: 50px; padding: 12px 30px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    }
    .status-highlight {
        display: inline-block; background: #e0f2fe; color: #0284c7;
        padding: 4px 12px; border-radius: 20px; margin: 0 4px; 
        font-size: 15px; border: 1px solid #bae6fd;
    }

    /* CSS Sidebar cũ */
    .sidebar-widget { padding: 20px !important; margin-bottom: 20px !important; }
    .widget-title { margin: 0 0 12px 0 !important; padding-bottom: 10px !important; font-size: 15px !important; border-bottom: 1px solid var(--card-border) !important; }
    .trending-list li { margin-bottom: 14px !important; padding-bottom: 14px !important; align-items: flex-start !important; gap: 12px !important; border-bottom: 1px dashed var(--card-border) !important; display: flex !important; }
    .trending-list li:last-child { margin-bottom: 0 !important; padding-bottom: 0 !important; border: none !important; }
    .trending-list li .trend-info { display: flex !important; flex-direction: column !important; justify-content: flex-start !important; gap: 0 !important; flex: 1 !important; min-width: 0 !important; height: auto !important; }
    .trending-list li .trend-info a, .trending-list li .trend-info .top-link { margin: 0 0 2px 0 !important; padding: 0 !important; font-size: 13px !important; font-weight: 700 !important; line-height: 1.35 !important; height: auto !important; min-height: 0 !important; max-height: none !important; display: -webkit-box !important; -webkit-line-clamp: 2 !important; -webkit-box-orient: vertical; overflow: hidden; white-space: normal !important; }
    .trending-list li .trend-info .top-meta { margin-top: 0 !important; padding-top: 0 !important; line-height: 1 !important; display: flex; align-items: center; gap: 6px; font-size: 11px !important; height: auto !important; }
    .rank-num { width: 24px !important; height: 24px !important; font-size: 12px !important; margin-top: 2px !important; flex-shrink: 0 !important; }
    .badge-type { padding: 2px 5px !important; font-size: 9px !important; border-radius: 4px !important; }
}
@media (max-width: 991px) {
    .live-feed-grid.random-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }
    .live-feed-grid.random-grid > .d-card:nth-child(n+22) {
        display: none !important;
    }
}

/* =========================================================
   11. MOBILE SPECIFIC OVERRIDES (MAX-WIDTH: 991px & SMALLER)
   ========================================================= */
@media (max-width: 991px) {
    /* Layout */
    .modern-layout { display: flex; flex-direction: column; }
    .main-content { order: 1; }
    .live-feed-section { order: 2; } /* Live Feed nằm sau Content */
    .sidebar-wrapper-fix { 
        order: 3; /* Sidebar xuống vị trí thứ 3 */
        display: block !important; margin-top: 25px;
        background: var(--bg-body); padding: 15px;
        border-radius: 12px; border: 1px solid var(--card-border);
    }
    .home-tags-container { order: 4; } /* Tags xuống cuối cùng */

    /* [FIX] Mobile Sidebar Colors & Position */
    .sidebar-widget {
        background: var(--card-bg); border: 1px solid var(--card-border);
        border-radius: 12px; margin-bottom: 15px; box-shadow: none;
    }
    .sidebar-widget h3.widget-title { color: var(--text-main); border-bottom-color: var(--card-border); }
    .trend-info a, .top-link { color: var(--text-main) !important; }
}

@media (max-width: 768px) {
    /* Header & Layout */
    .header-content { flex-wrap: wrap; height: auto; padding-bottom: 10px; }
    .search-wrapper { order: 3; width: 100%; max-width: 100%; }
    .home-tags-section { order: 3; margin-top: 20px; }
    
    /* Filters */
    .nav-controls { flex-direction: column; gap: 12px; background: transparent; border: none; padding-bottom: 0; align-items: stretch !important; }
    .filters-group { flex-direction: column; width: 100%; gap: 12px; display: flex; align-items: center; }
    .nav-filters-row { flex-direction: column; align-items: stretch; gap: 10px; }
    
    .filter-item-group:not(:last-child) { width: 100%; justify-content: space-between; margin: 0 !important; }
    .filter-item-group:not(:last-child) .dropdown-sort { flex-grow: 1; margin-left: 15px; }
    .filter-item-group:not(:last-child) .btn-sort-toggle { width: 100% !important; justify-content: space-between; padding: 10px 15px; }
    .filter-item-group:last-child { width: auto; margin-top: 5px; }

    /* Page Details */
    .cat-hero-section { padding: 20px !important; }
    .cat-hero-body { flex-direction: column; align-items: center; text-align: center; gap: 15px; }
    .detail-stats { flex-direction: column; gap: 10px; }
    .contact-grid { grid-template-columns: 1fr; }
    .detail-box { padding: 25px 15px; }
    .detail-title { font-size: 22px; }
    .detail-btn-join { width: 100%; padding: 14px; font-size: 16px; }
}

@media (max-width: 480px) {
    /* [FIX] Compact Mobile Cards */
    .grid-groups, .search-grid, .grid-search { gap: 8px !important; }
    .gcard { border-radius: 12px; }
    
    /* Header Card */
    .gcard-header { padding: 8px 8px 0 8px; margin-bottom: 4px; }
    .gcard-flag img { width: 14px; }
    .gcard-flag span { font-size: 10px; }
    .type-badge, .badge-access { font-size: 8px; padding: 2px 4px; }
    
    /* Body Card */
    .gcard-body { padding: 4px 8px 8px 8px; }
    .gcard-avatar { width: 48px; height: 48px; border-width: 2px; }
    .gcard-name { font-size: 12px !important; margin-bottom: 4px; height: 2.6em; }
    .gcard-info-row { margin-bottom: 4px; }
    .badge-row { height: auto !important; min-height: 18px; gap: 3px; margin-bottom: 6px; }
    .meta-badge { font-size: 9px; padding: 1px 5px; }
    .member-count { font-size: 10px; }
    
    /* Footer Card */
    .gcard-footer { padding: 8px; }
    .btn-join-block { padding: 6px 0; font-size: 11px; height: 28px; margin-bottom: 0; }
    .gcard-bottom-actions { display: none; }

    /* [FIX] Compact Tabs */
    .tab-nav-container { gap: 8px !important; }
    .tab-btn { flex: 1; width: auto !important; padding: 8px 4px !important; font-size: 13px !important; justify-content: center; }
    .tab-count { font-size: 10px !important; padding: 2px 5px !important; }

    /* [FIX] Live Feed Mobile */
    .live-feed-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }
    .d-card { padding: 8px 2px !important; min-height: 90px; justify-content: flex-start; }
    .d-card-avatar { width: 36px !important; height: 36px !important; margin-bottom: 5px !important; }
    .d-card-name { font-size: 10px !important; line-height: 1.2 !important; height: 2.4em !important; margin-bottom: 4px !important; padding: 0 2px; }
    .d-card-mini-foot { margin-top: auto; font-size: 8px !important; }

    /* [FIX] Compact Tags */
    .chip-container { gap: 6px !important; justify-content: center; }
    .chip { font-size: 11px !important; padding: 4px 10px !important; height: 26px; }
}

/* =========================================================
   [NEW] STATUS BAR STYLING (ACTIVE FILTERS)
   ========================================================= */

/* A. Giao diện mặc định (Mobile) */
.filter-status-bar {
    margin-top: 15px;
    padding: 10px 15px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    font-size: 11px;
    color: #64748b;
    display: none; /* JS sẽ bật class 'active' lên */
    animation: fadeIn 0.3s ease-out;
}
.filter-status-bar.active { display: block; }

.status-icon { margin-right: 6px; }
.status-highlight {
    font-weight: 700;
    color: var(--primary);
    background: rgba(36, 161, 222, 0.1); /* Màu nền nhẹ theo màu chủ đạo */
    padding: 2px 8px;
    border-radius: 4px;
    margin: 0 2px;
}

/* B. Giao diện PC (To, Giữa, Nổi bật) */
@media (min-width: 992px) {
    .filter-status-bar {
        text-align: center;       /* Căn giữa nội dung */
        font-size: 14px;          /* Chữ to hơn hẳn */
        font-weight: 500;        
        margin-top: 25px;
        margin-bottom: 10px;
        padding: 10px 20px;
        background: #ffffff;
        border: 2px solid #e2e8f0;
        box-shadow: 0 4px 20px rgba(0,0,0,0.04);
        border-radius: 50px;
        max-width: 800px;
        margin-left: auto;
        margin-right: auto;
    }
    
    .filter-status-bar .status-highlight {
        font-size: 16px; /* Highlight cũng to lên */
        padding: 4px 12px;
    }
}

/* Hiệu ứng xuất hiện */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   TAG PAGE - DENSE GRID SYSTEM (Hybrid Layout)
   ========================================= */

/* Grid mặc định cho Mobile (3 cột) */
.dense-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); 
    gap: 10px;
}

/* Tablet: 4 cột */
@media (min-width: 600px) {
    .dense-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Laptop nhỏ: 6 cột */
@media (min-width: 992px) {
    .dense-grid { grid-template-columns: repeat(6, 1fr); }
}

/* PC lớn: 8 cột */
@media (min-width: 1400px) {
    .dense-grid { grid-template-columns: repeat(8, 1fr); }
}

/* Style cho Card Dọc (Vertical Mini Card) */
.dense-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: #1e293b;
    padding: 12px 8px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%; /* Để các thẻ bằng nhau */
}

.dense-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: var(--primary); /* Đảm bảo biến --primary đã khai báo trong CSS gốc */
}

.dense-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 8px;
    border: 2px solid #f8fafc;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.dense-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Cắt dòng nếu tên quá dài */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dense-meta {
    margin-top: auto; /* Đẩy xuống đáy */
    font-size: 11px;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}
/* [VER 27] DETAIL PAGE ACTION BUTTONS */
.btn-act-round {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: 50px;
    border: none; font-weight: 700; font-size: 14px;
    cursor: pointer; transition: all 0.2s;
    background: #f1f5f9; color: #64748b;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.btn-act-round:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.btn-act-round .icon { font-size: 16px; }

/* Like Button Active State */
.btn-like.liked {
    background: #ffe4e6; color: #e11d48;
}
.btn-like:hover { background: #ffe4e6; color: #e11d48; }

/* Report Button Hover */
.btn-report:hover { background: #fef2f2; color: #ef4444; }

/* =========================================================
   [2a] VER 2: NEW STYLES FOR VIP, TRENDING & TAGS
   ========================================================= */

/* --- 1. VIP SECTION (Spotlight Design) --- */
.section-vip-wrapper {
    background: transparent;
    margin-bottom: 20px;
}
.vip-header {
    display: flex; align-items: center; gap: 10px; margin-bottom: 15px;
}
.vip-heading {
    font-size: 16px; font-weight: 800; color: #db2777; /* Pink/Rose for VIP */
    margin: 0; letter-spacing: 0.5px;
}
.vip-badge-label {
    background: #db2777; color: white; font-size: 10px; font-weight: 700;
    padding: 2px 6px; border-radius: 4px; text-transform: uppercase;
}

.vip-grid-modern {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Mobile: 2 cột */
    gap: 12px;
}
@media (min-width: 768px) {
    .vip-grid-modern { grid-template-columns: repeat(4, 1fr); }
}

.vip-card-modern {
    background: var(--card-bg);
    border: 1px solid #fbcfe8; /* Light pink border */
    border-radius: 16px;
    padding: 12px;
    display: flex; flex-direction: column;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    box-shadow: 0 4px 10px rgba(219, 39, 119, 0.05);
}
.vip-card-modern:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(219, 39, 119, 0.15);
    border-color: #db2777;
}

.vip-card-body {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    margin-bottom: 10px; flex: 1;
}

.vip-avatar-box {
    position: relative; width: 70px; height: 70px; margin-bottom: 10px;
}
.vip-img-modern {
    width: 100%; height: 100%; object-fit: cover;
    border-radius: 18px; /* Squircle shape */
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.vip-type-tag {
    position: absolute; bottom: -5px; right: -5px;
    background: #0f172a; color: #fff;
    font-size: 8px; font-weight: 700; padding: 2px 5px; border-radius: 4px;
    z-index: 2; border: 1px solid #fff;
}

.vip-name-modern {
    font-size: 13px; font-weight: 700; color: var(--text-main);
    line-height: 1.4; margin: 0 0 4px 0;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    height: 2.8em;
}
.vip-meta { font-size: 11px; color: #db2777; font-weight: 600; }

.vip-action { margin-top: auto; }
.vip-btn {
    display: block; width: 100%; text-align: center;
    background: linear-gradient(90deg, #ec4899, #db2777);
    color: white; font-size: 11px; font-weight: 700;
    padding: 8px 0; border-radius: 8px;
    transition: opacity 0.2s;
}
.vip-card-modern:hover .vip-btn { opacity: 0.9; }

/* =========================================================
   [FIX FINAL] TRENDING GRID & CARDS (PC 4 - MOBILE 2)
   ========================================================= */

/* 1. GRID CONTAINER */
.trending-grid-modern {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(4, 1fr); /* PC mặc định 4 cột */
}

/* 2. RESPONSIVE MOBILE */
@media (max-width: 991px) {
    .trending-grid-modern {
        grid-template-columns: repeat(2, 1fr) !important; /* Mobile ép cứng 2 cột */
        gap: 10px;
    }
}

/* 3. CARD ITEM STYLE */
.trend-card-modern {
    display: flex; align-items: center; gap: 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px; padding: 10px;
    text-decoration: none; transition: 0.2s;
    position: relative; overflow: hidden; /* Chống lòi nội dung */
}
.trend-card-modern:hover {
    background: var(--bg-body); border-color: var(--primary);
    transform: translateY(-2px);
}

/* 4. RANK NUMBER (#1, #2...) */
.trend-rank {
    font-size: 16px; font-weight: 900;
    width: 28px; text-align: center; flex-shrink: 0;
    color: var(--text-muted); opacity: 0.6; font-style: italic;
}
.trend-rank.rank-1 { color: #e11d48; opacity: 1; font-size: 20px; }
.trend-rank.rank-2 { color: #ea580c; opacity: 1; font-size: 18px; }
.trend-rank.rank-3 { color: #d97706; opacity: 1; font-size: 17px; }

/* 5. AVATAR & INFO */
.trend-avatar { flex-shrink: 0; }
.trend-avatar img {
    width: 44px; height: 44px; border-radius: 50%;
    object-fit: cover; border: 2px solid var(--bg-body);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.trend-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.trend-name {
    font-size: 13px; font-weight: 700; color: var(--text-main);
    margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    line-height: 1.4;
}
.trend-stats { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.trend-badge {
    font-size: 9px; padding: 2px 5px; border-radius: 4px; font-weight: 700; text-transform: uppercase;
}
.trend-badge.channel { background: #fff7ed; color: #c2410c; }
.trend-badge.group { background: #eff6ff; color: #1d4ed8; }
.trend-count { color: var(--text-muted); font-weight: 500; }
.chip-container-modern {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.chip-modern {
    display: inline-flex; align-items: center; 
    padding: 6px 14px; border-radius: 20px;
    font-size: 13px; font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
}
/* Hiệu ứng hover làm tag nổi lên */
.chip-modern:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    filter: brightness(0.95); /* Hơi tối lại chút khi hover để rõ hơn */
}

.btn-browse-tags {
    background: #3b82f6; color: white; border: none; 
    padding: 10px 20px; border-radius: 8px; font-weight: bold; 
    cursor: pointer; display: inline-flex; align-items: center; gap: 8px; 
    font-size: 14px; box-shadow: 0 4px 10px rgba(59,130,246,0.3); 
    transition: all 0.2s;
}
.btn-browse-tags:hover { background: #2563eb; transform: translateY(-2px); }

body.dark-mode .vip-badge-label { background: #be185d; }
body.dark-mode .vip-card-modern { border-color: #831843; background: #1e293b; }
body.dark-mode .vip-name-modern { color: #fce7f3; }
body.dark-mode .trend-card-modern:hover { background: #334155; }

/* =========================================================
   [NEW] BENTO GRID ADS (Tương thích Dark/Light Mode)
   ========================================================= */
.bento-wrapper {
    display: grid;
    grid-template-columns: 2fr 3fr; /* Tỷ lệ 40% - 60% */
    gap: 15px;
    margin-bottom: 25px; /* Tạo khoảng cách với phần dưới */
}

/* CỘT TRÁI (VIP) */
.bento-big {
    background: radial-gradient(circle at top right, #1e293b, #0f172a); /* Giữ màu tối sang trọng cho VIP */
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 30px 20px;
    display: flex; flex-direction: column; align-items: center; text-align: center;
    position: relative; overflow: hidden; height: 100%;
    text-decoration: none; /* Bỏ gạch chân link */
}
/* Hiệu ứng viền sáng VIP */
.bento-big::before {
    content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px;
    background: linear-gradient(90deg, #f43f5e, #f59e0b);
}

/* CỘT PHẢI (STACK) */
.bento-stack {
    display: flex; flex-direction: column; gap: 15px; height: 100%;
}

/* ITEM CON BÊN PHẢI */
.bento-small {
    flex: 1;
    background: var(--card-bg); /* Tự động theo giao diện sáng/tối */
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 15px 20px;
    display: flex; align-items: center; gap: 20px;
    transition: transform 0.2s, border-color 0.2s;
    text-decoration: none; position: relative;
}
.bento-small:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
}

/* ELEMENTS */
.b-tag {
    font-size: 9px; font-weight: 800; text-transform: uppercase;
    padding: 3px 8px; border-radius: 4px; letter-spacing: 0.5px;
}
.tag-vip { background: #f59e0b; color: #000; }
.tag-ad { 
    background: var(--bg-body); 
    color: var(--text-muted); 
    border: 1px solid var(--card-border); 
}

/* Typography bên trong Bento */
.bento-big .b-title { color: #fff; font-weight: 700; font-size: 18px; margin: 0; line-height: 1.3; }
.bento-big .b-desc { color: #94a3b8; font-size: 13px; margin: 10px 0 20px 0; }

.bento-small .b-title { color: var(--text-main); font-weight: 700; font-size: 15px; margin: 0; }
.bento-small .b-desc { 
    color: var(--text-muted); font-size: 12px; margin: 5px 0 0 0; 
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; 
}

/* Button VIP */
.btn-action-vip {
    margin-top: auto;
    padding: 10px 30px;
    border-radius: 50px;
    font-size: 13px; font-weight: 700;
    cursor: pointer; border: none;
    background: linear-gradient(90deg, #f59e0b, #d97706); 
    color: white; 
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
    transition: transform 0.2s;
}
.btn-action-vip:hover { transform: scale(1.05); }

/* =========================================================
   [FIX FINAL] MOBILE TRENDING - NO OVERFLOW
   ========================================================= */
@media (max-width: 991px) {
    /* 1. Xử lý Grid: Dùng minmax(0, 1fr) để ÉP KHÔNG TRÀN ra ngoài */
    .trending-grid-modern {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important; /* Quan trọng: minmax(0, 1fr) chống vỡ layout */
        gap: 10px;
        row-gap: 35px; /* Tăng khoảng cách dòng để đầu Avatar không đè lên thẻ trên */
        margin-top: 25px; /* Khoảng cách so với tiêu đề */
        padding: 0 5px; /* Đệm an toàn 2 bên */
    }

    /* 2. Thẻ Card: Gọn gàng, Avatar lửng */
    .trend-card-modern {
        display: flex;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center;
        background: var(--card-bg);
        border: 1px solid var(--card-border);
        border-radius: 16px;
        
        /* Padding trên cao để né Avatar, dưới thấp để gọn */
        padding: 28px 6px 10px 6px; 
        
        height: auto;
        position: relative; /* Mốc tọa độ */
        overflow: visible !important; /* Bắt buộc để Avatar lòi ra ngoài */
        box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    }

    /* 3. Avatar Lửng (Floating) - Tiết kiệm không gian */
    .trend-avatar {
        position: absolute;
        top: -24px; /* Kéo lên 1 nửa chiều cao avatar (48px / 2) */
        left: 50%;
        transform: translateX(-50%);
        margin: 0 !important;
        z-index: 5;
    }

    .trend-avatar img {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        object-fit: cover;
        /* Viền trùng màu nền body để tạo cảm giác cắt lõm */
        border: 4px solid var(--bg-body); 
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        background: var(--card-bg);
    }

    /* 4. Rank (#1, #2) - Treo góc trái tinh tế */
    .trend-rank {
        position: absolute;
        top: -8px; /* Treo hẳn lên mép trên */
        left: -4px;
        width: auto !important;
        font-size: 12px !important;
        font-weight: 800;
        padding: 2px 6px;
        background: #fff;
        color: #fff;
        border: 1px solid var(--card-border);
        border-radius: 6px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        z-index: 6;
    }
    /* Màu rank darkmode */
    body.dark-mode .trend-rank {
        background: #334155;
        border-color: #475569;
    }

    /* 5. Tên & Info - Chống tràn text */
    .trend-info {
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
    }

    .trend-name {
        font-size: 12px;
        font-weight: 700;
        line-height: 1.3;
        margin: 0;
        width: 100%;
        height: 2.6em; /* Giới hạn 2 dòng */
        
        /* Cắt chữ thông minh */
        white-space: normal !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        word-break: break-word; /* Chống từ quá dài làm banh khung */
    }

    .trend-stats {
        margin-top: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        width: 100%;
    }
    
    .trend-badge { font-size: 9px; padding: 2px 6px; }
    .trend-count { font-size: 10px; }
}
/* =========================================================
   [FIX] MOBILE DETAIL RELATED GRID (3 CỘT)
   ========================================================= */
@media (max-width: 991px) {
    .detail-related-grid {
        /* Ép về 3 cột trên Mobile/Tablet dọc */
        grid-template-columns: repeat(3, 1fr) !important; 
        
        /* Giảm khoảng cách giữa các ô để 3 cột không bị quá chật */
        gap: 6px !important; 
    }
}

/* CSS CHO CARD ĐÃ CHẾT */
.gcard.status-dead {
    opacity: 0.75;
    filter: grayscale(100%); /* Làm đen trắng */
    transition: 0.3s;
}
.gcard.status-dead:hover {
    opacity: 1;
    filter: grayscale(0%); /* Hover vào thì hiện màu lại */
}
/* Badge cảnh báo trên Card */
.gcard.status-dead .gcard-header::after {
    content: "CLOSED"; /* Hoặc dùng PHP echo __('lbl_closed') */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg);
    font-weight: 900;
    color: #ef4444;
    border: 2px solid #ef4444;
    padding: 5px 10px;
    border-radius: 6px;
    opacity: 0.8;
    font-size: 12px;
    pointer-events: none;
}
/* Style cho nhóm đã đóng */
.gcard.status-dead {
    opacity: 0.7;
    filter: grayscale(100%);
    transition: 0.3s;
}
.gcard.status-dead:hover {
    opacity: 1;
    filter: grayscale(0%);
}
/* Style cho nhóm chờ duyệt */
.gcard.status-pending {
    border: 1px dashed #3b82f6;
    background: #eff6ff;
}

/* =========================================================
   [NEW] ORIGINAL SOURCE BOX (Dark/Light Compatible)
   ========================================================= */
.origin-box {
    margin-top: 25px;
    padding: 16px 20px;
    background: var(--bg-body); /* Tự động theo giao diện (Sáng/Tối) */
    border: 1px solid var(--card-border);
    border-left: 4px solid var(--primary); /* Viền trái màu xanh chủ đạo */
    border-radius: 12px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    transition: all 0.3s ease;
}

.origin-box:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border-color: var(--primary);
}

.origin-flag {
    width: 32px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-top: 3px;
    flex-shrink: 0;
}

.origin-content {
    flex: 1;
    text-align: left;
}

.origin-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
    line-height: 1.4;
}

.origin-hl {
    color: var(--primary); /* Màu highlight tên gốc */
}

.origin-note {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Tinh chỉnh riêng cho Dark Mode để nổi bật hơn */
body.dark-mode .origin-box {
    background: rgba(30, 41, 59, 0.5); /* Nền tối mờ */
    border-color: #334155;
}

/* =========================================================
   [NEW] GROUP DETAIL IMPROVEMENTS (TIMELINE & ALERTS)
   ========================================================= */

/* 1. KHỐI THỐNG KÊ (MEMBERS, VIEWS, FLAG) - CĂN GIỮA */
.detail-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 25px;
    color: var(--text-muted);
    font-size: 15px;
}

.detail-stats span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-body);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--card-border);
}

/* 2. TIMELINE (LISTED | UPDATED | CHECKED) */
.meta-timeline-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--card-border);
}

.mt-item {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-body);
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.mt-check {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
    font-weight: 600;
}

/* 3. KHỐI CẢNH BÁO NGUỒN GỐC (SOURCE ALERT BOX) */
.source-alert-box {
    margin: 20px auto 25px auto;
    max-width: 600px;
    background: #fff7ed;
    border: 1px dashed #f97316;
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    text-align: left;
    box-shadow: 0 4px 6px -1px rgba(249, 115, 22, 0.1);
}

.sa-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.sa-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sa-title {
    font-size: 13px;
    font-weight: 600;
    color: #9a3412;
    line-height: 1.4;
}

.sa-highlight {
    color: #ea580c;
    font-weight: 700;
    word-break: break-word;
}

.sa-note {
    font-size: 12px;
    color: #7c2d12;
    opacity: 0.9;
}

/* 4. HỖ TRỢ DARK MODE CHO CÁC KHỐI MỚI */
body.dark-mode .detail-stats span {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .mt-item {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .mt-check {
    background: rgba(21, 128, 61, 0.2);
    border-color: rgba(21, 128, 61, 0.3);
    color: #86efac;
}

body.dark-mode .source-alert-box {
    background: rgba(67, 20, 7, 0.4);
    border-color: #ea580c;
}

body.dark-mode .sa-title {
    color: #ffedd5;
}

body.dark-mode .sa-note {
    color: #fed7aa;
}

/* 5. RESPONSIVE MOBILE CHO KHỐI MỚI */
@media (max-width: 480px) {
    .source-alert-box {
        flex-direction: row;
        font-size: 12px;
        padding: 10px;
    }
    .sa-icon {
        font-size: 20px;
    }
}

/* =========================================================
   [FIX FINAL] BADGE 2 DÒNG (STACK LAYOUT) - PC & MOBILE
   ========================================================= */

/* 1. Container: Xếp dọc (Column) để mỗi badge 1 hàng */
.gcard .gcard-body .gcard-stats-row {
    display: flex !important;
    flex-direction: column !important; /* QUAN TRỌNG: Xếp chồng dọc */
    justify-content: center !important;
    align-items: center !important;
    gap: 6px !important; /* Khoảng cách giữa 2 hàng badge */
    margin-top: 10px !important;
    width: 100% !important;
}

/* 2. Style chung cho Badge - Nằm gọn trong viền (không dính lề) */
.gcard .gcard-body .gcard-stats-row .meta-badge {
    display: flex !important;
    justify-content: center !important; /* Căn chữ giữa badge */
    align-items: center !important;
    
    /* Kích thước & Căn lề */
    width: 94% !important;      /* Chỉ chiếm 94% để hở 2 bên viền (Nằm trong viền) */
    margin: 0 auto !important;  /* Tự động căn giữa */
    height: 28px !important;    /* Chiều cao cố định cho đều */
    
    /* Font & Border */
    font-size: 11px !important;
    font-weight: 700 !important; 
    border-radius: 6px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}

/* 3. Badge MEMBERS (Xám) */
.gcard .gcard-body .gcard-stats-row .badge-member {
    background-color: #f1f5f9 !important;
    color: #0f172a !important; 
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* 4. Badge VERIFIED (Xanh lá) & UPDATED (Xanh dương) */
.gcard .gcard-body .gcard-stats-row .badge-verified {
    background-color: #dcfce7 !important;
    color: #15803d !important;
    border: 1px solid #86efac !important;
}

.gcard .gcard-body .gcard-stats-row .badge-updated {
    background-color: #e0f2fe !important;
    color: #0369a1 !important;
    border: 1px solid #7dd3fc !important;
}

/* 5. DARK MODE */
body.dark-mode .gcard .gcard-body .gcard-stats-row .badge-member {
    background-color: #334155 !important; 
    color: #ffffff !important; 
    border: 1px solid #475569 !important;
}

body.dark-mode .gcard .gcard-body .gcard-stats-row .badge-verified {
    background-color: rgba(22, 163, 74, 0.2) !important;
    color: #86efac !important;
    border-color: rgba(22, 163, 74, 0.5) !important;
}
body.dark-mode .gcard .gcard-body .gcard-stats-row .badge-updated {
    background-color: rgba(2, 132, 199, 0.2) !important;
    color: #7dd3fc !important;
    border-color: rgba(2, 132, 199, 0.5) !important;
}

/* =========================================================
   [MOBILE FIX] TINH CHỈNH RIÊNG CHO ĐIỆN THOẠI
   ========================================================= */
@media (max-width: 480px) {
    /* Trên Mobile vẫn giữ 2 dòng nhưng chỉnh lại size cho vừa mắt */
    .gcard .gcard-body .gcard-stats-row {
        gap: 4px !important; /* Giảm khoảng cách giữa 2 dòng */
        margin-top: 8px !important;
    }

    .gcard .gcard-body .gcard-stats-row .meta-badge {
        font-size: 10px !important; /* Chữ nhỏ lại xíu */
        height: 24px !important;    /* Thấp hơn xíu cho đỡ tốn diện tích dọc */
        width: 96% !important;      /* Mobile cho rộng ra xíu nữa */
    }
    
    /* Icon trong badge nhỏ lại */
    .gcard .gcard-body .gcard-stats-row .meta-badge img,
    .gcard .gcard-body .gcard-stats-row .meta-badge svg {
        width: 10px !important;
        height: 10px !important;
    }
}
/* =========================================================
   [NEW] TRENDING CARD MODERN (DASHBOARD STYLE) - FINAL VERSION
   ========================================================= */

/* --- 1. BASE STYLES (Dùng chung cho cả Mobile & PC) --- */
.trend-card-modern {
    /* Màu nền và viền */
    background: #1e293b; 
    border: 1px solid #334155;
    /* Hiệu ứng */
    text-decoration: none;
    transition: transform 0.2s, border-color 0.2s;
    box-sizing: border-box;
}

.trend-card-modern:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

/* Avatar Image Base */
.trend-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* Rank Badge Base (#1, #2...) */
.trend-rank {
    position: absolute;
    font-weight: 900;
    background: #334155;
    color: #cbd5e1;
    border: 1px solid #475569;
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    z-index: 10;
}
.trend-rank.rank-1 { background: #fff1f2; color: #e11d48; border-color: #fecdd3; }
.trend-rank.rank-2 { background: #fff7ed; color: #ea580c; border-color: #fed7aa; }
.trend-rank.rank-3 { background: #fffbeb; color: #d97706; border-color: #fde68a; }

/* Tên Group Base */
.trend-name {
    font-weight: 700;
    color: #fff;
    text-align: center;
    line-height: 1.3;
    white-space: normal;
    word-wrap: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    flex-shrink: 0; /* Không co giãn */
}

/* Badge con (Type, Mem, Time) Base */
.t-badge {
    display: block;
    width: 100%;
    text-align: center;
    border-radius: 6px;
    white-space: nowrap;
}
.t-type {
    font-weight: 800;
    text-transform: uppercase;
    background: #0f172a;
    color: #94a3b8;
    border: 1px solid #334155;
    width: fit-content;
    margin: 0 auto;
}
.t-type.channel { color: #fdba74; border-color: #fb923c; }
.t-type.group { color: #7dd3fc; border-color: #38bdf8; }
.t-mem {
    font-weight: 800;
    color: #fff;
    background: rgba(255,255,255,0.05);
    border: 1px dashed #475569;
}
.t-time {
    color: #4ade80;
    font-weight: 600;
}


/* --- 2. MOBILE STYLES (Màn hình < 992px) --- */
@media (max-width: 991px) {
    .trending-grid-modern {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important; /* 2 cột đều nhau */
        gap: 10px !important;
        row-gap: 40px !important; /* Gap dọc lớn cho avatar */
        padding-top: 25px !important;
        padding-bottom: 10px !important;
    }

    .trend-card-modern {
        display: flex !important;
        flex-direction: column !important;
        overflow: visible !important; /* Cho phép avatar bay ra ngoài */
        position: relative !important;
        z-index: 1;
        border-radius: 12px !important;
        margin-top: 0 !important;
        padding: 25px 3px 10px 3px !important; /* Padding gọn cho mobile */
        width: 100% !important;
        height: 100% !important;
    }

    .trend-avatar {
        position: absolute;
        width: 42px !important;
        height: 42px !important;
        top: -21px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        background: #1e293b !important;
        border: 1px solid #334155 !important;
        padding: 3px !important;
        border-radius: 50% !important;
        z-index: 2;
        box-shadow: 0 -3px 6px rgba(0,0,0,0.2) !important;
    }

    .trend-rank {
        top: -8px !important;
        left: -4px !important;
        width: 22px !important;
        height: 22px !important;
        font-size: 10px !important;
        box-shadow: 2px 2px 4px rgba(0,0,0,0.3) !important;
    }

    .trend-name {
        font-size: 11px !important;
        margin-top: 5px !important;
        margin-bottom: 4px !important;
        height: 2.6em !important;
    }

    /* Auto Balance Mobile */
    .trend-stats-stack {
        display: flex !important;
        flex-direction: column !important;
        flex-grow: 1 !important;        /* Tự lấp đầy */
        justify-content: center !important; /* Căn giữa */
        gap: 4px !important;
        width: 100% !important;
        margin-top: 0 !important;
    }

    /* Font size Mobile */
    .t-type { font-size: 8px !important; padding: 1px 6px !important; }
    .t-mem { font-size: 11px !important; padding: 2px 0 !important; }
    .t-time { font-size: 9px !important; }
}


/* --- 3. PC STYLES (Màn hình >= 992px) --- */
@media (min-width: 992px) {
    .trending-grid-modern {
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr)) !important; /* 6 cột cứng */
        gap: 12px !important;
        row-gap: 50px !important;
        padding-top: 35px !important;
        padding-bottom: 15px !important;
    }

    .trend-card-modern {
        display: flex !important;
        flex-direction: column !important;
        overflow: visible !important;
        position: relative !important;
        z-index: 1;
        border-radius: 12px !important;
        margin-top: 0 !important;
        padding: 28px 4px 12px 4px !important;
        width: 100% !important;
        height: 100% !important;
    }

    .trend-avatar {
        position: absolute;
        width: 48px !important;
        height: 48px !important;
        top: -24px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        background: #1e293b !important;
        border: 1px solid #334155 !important;
        padding: 3px !important;
        border-radius: 50% !important;
        z-index: 2;
        box-shadow: 0 -3px 8px rgba(0,0,0,0.3) !important;
    }

    .trend-rank {
        top: -12px !important;
        left: -6px !important;
        width: 24px !important;
        height: 24px !important;
        font-size: 11px !important;
        box-shadow: 2px 2px 5px rgba(0,0,0,0.3) !important;
    }

    .trend-name {
        font-size: 11px !important;
        margin-top: 4px !important;
        margin-bottom: 4px !important;
        height: 2.6em !important;
    }

    /* Auto Balance PC */
    .trend-stats-stack {
        display: flex !important;
        flex-direction: column !important;
        flex-grow: 1 !important;        /* Tự lấp đầy */
        justify-content: center !important; /* Căn giữa */
        gap: 6px !important;
        width: 100% !important;
        margin-top: 0 !important;
    }

    /* Font size PC */
    .t-type { font-size: 8px !important; padding: 2px 8px !important; }
    .t-mem { font-size: 11px !important; padding: 2px 0 !important; }
    .t-time { font-size: 9px !important; }
}
/* =========================================
   STATS CRITERIA PANEL (Popup Why?)
   ========================================= */
#statsCriteriaBtn {
    cursor: pointer;
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.4);
    margin-left: 5px;
    user-select: none;
    white-space: nowrap;
    transition: all 0.2s ease;
}

#statsCriteriaBtn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: #38bdf8;
}

#statsCriteriaPanel {
    display: none; /* JS sẽ bật cái này */
    position: absolute;
    z-index: 9999;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 12px;
    background: #1e293b;
    border: 1px solid #475569;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    width: 280px;
    max-width: 90vw; /* Chống tràn trên mobile */
    text-align: left;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Mũi tên chỉ lên */
.stats-arrow {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
}
.stats-arrow.outer {
    top: -6px;
    border-bottom: 6px solid #475569;
}
.stats-arrow.inner {
    top: -5px;
    border-bottom: 6px solid #1e293b;
}

/* Nội dung bên trong */
.stats-header {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    color: #fff;
    border-bottom: 1px solid #334155;
    padding-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats-close-mobile {
    cursor: pointer; 
    opacity: 0.6; 
    font-size: 16px;
}

.stats-list {
    margin: 0;
    padding-left: 20px;
    color: #e2e8f0;
    font-size: 0.8rem;
    list-style-type: disc;
    line-height: 1.5;
}

.stats-list li {
    margin-bottom: 4px;
}

.stats-footer {
    margin-top: 10px;
    font-size: 0.7rem;
    color: #94a3b8;
    font-style: italic;
    border-top: 1px dashed #334155;
    padding-top: 8px;
}
