/* ============================================================
   DEBATE ACHIEVEMENTS VN — Design System
   Lấy chất liệu từ chính thế giới tranh biện:
   - "Flow": cách debater ghi chú lập luận theo cột trong 1 vòng đấu
   - "Tab": bảng tổng hợp/tabulation kết quả — nên số liệu dùng mono
   - Tín hiệu thời gian xanh/vàng/đỏ dùng cho các trạng thái duyệt
   ============================================================ */

:root {
    --ink: #1C2430;
    --ink-soft: #4A5163;
    --muted: #6B7080;
    --paper: #F3F3EE;
    --paper-lift: #FBFAF7;
    --rule: #DAD6C8;
    --rule-strong: #B9B4A2;

    --motion: #26418F;
    --motion-dark: #172C63;
    --motion-tint: #E9EDF7;

    --green: #2E7D4F;
    --green-bg: #E7F2EB;
    --red: #B7392F;
    --red-bg: #F8EAE8;
    --amber: #A66A1E;
    --amber-bg: #F5EEDE;

    --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
    --font-ui: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', 'SF Mono', Consolas, monospace;

    --radius: 5px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px 60px;
}

a { color: var(--motion); }

h1, h2, h3 { font-family: var(--font-display); color: var(--ink); margin: 0 0 6px; font-weight: 600; }
h2 { font-size: 22px; }
h3 { font-size: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-family: var(--font-ui); color: var(--ink-soft); }

/* ============ MASTHEAD / NAVBAR ============ */

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 22px 0 18px;
    border-bottom: 1.5px solid var(--ink);
    margin-bottom: 34px;
}

.navbar .brand {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 17px;
    letter-spacing: .01em;
    text-decoration: none;
    color: var(--ink);
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
}
.navbar .brand::after {
    content: 'VN';
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--paper-lift);
    background: var(--motion);
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: .03em;
}

.navbar .nav-links { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }

.navbar .nav-links a, .navbar .nav-links button {
    text-decoration: none;
    color: var(--ink-soft);
    font-weight: 500;
    font-size: 13.5px;
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-family: var(--font-ui);
    transition: all .15s;
    position: relative;
}
.navbar .nav-links a:hover, .navbar .nav-links button:hover { background: var(--motion-tint); color: var(--motion-dark); }
.navbar .nav-links a.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.navbar .nav-links a.primary:hover { background: var(--motion-dark); border-color: var(--motion-dark); color: white; }

.mail-link { position: relative; }
.mail-badge {
    position: absolute; top: 2px; right: 4px;
    background: var(--red); color: white;
    font-family: var(--font-mono); font-size: 10px; font-weight: 600;
    min-width: 15px; height: 15px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px; line-height: 1;
}

/* ============ BUTTONS ============ */

.btn-primary, .btn-secondary {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 13.5px;
    padding: 11px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    border: 1.5px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all .15s;
    width: 100%;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--motion-dark); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-secondary { background: transparent; color: var(--ink-soft); border-color: var(--rule-strong); }
.btn-secondary:hover { border-color: var(--ink); color: var(--ink); }

/* ============ FORMS ============ */

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--rule-strong);
    border-radius: var(--radius);
    font-size: 14.5px;
    font-family: var(--font-ui);
    background: var(--paper-lift);
    color: var(--ink);
}
.form-group textarea { resize: vertical; min-height: 90px; font-family: var(--font-ui); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--motion); box-shadow: 0 0 0 3px var(--motion-tint);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-box { background: var(--paper-lift); border: 1px solid var(--rule); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; }
.form-actions { display: flex; gap: 10px; }
.form-actions .btn-primary, .form-actions .btn-secondary { width: auto; }

.password-input { position: relative; }
.password-input input { padding-right: 44px; }
.password-input button { position: absolute; right: 4px; top: 4px; bottom: 4px; border: none; background: transparent; color: var(--muted); cursor: pointer; padding: 0 10px; }

.search-box { display: flex; gap: 10px; max-width: 480px; margin: 26px auto 0; }
.search-box input {
    flex: 1; padding: 13px 16px; border: 1.5px solid var(--rule-strong); border-radius: var(--radius);
    font-size: 14px; font-family: var(--font-mono); background: var(--paper-lift); color: var(--ink);
}
.search-box input:focus { outline: none; border-color: var(--motion); }
.search-box select { padding: 10px; border-radius: var(--radius); border: 1.5px solid var(--rule-strong); font-family: var(--font-ui); background: var(--paper-lift); }

