/* ── CSS VARIABLES ── */
:root {
    --bg:       #0f172a;
    --bg-2:     #1e293b;
    --bg-3:     #0f172a;
    --border:   #1e293b;
    --border-2: #334155;
    --border-3: #475569;
    --text:     #e2e8f0;
    --text-title:#f1f5f9;
    --text-2:   #94a3b8;
    --text-3:   #64748b;
    --text-4:   #475569;
    --accent:   #14b8a6;
    --accent-h: #0d9488;
    --link:     #38bdf8;
    --header-bg: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f4c3a 100%);
    --profile-header-bg: linear-gradient(135deg, #0f3a33, #0f2a4a);
    --header-h1: #f0fdfa;
    --header-sub: #94a3b8;
    --header-stat-lbl: #64748b;
}
body.light {
    --bg:       #f1f5f9;
    --bg-2:     #ffffff;
    --bg-3:     #e2e8f0;
    --border:   #e2e8f0;
    --border-2: #cbd5e1;
    --border-3: #94a3b8;
    --text:     #334155;
    --text-title:#0f172a;
    --text-2:   #475569;
    --text-3:   #64748b;
    --text-4:   #94a3b8;
    --accent:   #0d9488;
    --accent-h: #0f766e;
    --link:     #0284c7;
    --header-bg: linear-gradient(135deg, #0284c7 0%, #0d9488 60%, #059669 100%);
    --profile-header-bg: linear-gradient(135deg, #0d9488, #0284c7);
    --header-h1: #ffffff;
    --header-sub: rgba(255,255,255,0.75);
    --header-stat-lbl: rgba(255,255,255,0.6);
}

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

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
* { scrollbar-width: thin; scrollbar-color: var(--border-2) var(--bg); }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

/* ── HEADER ── */
header {
    background: var(--header-bg);
    padding: 70px 20px 60px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 60% 40%, #14b8a620 0%, transparent 70%);
    pointer-events: none;
}
.site-badge {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 5px 16px;
    border-radius: 20px;
    margin-bottom: 20px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.85);
}
header h1 {
    font-size: 3rem;
    font-weight: 800;
    color: var(--header-h1);
    letter-spacing: -1px;
}
header h1 span { color: var(--accent); }
body.light header h1 span { color: #fff; text-shadow: 0 0 20px rgba(255,255,255,0.4); }
header p.subtitle {
    margin-top: 14px;
    font-size: 1.1rem;
    color: var(--header-sub);
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}
.header-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-top: 36px;
}
.stat { text-align: center; }
.stat-num { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
body.light .stat-num { color: #fff; }
.stat-lbl { font-size: 0.78rem; color: var(--header-stat-lbl); margin-top: 2px; }

/* ── CONTAINER ── */
.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ── SECTION ── */
section { padding: 56px 0; }
.section-header {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 32px;
}
.section-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-title);
}
.section-header span {
    font-size: 0.82rem;
    color: var(--text-4);
}
.divider {
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ── TOPIC CARDS ── */
.topics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
.topic-card {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: 14px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: border-color 0.2s, transform 0.2s;
    position: relative;
    overflow: hidden;
}
.topic-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent, #334155);
    border-radius: 14px 14px 0 0;
}
.topic-card:hover {
    border-color: var(--accent, #475569);
    transform: translateY(-3px);
}
.topic-card.coming-soon {
    opacity: 0.55;
    pointer-events: none;
}
.card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}
.card-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    background: var(--icon-bg, #1e3a5f);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.card-status {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}
.status-active {
    background: #14b8a615;
    color: #14b8a6;
    border: 1px solid #14b8a630;
}
.status-soon {
    background: var(--bg-2);
    color: var(--text-4);
    border: 1px solid var(--border-2);
}
.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-title);
}
.card-desc {
    font-size: 0.88rem;
    color: var(--text-3);
    flex: 1;
    line-height: 1.6;
}
.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.tag {
    font-size: 0.72rem;
    background: var(--bg-3);
    color: var(--text-2);
    border: 1px solid var(--border-2);
    padding: 2px 9px;
    border-radius: 4px;
}
.card-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}
.card-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s;
}
.card-link.primary {
    background: var(--accent, #14b8a6);
    color: #0f172a;
    font-weight: 700;
}
.card-link.primary:hover { filter: brightness(1.1); }
.card-link.secondary {
    background: var(--bg-3);
    color: var(--text-2);
    border: 1px solid var(--border-2);
}
.card-link.secondary:hover { color: var(--text); border-color: var(--border-3); }
.card-link .link-icon { font-size: 1rem; }

/* ── CARD STATS — tag treo bên phải ── */
.card-stats {
    position: absolute;
    top: 78px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 14px 8px 12px;
    background: color-mix(in srgb, var(--accent, #14b8a6) 14%, #0f172a);
    border: 1px solid color-mix(in srgb, var(--accent, #14b8a6) 35%, transparent);
    border-right: none;
    border-radius: 8px 0 0 8px;
    text-align: center;
    z-index: 1;
    box-shadow: -3px 2px 10px rgba(0,0,0,0.25);
}
.card-stats::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 0;
    border-top: 7px solid color-mix(in srgb, var(--accent, #14b8a6) 50%, #000);
    border-left: 7px solid transparent;
}
.card-stat {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent, #14b8a6);
    line-height: 1.3;
}

/* ── PREREQ BADGE ── */
.card-requires {
    font-size: 0.78rem;
    color: var(--text-3);
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}
.card-requires a { color: #38bdf8; text-decoration: none; }
.card-requires a:hover { text-decoration: underline; }

/* ── RECENT DOCS LIST ── */
.docs-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.doc-row {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: 10px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: border-color 0.2s;
}
.doc-row:hover { border-color: var(--border-3); }
.doc-row-icon { font-size: 1.6rem; flex-shrink: 0; }
.doc-row-info { flex: 1; }
.doc-row-info h4 { font-size: 0.95rem; color: var(--text-title); margin-bottom: 3px; }
.doc-row-info p  { font-size: 0.8rem; color: var(--text-3); }
.doc-row-meta {
    font-size: 0.78rem;
    color: var(--text-4);
    text-align: right;
    flex-shrink: 0;
}
.doc-row-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-sm {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 0.8rem; font-weight: 600;
    padding: 6px 14px; border-radius: 6px;
    text-decoration: none; transition: all 0.15s;
}
.btn-sm.teal { background: var(--accent); color: #0f172a; }
.btn-sm.teal:hover { background: var(--accent-h); }
.btn-sm.ghost { background: transparent; color: var(--text-3); border: 1px solid var(--border-2); }
.btn-sm.ghost:hover { color: var(--text); border-color: var(--border-3); }

/* ── TOPBAR ── */
.topbar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar-brand {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-4);
    letter-spacing: 1px;
}
.topbar-brand span { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* ── THEME TOGGLE ── */
.theme-btn {
    width: 34px; height: 34px;
    border-radius: 8px;
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    color: var(--text-3);
}
.theme-btn:hover { border-color: var(--accent); color: var(--accent); }

.user-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0f766e, #1d4ed8);
    border: 2px solid var(--border-2);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    transition: border-color 0.2s, transform 0.15s;
    position: relative;
}
.user-btn:hover { border-color: var(--accent); transform: scale(1.08); }
.user-btn .online-dot {
    position: absolute;
    bottom: 1px; right: 1px;
    width: 9px; height: 9px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--bg);
}

/* ── PROFILE MODAL ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: #00000070;
    z-index: 999;
    backdrop-filter: blur(3px);
    padding: 56px 16px 16px;
    overflow-y: auto;
}
.modal-overlay.open { display: flex; align-items: center; justify-content: center; }
.profile-modal {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: 16px;
    width: 560px;
    max-width: calc(100% - 32px);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
    animation: popIn 0.2s ease;
}
.profile-modal::-webkit-scrollbar { width: 5px; }
.profile-modal::-webkit-scrollbar-track { background: transparent; }
.profile-modal::-webkit-scrollbar-thumb { background: #334155; border-radius: 99px; }
.profile-modal::-webkit-scrollbar-thumb:hover { background: #14b8a6; }
@keyframes popIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}
.profile-header {
    background: var(--profile-header-bg);
    padding: 24px;
    text-align: center;
    position: relative;
}
.profile-close {
    position: absolute;
    top: 12px; right: 14px;
    background: none; border: none;
    color: rgba(255,255,255,0.4); font-size: 1.2rem;
    cursor: pointer; line-height: 1;
    transition: color 0.15s;
}
.profile-close:hover { color: #fff; }
.avatar-wrap {
    position: relative;
    width: 80px;
    margin: 0 auto 12px;
    cursor: pointer;
}
.profile-avatar {
    width: 80px; height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0f766e, #1d4ed8);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem;
    border: 3px solid #14b8a650;
    transition: border-color 0.2s;
}
.avatar-wrap:hover .profile-avatar { border-color: #14b8a6; }
.avatar-zoom {
    position: absolute;
    bottom: 2px; right: 2px;
    width: 22px; height: 22px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.65rem;
    border: 2px solid var(--bg-2);
    opacity: 0;
    transition: opacity 0.2s;
}
.avatar-wrap:hover .avatar-zoom { opacity: 1; }

/* ── LIGHTBOX ── */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: #000000cc;
    z-index: 1100;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.8);
    animation: popIn 0.2s ease;
}
.profile-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #f1f5f9;
    margin-bottom: 4px;
}
.profile-title {
    font-size: 0.82rem;
    color: #14b8a6;
    font-weight: 600;
    margin-bottom: 8px;
}
.profile-bio {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.5);
    line-height: 1.5;
    margin-top: 6px;
    padding: 0 4px;
}
.profile-body { padding: 24px; }
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
}
.profile-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.profile-row.full { grid-column: 1 / -1; }
.profile-row:last-child { border-bottom: none; }
.profile-row-icon { font-size: 1rem; flex-shrink: 0; margin-top: 2px; }
.profile-row-label {
    font-size: 0.7rem;
    color: var(--text-4);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 3px;
}
.profile-row-value { color: var(--text); font-size: 0.88rem; }
.profile-row-value a { color: var(--link); text-decoration: none; }
.profile-row-value a:hover { text-decoration: underline; }
.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.skill-tag {
    font-size: 0.75rem;
    background: var(--bg-3);
    color: var(--text-2);
    border: 1px solid var(--border-2);
    padding: 3px 10px;
    border-radius: 4px;
}

/* ── FOOTER ── */
footer {
    border-top: 1px solid var(--border);
    padding: 28px 24px;
    text-align: center;
    color: var(--border-2);
    font-size: 0.82rem;
}
footer span { color: var(--text-4); }

/* ── CATEGORY GROUPS ── */
.cat-section { margin-bottom: 44px; }
.cat-section:last-child { margin-bottom: 0; }
.cat-label {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}
.cat-label-text {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    white-space: nowrap;
}
.cat-label-soon { color: var(--text-4); }
.cat-divider {
    flex: 1;
    height: 1px;
    background: var(--border);
}
.cat-label-desc {
    font-size: 0.78rem;
    color: var(--text-4);
    white-space: nowrap;
}

/* ── FILTER BAR ── */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.filter-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-2);
    background: var(--bg-2);
    color: var(--text-3);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.filter-tab:hover {
    border-color: var(--border-3);
    color: var(--text);
}
.filter-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #0f172a;
    font-weight: 700;
}
.filter-count {
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(0,0,0,0.15);
    padding: 1px 6px;
    border-radius: 10px;
    line-height: 1.4;
}
.filter-tab.active .filter-count {
    background: rgba(0,0,0,0.18);
}
.filter-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.filter-search-icon {
    position: absolute;
    left: 10px;
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0.5;
}
.filter-search {
    padding: 7px 32px 7px 32px;
    border-radius: 8px;
    border: 1px solid var(--border-2);
    background: var(--bg-2);
    color: var(--text);
    font-size: 0.85rem;
    width: 220px;
    transition: border-color 0.15s, width 0.2s;
    outline: none;
}
.filter-search::placeholder { color: var(--text-4); }
.filter-search:focus {
    border-color: var(--accent);
    width: 260px;
}
.filter-search-clear {
    position: absolute;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--border-2);
    border: none;
    color: var(--text-3);
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.15s;
}
.filter-search-clear:hover { background: var(--border-3); color: var(--text); }

/* ── NO RESULT ── */
.no-result {
    text-align: center;
    padding: 48px 0;
    color: var(--text-3);
    font-size: 0.95rem;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
    .topics-grid { grid-template-columns: repeat(2, 1fr); }
    header h1 { font-size: 2.2rem; }
}
@media (max-width: 700px) {
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-search-wrap { width: 100%; }
    .filter-search { width: 100%; }
    .filter-search:focus { width: 100%; }
}
@media (max-width: 560px) {
    .topics-grid { grid-template-columns: 1fr; }
    header h1 { font-size: 1.8rem; }
    .header-stats { gap: 20px; }
    .doc-row { flex-wrap: wrap; }
    .doc-row-meta { display: none; }
}
@media (max-width: 480px) {
    .profile-grid { grid-template-columns: 1fr; }
    .profile-row.full { grid-column: auto; }
}
