/* Tools Chắn theme — layered on top of AdminLTE 3 */
:root {
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: #eef2ff;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #1f2937;
    --muted: #6b7280;
    --sidebar-bg: #111827;
    --sidebar-hover: #1f2937;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .08);
}

body {
    font-family: "Be Vietnam Pro", "Source Sans Pro", -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    font-size: .925rem;
}

.content-wrapper { background: var(--bg); }
.content-wrapper > .content { padding: 1.25rem .5rem 2rem; }

/* ---------- Navbar ---------- */
.main-header.navbar {
    border-bottom: 1px solid var(--border);
    box-shadow: none;
    min-height: 60px;
}
.page-heading { display: flex; flex-direction: column; justify-content: center; margin-left: .5rem; min-width: 0; flex: 1 1 auto; }
.main-header .navbar-nav.ml-auto { flex-shrink: 0; }
.page-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.page-crumbs { font-size: .75rem; color: var(--muted); line-height: 1.2; }
.user-chip { color: var(--muted) !important; font-weight: 500; }
.user-chip i { margin-right: .25rem; }

/* ---------- Sidebar ---------- */
.main-sidebar, .main-sidebar .brand-link { background: var(--sidebar-bg); }
.main-sidebar .sidebar { overflow-x: hidden; }
.main-sidebar .brand-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    height: 60px;
    border-bottom: 1px solid rgba(255, 255, 255, .06) !important;
}
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    margin-left: .2rem;
}
.brand-text { font-weight: 700; letter-spacing: .02em; color: #fff; }

.menu-search {
    position: relative;
    margin: .85rem .25rem .25rem;
}
.menu-search i {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    font-size: .8rem;
}
.menu-search input {
    width: 100%;
    padding: .45rem .75rem .45rem 2rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .08);
    background: rgba(255, 255, 255, .05);
    color: #e5e7eb;
    font-size: .85rem;
    outline: none;
}
.menu-search input:focus { border-color: var(--accent); background: rgba(255, 255, 255, .08); }
.sidebar-collapse .main-sidebar:not(:hover) .menu-search { display: none; }

