/* YUKIWARE Admin — Bootstrap + Be Vietnam Pro + Material Icons */

:root {
  --bs-font-sans-serif: 'Be Vietnam Pro', system-ui, sans-serif;
  --bs-body-font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  --bs-primary: #6750a4;
  --bs-primary-rgb: 103, 80, 164;
  --bs-secondary: #e8def8;
  --bs-secondary-rgb: 232, 222, 248;
  --admin-sidebar-bg: #f8f6fc;
  --admin-surface: #ffffff;
  --admin-text-muted: #6c757d;
  --admin-border: #e9ecef;
  --admin-radius: 0.75rem;
}

body.admin-body {
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  background: #f3f0f9;
  color: #1d1b20;
  min-height: 100vh;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
  user-select: none;
}

/* Layout */
.admin-wrapper { min-height: 100vh; }

.admin-sidebar {
  min-height: 100vh;
  background: var(--admin-sidebar-bg);
  border-right: 1px solid var(--admin-border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-offcanvas {
  width: min(300px, 85vw);
  background: var(--admin-sidebar-bg);
}

.admin-main {
  padding: 1.25rem;
  min-width: 0;
}

@media (min-width: 768px) {
  .admin-main { padding: 1.5rem 2rem 2rem; }
}

@media (min-width: 1200px) {
  .admin-main { padding: 2rem 2.5rem; }
}

/* Brand */
.brand-icon-sm {
  width: 40px;
  height: 40px;
  border-radius: var(--admin-radius);
  background: var(--bs-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Sidebar nav */
.nav-link-sidebar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: 2rem;
  color: #49454f;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  transition: background 0.15s, color 0.15s;
}

.nav-link-sidebar:hover {
  background: #ece6f0;
  color: #1d1b20;
  text-decoration: none;
}

.nav-link-sidebar.active {
  background: var(--bs-secondary);
  color: #21005d;
  font-weight: 600;
}

.nav-link-sidebar .material-symbols-outlined {
  font-size: 22px;
}

/* Page header */
.page-header { margin-bottom: 1.5rem; }

.page-title {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #1d1b20;
}

.page-subtitle {
  color: var(--admin-text-muted);
  font-size: 0.9rem;
  margin-bottom: 0;
}

/* Cards */
.admin-card {
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  background: var(--admin-surface);
  margin-bottom: 1.25rem;
}

.admin-card .card-header {
  background: var(--admin-surface);
  border-bottom: 1px solid var(--admin-border);
  padding: 1rem 1.25rem;
  font-weight: 600;
}

.admin-card .card-body { padding: 1.25rem; }

.card-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 0.5rem;
  background: rgba(var(--bs-primary-rgb), 0.12);
  color: var(--bs-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Stat cards */
.stat-card {
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  background: var(--admin-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  padding: 1.25rem;
  height: 100%;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--admin-radius);
  background: rgba(var(--bs-primary-rgb), 0.12);
  color: var(--bs-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon .material-symbols-outlined { font-size: 24px; }

.stat-value {
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  font-weight: 700;
  line-height: 1.2;
  color: #1d1b20;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--admin-text-muted);
  margin-top: 0.125rem;
}

/* Dashboard charts */
.chart-card .card-body {
  padding: 1rem 1.25rem 1.25rem;
}

.chart-wrap {
  position: relative;
  height: 280px;
  width: 100%;
}

.chart-wrap--doughnut {
  height: 240px;
  max-width: 280px;
  margin: 0 auto;
}

.chart-wrap--bar-h {
  height: min(320px, max(200px, calc(var(--bar-count, 1) * 48px)));
}

@media (max-width: 575.98px) {
  .chart-wrap { height: 220px; }
  .chart-wrap--doughnut { height: 200px; }
}

/* Buttons with icons */
.btn .material-symbols-outlined {
  font-size: 18px;
}

.btn-icon-sm .material-symbols-outlined {
  font-size: 16px;
}

/* Tables */
.table > :not(caption) > * > * {
  padding: 0.85rem 1rem;
  vertical-align: middle;
}

.table thead th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--admin-text-muted);
  background: #f8f9fa;
  white-space: nowrap;
}

.table code {
  font-size: 0.8125rem;
  word-break: break-all;
}

/* Filter pills */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 1rem;
  border-radius: 2rem;
  border: 1px solid var(--admin-border);
  background: var(--admin-surface);
  color: #49454f;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
}

.filter-pill:hover {
  background: #f3f0f9;
  color: var(--bs-primary);
  text-decoration: none;
  border-color: rgba(var(--bs-primary-rgb), 0.3);
}

.filter-pill.active {
  background: var(--bs-primary);
  color: #fff;
  border-color: var(--bs-primary);
}

.filter-pill .material-symbols-outlined { font-size: 18px; }

/* Action button group in tables */
.action-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

/* Topup forms in table */
.topup-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  min-width: 180px;
}

.topup-form-row .form-control {
  flex: 1 1 140px;
  min-width: 0;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f3f0f9 0%, #e8def8 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--admin-border);
  border-radius: 1.25rem;
  box-shadow: 0 8px 32px rgba(103, 80, 164, 0.12);
}

.login-brand-icon {
  width: 64px;
  height: 64px;
  border-radius: 1rem;
  background: var(--bs-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.login-brand-icon .material-symbols-outlined { font-size: 32px; }

/* Bootstrap overrides */
.btn-primary {
  --bs-btn-bg: var(--bs-primary);
  --bs-btn-border-color: var(--bs-primary);
  --bs-btn-hover-bg: #5a4590;
  --bs-btn-hover-border-color: #5a4590;
  --bs-btn-active-bg: #4f3d82;
  --bs-btn-active-border-color: #4f3d82;
}

.bg-primary { background-color: var(--bs-primary) !important; }

.form-control:focus,
.form-select:focus {
  border-color: rgba(var(--bs-primary-rgb), 0.6);
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
}

.badge { font-weight: 500; }

/* Bootstrap switch — label trên, switch dưới */
.form-switch-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  padding-left: 0;
  margin-bottom: 0;
  min-height: auto;
}

.form-switch-stack .form-check-label {
  order: 1;
  margin-bottom: 0;
  padding: 0;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--admin-text-muted);
  line-height: 1.2;
}

.form-switch-stack .form-check-input {
  order: 2;
  margin-left: 0;
  float: none;
  width: 2.5em;
  height: 1.25em;
  cursor: pointer;
}

.form-switch-stack .form-check-input:checked {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

/* DataTables */
.admin-datatable-wrapper {
  padding: 0.25rem 1rem 1rem;
}

div.dataTables_wrapper {
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
}

/* Toolbar: hiển thị số dòng trái — tìm kiếm phải, cùng một hàng */
.dt-toolbar {
  width: 100%;
}

.dt-toolbar .dt-length {
  flex: 1 1 auto;
  min-width: 0;
}

.dt-toolbar .dt-search {
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
  text-align: right;
}

div.dataTables_wrapper .dataTables_length {
  margin-bottom: 0;
}

div.dataTables_wrapper .dataTables_length label,
div.dataTables_wrapper .dataTables_filter label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--admin-text-muted);
  white-space: nowrap;
}

div.dataTables_wrapper .dataTables_filter {
  margin-bottom: 0;
  float: none !important;
  text-align: right !important;
}

div.dataTables_wrapper .dataTables_length select,
div.dataTables_wrapper .dataTables_filter input {
  display: inline-block;
  width: auto;
  min-width: 4.5rem;
  border: 1px solid var(--admin-border);
  border-radius: 0.5rem;
  padding: 0.4rem 0.65rem;
  font-family: inherit;
  font-size: 0.875rem;
  background: #fff;
}

div.dataTables_wrapper .dataTables_filter input {
  min-width: 10rem;
  margin-left: 0 !important;
}

div.dataTables_wrapper .dataTables_filter input:focus,
div.dataTables_wrapper .dataTables_length select:focus {
  border-color: rgba(var(--bs-primary-rgb), 0.6);
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
  outline: none;
}

/* Footer */
.dt-footer {
  width: 100%;
}

.dt-footer .dt-info {
  flex: 1 1 auto;
}

.dt-footer .dt-paging {
  flex: 0 1 auto;
  margin-left: auto;
}

div.dataTables_wrapper .dataTables_info {
  font-size: 0.875rem;
  color: var(--admin-text-muted);
  padding-top: 0.25rem;
}

div.dataTables_wrapper .dataTables_paginate {
  margin-top: 0 !important;
  float: none !important;
}

div.dataTables_wrapper .dataTables_paginate .pagination {
  margin-bottom: 0;
  gap: 0.25rem;
}

div.dataTables_wrapper .dataTables_paginate .page-link {
  border-radius: 0.5rem !important;
  margin: 0 !important;
  font-size: 0.875rem;
  color: var(--bs-primary) !important;
  background-color: #fff !important;
  border: 1px solid var(--admin-border) !important;
  min-width: 2.25rem;
  text-align: center;
  line-height: 1.25;
  padding: 0.375rem 0.65rem;
}

div.dataTables_wrapper .dataTables_paginate .page-item.active .page-link {
  background-color: var(--bs-primary) !important;
  border-color: var(--bs-primary) !important;
  color: #fff !important;
  font-weight: 600;
}

div.dataTables_wrapper .dataTables_paginate .page-item.disabled .page-link {
  color: #adb5bd !important;
  background-color: #f8f9fa !important;
  border-color: var(--admin-border) !important;
}

div.dataTables_wrapper .dataTables_paginate .page-link:hover {
  background-color: rgba(var(--bs-primary-rgb), 0.08) !important;
  color: var(--bs-primary) !important;
  border-color: rgba(var(--bs-primary-rgb), 0.35) !important;
}

div.dataTables_wrapper .dataTables_paginate .page-item.active .page-link:hover {
  background-color: var(--bs-primary) !important;
  color: #fff !important;
}

table.dataTable.table-hover > tbody > tr:hover > * {
  box-shadow: none;
  background-color: #f8f9fa;
}

/* Nút mở rộng responsive — không nền tím */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control {
  position: relative;
  padding-left: 2.25rem !important;
  cursor: pointer;
}

table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
  top: 50%;
  left: 0.65rem;
  transform: translateY(-50%);
  height: 1.25rem;
  width: 1.25rem;
  line-height: 1.15rem;
  border-radius: 0.35rem;
  background-color: #fff !important;
  border: 1px solid var(--admin-border) !important;
  color: var(--bs-primary) !important;
  box-shadow: none;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th.dtr-control::before {
  background-color: rgba(var(--bs-primary-rgb), 0.1) !important;
  border-color: rgba(var(--bs-primary-rgb), 0.35) !important;
  color: var(--bs-primary) !important;
}

/* Chi tiết hàng responsive */
table.dataTable > tbody > tr.child ul.dtr-details {
  width: 100%;
  margin: 0.5rem 0;
  padding: 0.75rem 1rem;
  background: #f8f9fa;
  border: 1px solid var(--admin-border);
  border-radius: 0.5rem;
  list-style: none;
}

table.dataTable > tbody > tr.child ul.dtr-details > li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--admin-border);
}