/* ============ HERO ============ */

.hero {
    padding: 54px 0 40px;
    position: relative;
    overflow: hidden;
}
.hero-eyebrow {
    font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
    color: var(--motion); margin-bottom: 14px; font-weight: 500;
}
.hero h1 {
    font-size: 44px; line-height: 1.12; max-width: 620px; letter-spacing: -.01em;
}
.hero h1 em { font-style: italic; color: var(--motion); }
.hero p.lead { color: var(--ink-soft); font-size: 16px; max-width: 480px; margin-top: 16px; }

.hero-flow {
    position: absolute; top: -10px; right: -40px; width: 420px; height: 340px;
    opacity: .55; pointer-events: none;
}
@media (max-width: 900px) { .hero-flow { display: none; } }

/* ============ SECTION / ANNOUNCEMENTS ============ */

.section { margin-bottom: 40px; }
.section-head {
    display: flex; justify-content: space-between; align-items: baseline;
    border-bottom: 1px solid var(--rule); padding-bottom: 10px; margin-bottom: 18px;
}
.section-head h2 { margin: 0; }
.section-head .count { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

.announcement-card {
    border: 1px solid var(--rule); border-left: 3px solid var(--motion);
    background: var(--paper-lift); border-radius: 0 var(--radius) var(--radius) 0;
    padding: 16px 20px; margin-bottom: 12px;
}
.announcement-card .a-title { font-family: var(--font-ui); font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.announcement-card .a-body { color: var(--ink-soft); font-size: 14px; white-space: pre-wrap; }
.announcement-card .a-meta { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 8px; }
.announcement-card .a-actions { margin-top: 10px; }

/* ============ DIRECTORY (roster list) ============ */

.directory-grid {
    display: flex; flex-direction: column;
    border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; background: var(--paper-lift);
}
.profile-card {
    display: flex; align-items: center; gap: 16px; padding: 16px 20px;
    text-decoration: none; color: inherit;
    border-bottom: 1px solid var(--rule);
    transition: background .12s;
}
.directory-grid .profile-card:last-child { border-bottom: none; }
.profile-card:hover { background: var(--motion-tint); }
.profile-card .name { font-weight: 700; color: var(--ink); font-size: 15px; }
.profile-card .path { color: var(--motion); font-size: 12.5px; font-family: var(--font-mono); }
.profile-card .bio { color: var(--muted); font-size: 13px; margin-top: 2px; }
.profile-card .count {
    margin-left: auto; text-align: right; font-family: var(--font-mono); font-size: 20px;
    font-weight: 600; color: var(--ink); flex-shrink: 0;
}
.profile-card .count small { display: block; font-size: 10px; font-weight: 400; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.avatar {
    width: 46px; height: 46px; border-radius: 6px; flex-shrink: 0;
    background: var(--paper); border: 1.5px solid var(--ink);
    display: flex; align-items: center; justify-content: center;
    color: var(--ink); font-weight: 700; font-size: 17px; font-family: var(--font-display);
    object-fit: cover;
}

.empty-state { text-align: center; color: var(--muted); padding: 50px 20px; font-size: 14px; }
.empty { color: var(--muted); font-style: italic; font-size: 13px; }

/* ============ AUTH PAGES ============ */

.auth-wrapper { max-width: 420px; margin: 50px auto; }
.login-box {
    background: var(--paper-lift); border: 1px solid var(--rule); border-top: 3px solid var(--ink);
    border-radius: 0 0 var(--radius) var(--radius); padding: 30px;
}
.login-box h2 { margin-bottom: 18px; }
.switch-link { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--muted); }
.switch-link a { color: var(--motion); font-weight: 600; text-decoration: none; }

/* ============ STATUS / BANNERS ============ */

.status-banner {
    background: var(--amber-bg); border: 1px solid var(--amber); border-left-width: 4px; color: #7A5116;
    padding: 16px 20px; border-radius: var(--radius); margin-bottom: 24px; font-size: 14px;
}
.status-banner.danger { background: var(--red-bg); border-color: var(--red); color: #7C271F; }
.status-banner.info { background: var(--motion-tint); border-color: var(--motion); color: var(--motion-dark); }

/* ============ NAMEPATH SETUP ============ */

.namepath-setup {
    max-width: 460px; margin: 50px auto; background: var(--paper-lift);
    border: 1px solid var(--rule); border-top: 3px solid var(--motion);
    padding: 30px; border-radius: 0 0 var(--radius) var(--radius);
}
.namepath-setup .preview { font-size: 12.5px; margin-top: 7px; font-family: var(--font-mono); }
.preview.available { color: var(--green); }
.preview.taken { color: var(--red); }

/* ============ PUBLIC PROFILE HEADER ============ */

.profile-header {
    display: flex; gap: 22px; align-items: center; flex-wrap: wrap;
    padding: 28px 0; border-bottom: 1.5px solid var(--ink); margin-bottom: 30px;
}
.profile-header .avatar { width: 74px; height: 74px; font-size: 26px; border-radius: 8px; }
.profile-header h1 { font-size: 26px; margin-bottom: 2px; }
.profile-header .path { color: var(--motion); font-weight: 600; font-family: var(--font-mono); font-size: 13px; }
.profile-header .bio { color: var(--ink-soft); margin-top: 8px; font-size: 14px; max-width: 480px; }
.profile-header .socials { margin-top: 10px; display: flex; gap: 14px; }
.profile-header .socials a { color: var(--ink-soft); font-size: 17px; }
.profile-header .socials a:hover { color: var(--motion); }
.profile-header .edit-link { margin-left: auto; }

/* ============ ACHIEVEMENTS DISPLAY ============ */

.achievements-display { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
@media (max-width: 720px) { .achievements-display { grid-template-columns: 1fr; gap: 28px; } }
.achievement-section { border-top: 2px solid var(--ink); padding-top: 12px; }
.achievement-list { list-style: none; padding: 0; margin: 0; }
.achievement-list li {
    padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 13.5px; color: var(--ink-soft);
}
.achievement-list li a { color: var(--ink); font-weight: 600; text-decoration: none; }
.achievement-list li a:hover { color: var(--motion); }

.detail-list { display: flex; flex-direction: column; gap: 10px; }
.detail-card {
    background: var(--paper-lift); border: 1px solid var(--rule); border-radius: var(--radius); padding: 15px 17px;
}
.detail-card .dr { display: flex; justify-content: space-between; font-size: 12.5px; padding: 4px 0; gap: 12px; }
.detail-card .dr span { color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-size: 11px; }
.detail-card .dr b { color: var(--ink); font-weight: 600; text-align: right; font-family: var(--font-mono); }
.detail-card .tab-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; color: var(--motion); text-decoration: none; font-family: var(--font-mono); font-weight: 600; }
.detail-card .tab-link:hover { text-decoration: underline; }
.detail-card .card-actions { margin-top: 12px; text-align: right; }

/* ============ TABS ============ */

.tabs { display: flex; gap: 6px; border-bottom: 1.5px solid var(--rule); margin-bottom: 24px; }
.tab-btn {
    padding: 11px 18px; border: none; background: transparent; cursor: pointer;
    font-family: var(--font-ui); font-weight: 600; font-size: 13.5px; color: var(--muted);
    border-bottom: 2.5px solid transparent; margin-bottom: -1.5px; transition: all .15s;
    display: inline-flex; align-items: center; gap: 6px;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--motion); border-bottom-color: var(--motion); }
.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-count {
    background: var(--rule); color: var(--ink-soft); font-family: var(--font-mono); font-size: 10.5px;
    padding: 1px 6px; border-radius: 999px; font-weight: 600;
}
.tab-btn.active .tab-count { background: var(--motion); color: white; }

/* ============ ADMIN ============ */

.admin-panel h2 { margin-bottom: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; margin-bottom: 26px; }
.stat-card { background: var(--paper-lift); padding: 18px; text-align: center; }
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--ink); font-family: var(--font-mono); }
.stat-card .label { font-size: 11px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .03em; }

