/* =====================================================================
   HỆ THỐNG CASHBACK — Giao diện Admin
   Token thiết kế:
     Nền:      #FFFFFF / #F6F8FA (soft)
     Chữ:      #12161C (ink) / #626C7A (ink phụ)
     Nhấn:     #0F9D74 (emerald — tiền/tăng trưởng) / #0B7A5A (đậm) / #E6F7F1 (nền nhạt)
     Cảnh báo: #F59E0B (chờ xử lý) — Nguy hiểm: #E5484D
     Font:     'Sora' cho tiêu đề, 'Inter' cho nội dung, 'JetBrains Mono' cho số liệu/ID
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@500;600&display=swap');

:root {
    --bg: #ffffff;
    --bg-soft: #f6f8fa;
    --bg-soft-2: #eef1f5;
    --ink: #12161c;
    --ink-soft: #626c7a;
    --ink-faint: #9aa4b2;
    --border: #e7eaef;
    --accent: #0f9d74;
    --accent-deep: #0b7a5a;
    --accent-soft: #e6f7f1;
    --warn: #f59e0b;
    --warn-soft: #fef3e2;
    --danger: #e5484d;
    --danger-soft: #fdeaec;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(18, 22, 28, 0.04);
    --shadow-md: 0 8px 24px rgba(18, 22, 28, 0.06);
    --sidebar-w: 250px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-soft);
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .display {
    font-family: 'Sora', 'Inter', sans-serif;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0;
}

.mono { font-family: 'JetBrains Mono', monospace; }

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--accent-soft); color: var(--accent-deep); }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* Focus rõ ràng cho bàn phím — khả năng tiếp cận */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------------------
   Layout chung
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 22px 16px;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform 0.25s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 22px 10px;
}
.brand-mark {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    display: flex; align-items: center; justify-content: center;
    font-size: 17px;
    box-shadow: var(--shadow-sm);
}
.brand-text { font-family: 'Sora'; font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-text small { display: block; font-family: 'Inter'; font-weight: 500; font-size: 11px; color: var(--ink-faint); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-weight: 500;
    font-size: 13.8px;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: var(--bg-soft); text-decoration: none; color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
.nav-item .emoji { font-size: 16px; width: 20px; text-align: center; }

.sidebar-foot {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    font-size: 12.5px;
    color: var(--ink-faint);
}

.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    padding: 26px 32px 60px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    gap: 12px;
    flex-wrap: wrap;
}
.topbar h1 { font-size: 21px; font-weight: 700; }
.topbar .subtitle { color: var(--ink-soft); font-size: 13.5px; margin-top: 2px; }

.admin-chip {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 6px 8px 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    box-shadow: var(--shadow-sm);
}
.admin-chip .avatar {
    width: 26px; height: 26px; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent-deep);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px;
}
.admin-chip a.logout {
    color: var(--ink-faint); padding: 4px 10px; border-radius: 999px;
}
.admin-chip a.logout:hover { background: var(--danger-soft); color: var(--danger); text-decoration: none; }