.nav-sidebar .nav-link { border-radius: 8px; color: #cbd5e1 !important; font-size: .875rem; }
.nav-sidebar .nav-link:hover { background: var(--sidebar-hover) !important; color: #fff !important; }
.nav-sidebar > .nav-item > .nav-link.active {
    background: rgba(79, 70, 229, .18) !important;
    color: #fff !important;
    box-shadow: none !important;
}
.nav-sidebar .nav-treeview .nav-link.active {
    background: var(--accent) !important;
    color: #fff !important;
    box-shadow: none !important;
}
.nav-sidebar .nav-treeview .nav-icon { font-size: .55rem !important; opacity: .7; }
.nav-sidebar .nav-treeview .fa-folder.nav-icon { font-size: .8rem !important; }
.nav-sidebar .nav-item.search-hidden { display: none; }

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.card[class*="card-"]:not(.card-outline) > .card-header {
    background: transparent;
    color: var(--text);
}
.card[class*="card-"]:not(.card-outline) > .card-header .btn-tool { color: var(--muted); }
.card-header {
    border-bottom: 1px solid var(--border);
    padding: .85rem 1.25rem;
}
.card-header.is-empty { display: none; }
.card-title { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* Date filter card: label + input + button on one row */
.card form .form-group { margin-bottom: 0; }
.card form label { font-size: .8rem; font-weight: 500; color: var(--muted); margin-bottom: .35rem; }
.card form .input-group { flex-wrap: nowrap; }
.card form .input-group .btn-block {
    width: auto;
    margin-left: .5rem;
    margin-top: 0;
    border-radius: 8px !important;
    white-space: nowrap;
}
.input-group-text { background: #f9fafb; border-color: var(--border); color: var(--muted); }
.form-control { border-color: var(--border); }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
#range { cursor: pointer; background: #fff; min-width: 250px; }
/* the filter card sits in a narrow col-md-4: let it grow to fit the date range */
@media (min-width: 768px) {
    .row > .col-md-4:has(> .card form) { flex: 0 0 auto; max-width: 100%; width: auto; }
}

.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover, .btn-primary:focus, .btn-primary:not(:disabled):not(.disabled):active {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* ---------- Tables ---------- */
.card-body div[style*="overflow-x"] {
    max-height: 75vh;
    overflow: auto !important;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.table { margin-bottom: 0; font-variant-numeric: tabular-nums; }
.table-bordered, .table-bordered td, .table-bordered th { border-color: #eef0f3; }
.table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
    color: #475569;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .02em;
    vertical-align: middle;
    border-bottom: 1px solid var(--border) !important;
    white-space: nowrap;
}
.table thead tr + tr th { top: 38px; }
.table td { vertical-align: middle; padding: .55rem .75rem; }
.table td[bgcolor], .table th[bgcolor] { background-color: #f8fafc; }
.table td[style*="sticky"], .table th[style*="sticky"] { left: 0; z-index: 1; }
.table thead th[style*="sticky"] { z-index: 3; }
.table-hover tbody tr:hover td { background-color: var(--accent-soft); }
table.dataTable thead .sorting::before, table.dataTable thead .sorting::after,
table.dataTable thead .sorting_asc::before, table.dataTable thead .sorting_asc::after { display: none; }

/* Reusable pieces for redesigned pages (e.g. feeByHour) */
.filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem 1rem; }
.filter-row .filter-field { min-width: 0; }
.filter-row .input-group { flex-wrap: nowrap; }
.filter-row .hour-range select { min-width: 72px; }

.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.stat-value { font-size: clamp(1.1rem, 1.6vw, 1.5rem); font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .15rem; overflow-wrap: anywhere; }

.tabs-header { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.area-tabs { flex-wrap: wrap; gap: .25rem; flex: 1 1 auto; min-width: 0; }
.area-tabs .nav-link { white-space: nowrap; font-size: .85rem; font-weight: 500; color: var(--muted); border-radius: 8px; padding: .4rem .8rem; }
.area-tabs .nav-link:hover { color: var(--text); background: #f3f4f6; }
.area-tabs .nav-link.active { background: var(--accent-soft); color: var(--accent); }

.metric-toggle { background: #f3f4f6; border-radius: 8px; padding: 3px; flex-shrink: 0; }
.metric-toggle .btn { border: none; border-radius: 6px !important; color: var(--muted); font-weight: 500; padding: .3rem .9rem; }
.metric-toggle .btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .1); }
[data-metric="fee"] .v-count, [data-metric="count"] .v-fee,
[data-metric="abs"] .v-pct, [data-metric="pct"] .v-abs { display: none; }
.stat-share { margin-left: .35rem; font-size: .75rem; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: .05rem .45rem; }
.table.grouped-head thead tr:first-child th.group-head { text-align: center; border-bottom: 1px solid var(--border) !important; }

.range-note { color: var(--muted); font-size: .85rem; margin-bottom: .75rem; }
.empty-state { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty-state i { margin-right: .35rem; }

.table-scroll { max-height: 70vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.table-scroll .table { border: none; }
.table .num { text-align: right; white-space: nowrap; }
.table .sticky-col { position: sticky; left: 0; z-index: 1; background: #f8fafc; white-space: nowrap; font-weight: 500; }
.table thead .sticky-col { z-index: 3; }
.table .col-total { background: #fafaff; font-weight: 600; }
.table tfoot td { position: sticky; bottom: 0; z-index: 1; background: #f1f5f9; font-weight: 600; border-top: 2px solid var(--border); }
.table tfoot .sticky-col { z-index: 2; background: #f1f5f9; }

/* ---------- Charts ---------- */
.chart canvas { width: 100% !important; }

/* ---------- Date range picker ---------- */
.daterangepicker {
    font-family: inherit;
    border-color: var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(16, 24, 40, .12);
}
.daterangepicker .ranges li { border-radius: 6px; margin: 2px 6px; }
.daterangepicker .ranges li.active, .daterangepicker td.active, .daterangepicker td.active:hover { background-color: var(--accent); }
.daterangepicker td.in-range { background-color: var(--accent-soft); }

/* ---------- Login ---------- */
.login-page {
    background: radial-gradient(circle at 20% 20%, #312e81 0, #111827 55%);
}
.login-box { width: 380px; max-width: calc(100vw - 32px); }
.login-brand { display: flex; align-items: center; justify-content: center; gap: .75rem; color: #fff; margin-bottom: 1.5rem; }
.login-brand .brand-mark { width: 44px; height: 44px; flex-basis: 44px; font-size: 1.2rem; border-radius: 12px; }
.login-brand span { font-size: 1.5rem; font-weight: 700; }
.login-box .card { border: none; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.login-card-body { padding: 2rem; border-radius: var(--radius); }
.login-card-body h1 { font-size: 1.15rem; font-weight: 600; margin-bottom: .25rem; }
.login-card-body p.hint { color: var(--muted); font-size: .85rem; margin-bottom: 1.5rem; }
.login-card-body .btn { padding: .6rem; font-weight: 600; }

/* ---------- Small screens ---------- */
@media (max-width: 576px) {
    .content-wrapper > .content { padding: 1rem 0 2rem; }
    .card-body { padding: 1rem; }
    .page-crumbs { display: none; }
    .page-title { font-size: .95rem; }
    #range { min-width: 0; }
    .card form .input-group { flex-wrap: wrap; }
    .card form .input-group .btn-block { width: 100%; margin: .5rem 0 0; }
    .card form .input-group > .form-control { flex: 1 1 0; }
    .filter-row .filter-field, .filter-row .btn { width: 100%; }
    .stat-tile { margin-bottom: .75rem; padding: .75rem 1rem; }
    .stat-value { font-size: 1.25rem; }
}