table.dataTable > tbody > tr.child ul.dtr-details > li:last-child {
  border-bottom: none;
}

table.dataTable > tbody > tr.child span.dtr-title {
  font-weight: 600;
  min-width: 5.5rem;
  color: var(--admin-text-muted);
}

@media (max-width: 575.98px) {
  .dt-toolbar {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 0.5rem !important;
  }

  .dt-toolbar .dt-length {
    flex: 0 1 auto;
  }

  .dt-toolbar .dt-search {
    flex: 1 1 auto;
    min-width: 0;
  }

  div.dataTables_wrapper .dataTables_length label {
    font-size: 0.8125rem;
    gap: 0.35rem;
  }

  div.dataTables_wrapper .dataTables_filter label {
    width: 100%;
    justify-content: flex-end;
    font-size: 0.8125rem;
  }

  div.dataTables_wrapper .dataTables_filter input {
    flex: 1;
    min-width: 0;
    max-width: 9rem;
  }

  .dt-footer {
    flex-direction: column;
    align-items: stretch !important;
  }

  .dt-footer .dt-paging {
    margin-left: 0;
  }

  div.dataTables_wrapper .dataTables_paginate .pagination {
    justify-content: center;
  }
}

.alert .material-symbols-outlined { font-size: 20px; }

/* Responsive table action column */
@media (max-width: 767.98px) {
  .action-btns .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }

  .action-btns .btn .material-symbols-outlined {
    font-size: 16px;
  }

  .hide-mobile { display: none !important; }
}

@media (max-width: 575.98px) {
  .admin-main { padding: 1rem; }

  .stat-card { padding: 1rem; }

  .stat-icon {
    width: 40px;
    height: 40px;
  }
}