/* ---------------------------------------------------------------------
   Thẻ (card), lưới thống kê
   --------------------------------------------------------------------- */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px 22px;
}

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2,1fr);} }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.stat-card {
    display: flex; flex-direction: column; gap: 6px;
    position: relative;
    overflow: hidden;
}
.stat-card .label { color: var(--ink-soft); font-size: 12.8px; font-weight: 500; display:flex; align-items:center; gap:6px; }
.stat-card .value { font-family: 'Sora'; font-size: 25px; font-weight: 700; }
.stat-card .value.count-up { opacity: 0; animation: fadeUp 0.5s ease forwards; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Thẻ ví — signature element của dashboard */
.wallet-hero {
    border-radius: var(--radius);
    background: linear-gradient(120deg, #0b2e26 0%, #0f9d74 55%, #14b989 100%);
    color: #fff;
    padding: 26px 28px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.wallet-hero::before {
    content: "";
    position: absolute; inset: 0;
    background: radial-gradient(circle at 85% 15%, rgba(255,255,255,0.16), transparent 55%);
}
.wallet-hero .eyebrow { font-size: 12.5px; opacity: 0.85; font-weight: 600; letter-spacing: 0.02em; }
.wallet-hero .big-number { font-family: 'Sora'; font-size: 40px; font-weight: 800; margin: 4px 0 14px; }
.wallet-hero .wallet-row { display: flex; gap: 28px; flex-wrap: wrap; position: relative; z-index: 1; }
.wallet-hero .wallet-item .k { font-size: 12px; opacity: 0.8; }
.wallet-hero .wallet-item .v { font-family: 'JetBrains Mono'; font-size: 16px; font-weight: 600; margin-top: 2px; }

/* ---------------------------------------------------------------------
   Bảng dữ liệu
   --------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg); }
table { width: 100%; border-collapse: collapse; font-size: 13.6px; }
thead th {
    text-align: left; padding: 12px 16px;
    background: var(--bg-soft);
    color: var(--ink-soft);
    font-weight: 600; font-size: 12.2px;
    text-transform: uppercase; letter-spacing: 0.02em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--bg-soft); }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
}
.badge-success { background: var(--accent-soft); color: var(--accent-deep); }
.badge-warn { background: var(--warn-soft); color: #92620a; }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--bg-soft-2); color: var(--ink-soft); }

/* ---------------------------------------------------------------------
   Nút bấm
   --------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--ink);
    font-weight: 600; font-size: 13.5px;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #c93d42; }
.btn-sm { padding: 6px 12px; font-size: 12.6px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------------------------------------------------------------------
   Form
   --------------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field .hint { color: var(--ink-faint); font-size: 12px; margin-top: 5px; }
.field input[type=text], .field input[type=password], .field input[type=number], .field select {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    color: var(--ink);
    transition: border 0.15s ease, background 0.15s ease;
}
.field input:focus, .field select:focus {
    background: var(--bg);
    border-color: var(--accent);
}

.toast {
    position: fixed; top: 20px; right: 20px; z-index: 999;
    background: var(--ink); color: #fff;
    padding: 12px 18px; border-radius: var(--radius-sm);
    font-size: 13.5px; box-shadow: var(--shadow-md);
    animation: slideIn 0.25s ease;
}
.toast.success { background: var(--accent-deep); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.empty-state {
    text-align: center; padding: 50px 20px; color: var(--ink-soft);
}
.empty-state .emoji { font-size: 34px; margin-bottom: 10px; display: block; }

/* Login page */
.login-shell {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 20% 20%, #eafaf3, var(--bg-soft) 55%);
}
.login-card {
    width: 100%; max-width: 380px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 34px 30px;
}
.login-card .brand-mark { margin: 0 auto 16px; }
.login-card h1 { text-align: center; font-size: 19px; margin-bottom: 4px; }
.login-card .subtitle { text-align: center; color: var(--ink-soft); font-size: 13px; margin-bottom: 24px; }
.login-error {
    background: var(--danger-soft); color: var(--danger);
    padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: 13px; margin-bottom: 16px;
}

.section-title {
    font-size: 15px; font-weight: 700; margin: 30px 0 14px;
    display: flex; align-items: center; gap: 8px;
}
.section-title:first-child { margin-top: 0; }

.pill-tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.pill-tabs a {
    padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
    background: var(--bg-soft-2); color: var(--ink-soft);
}
.pill-tabs a.active { background: var(--accent); color: #fff; }
.pill-tabs a:hover { text-decoration: none; }

.search-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 12px;
    margin-bottom: 14px; max-width: 320px;
}
.search-box input { border: none; outline: none; background: transparent; width: 100%; font-size: 13.5px; }

/* Mobile: ẩn sidebar, hiện nút toggle */
.menu-toggle { display: none; }
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
    .main { margin-left: 0; padding: 20px 16px 60px; }
    .menu-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 38px; height: 38px; border-radius: var(--radius-sm);
        background: var(--bg); border: 1px solid var(--border); font-size: 18px;
    }
}