.admin-tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; border-bottom: 1.5px solid var(--rule); }
.admin-tabs button {
    padding: 10px 16px; border: none; background: transparent; color: var(--muted); cursor: pointer;
    font-weight: 600; font-size: 13px; font-family: var(--font-ui);
    border-bottom: 2.5px solid transparent; margin-bottom: -1.5px;
}
.admin-tabs button.active { color: var(--motion); border-bottom-color: var(--motion); }

.admin-table-wrap { background: var(--paper-lift); border: 1px solid var(--rule); border-radius: var(--radius); overflow-x: auto; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.admin-table th {
    text-align: left; padding: 12px 16px; color: var(--muted); border-bottom: 1.5px solid var(--ink);
    font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
}
table.admin-table td { padding: 12px 16px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.admin-table tr:last-child td { border-bottom: none; }
table.admin-table tr:hover td { background: var(--motion-tint); }

.badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px; border-radius: 999px;
    font-size: 11px; font-weight: 600; font-family: var(--font-mono); border: 1px solid; text-transform: uppercase; letter-spacing: .02em;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.pending { color: var(--amber); background: var(--amber-bg); border-color: var(--amber); }
.badge.approved { color: var(--green); background: var(--green-bg); border-color: var(--green); }
.badge.rejected { color: var(--red); background: var(--red-bg); border-color: var(--red); }
.badge.banned { color: var(--ink-soft); background: var(--rule); border-color: var(--rule-strong); }
.badge.admin { color: var(--motion); background: var(--motion-tint); border-color: var(--motion); }

.btn-sm {
    padding: 6px 12px; font-size: 11.5px; border: 1px solid transparent; border-radius: var(--radius);
    cursor: pointer; font-weight: 600; margin-right: 4px; font-family: var(--font-ui); background: transparent;
}
.btn-sm.approve { color: var(--green); border-color: var(--green); }
.btn-sm.approve:hover { background: var(--green); color: white; }
.btn-sm.reject { color: var(--amber); border-color: var(--amber); }
.btn-sm.reject:hover { background: var(--amber); color: white; }
.btn-sm.ban { color: var(--red); border-color: var(--red); }
.btn-sm.ban:hover { background: var(--red); color: white; }
.btn-sm.delete { color: var(--muted); border-color: var(--rule-strong); }
.btn-sm.delete:hover { background: var(--ink); color: white; border-color: var(--ink); }
.btn-sm.edit { color: var(--motion); border-color: var(--motion); }
.btn-sm.edit:hover { background: var(--motion); color: white; }

/* ============ MAILBOX / INBOX ============ */

.inbox-list { display: flex; flex-direction: column; gap: 10px; }
.inbox-item {
    background: var(--paper-lift); border: 1px solid var(--rule); border-radius: var(--radius);
    padding: 16px 20px; cursor: pointer; transition: border-color .15s;
}
.inbox-item:hover { border-color: var(--motion); }
.inbox-item.unread { border-left: 3px solid var(--motion); background: var(--motion-tint); }
.inbox-item .i-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.inbox-item .i-title { font-weight: 700; font-size: 14.5px; color: var(--ink); }
.inbox-item .i-date { font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.inbox-item .i-from { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.inbox-item .i-body { font-size: 13.5px; color: var(--ink-soft); margin-top: 8px; white-space: pre-wrap; display: none; }
.inbox-item.open .i-body { display: block; }
.inbox-item .i-preview { font-size: 13px; color: var(--muted); margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-item.open .i-preview { display: none; }

/* ============ TOAST ============ */

.app-toast {
    position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--ink); color: var(--paper); padding: 12px 22px; border-radius: var(--radius);
    font-size: 13.5px; font-family: var(--font-ui); opacity: 0; pointer-events: none; transition: all .25s; z-index: 999;
    box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.app-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.app-toast.error { background: var(--red); }

/* ============ RESPONSIVE ============ */

@media (max-width: 640px) {
    .hero h1 { font-size: 32px; }
    .navbar { flex-direction: column; align-items: stretch; }
    .profile-header { flex-direction: column; text-align: center; }
    .profile-header .edit-link { margin-left: 0; width: 100%; }
    .form-row { grid-template-columns: 1fr; }
    .profile-card { flex-wrap: wrap; }
    .profile-card .count { margin-left: 0; }
}
