/* ==========================================================================
   July CONTROL — Admin layout theo Linear "midnight precision instrument"
   Giữ nguyên toàn bộ class/ID mà admin.js đang dùng. Chỉ đổi visual:
   void canvas · carbon cards · hairline #23252a · acid-lime CTA duy nhất ·
   radius buttons/inputs 6px · cards 12px · pills 9999px · badges 4px.
   ========================================================================== */

/* Theme toggle spans (do App.applyTheme quản lý) */
.dropdown-theme-icon, .sidebar-theme-icon { flex-shrink: 0; }
.dropdown-theme-text, .sidebar-theme-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- App header (mobile top bar cho các trang admin có sidebar desktop) ---------- */
@media (min-width: 769px) {
  body[data-admin-page] .app-header { display: none; }
  body[data-admin-page] .app-header { margin-left: 248px; }
}
.user-dropdown-container { position: relative; }
.header-right { display: flex; align-items: center; gap: 8px; }

/* ---------- Main layout + pages ---------- */
.page { display: none; }
.page.active { display: block; }
.page-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 96px;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 24px; font-weight: 400; letter-spacing: -0.012em; }
.page-header .title { font-size: 24px; font-weight: 400; letter-spacing: -0.012em; }
.page-header .sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Stats grid ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  min-width: 0;
}
.stat-card.clickable:hover { border-color: var(--text-muted); }
.stat-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stat-card-top .label, .stat-card .label { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.stat-card .value {
  font-size: 32px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.13;
  letter-spacing: -0.022em;
}
.stat-card .desc { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-icon-wrap {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon-wrap svg, .stat-icon-wrap i { width: 16px; height: 16px; }
.stat-icon-wrap.success { background: var(--success-bg); color: var(--success); }
.stat-icon-wrap.warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon-wrap.danger { background: var(--danger-bg); color: var(--danger); }
.stat-num { height: 28px; width: 60px; }

/* ---------- Sections + card list ---------- */
.section-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.section-head .title { font-size: 13px; font-weight: 510; letter-spacing: -0.011em; color: var(--text); }
.section-head .sub { font-size: 12px; color: var(--text-muted); }
.card-list { display: flex; flex-direction: column; gap: 8px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

/* ---------- Filter bar + search + custom select ---------- */
.filter-bar { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 16px; flex-wrap: wrap; }
.search-group, .search-input-wrap { position: relative; flex: 1; min-width: 220px; }
.search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 12px 14px 12px 36px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-size: 14px;
  outline: none;
}
.search-input:focus { border-color: var(--text-secondary); }
.search-input::placeholder { color: var(--text-muted); }
.filter-row-selects { display: flex; gap: 8px; }
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-group.status-group { min-width: 190px; }
.filter-group.sort-group { min-width: 150px; }
.filter-label { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.custom-select {
  position: relative;
  min-height: 44px;
  min-width: 160px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  outline: none;
}
.custom-select:focus, .custom-select.open { border-color: var(--text-secondary); }
.select-selected { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-arrow { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; transition: transform 150ms ease; }
.custom-select.open .select-arrow { transform: rotate(180deg); }
.select-items {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: #202329; background: var(--elev, #202329);
  border: 1px solid #3f444b; border: 1px solid var(--elev-border, #3f444b);
  border-radius: 12px;
  box-shadow: rgba(8, 9, 10, 0.6) 0px 4px 32px 0px;
  z-index: 500;
  overflow: hidden;
  padding: 4px;
}
.select-hide { display: none; }
.select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.select-option:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.select-option.active { color: var(--primary); font-weight: 510; }
.select-option .opt-check { width: 15px; height: 15px; opacity: 0; flex-shrink: 0; }
.select-option.active .opt-check { opacity: 1; }

/* ---------- Data tables (desktop) ---------- */
.data-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.data-table, .table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th, .table thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  background: var(--surface);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td, .table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}
.data-table tbody tr:last-child td, .table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover, .table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

/* ---------- Mobile cards ---------- */
.box-card, .action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}
.box-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.meta-item { min-width: 0; }
.meta-label { font-size: 11px; font-weight: 510; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 3px; }
.meta-val { font-size: 13.5px; color: var(--text-secondary); word-break: break-all; }
.box-tid { font-size: 15px; font-weight: 510; color: var(--text); }
.box-footer { margin-top: 14px; }
.ac-tid { font-size: 13px; color: var(--text); }
.ac-uid { font-size: 12px; color: var(--text-muted); }
.ac-expire { font-size: 12px; font-weight: 510; }
.action-btn-group { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.btn-more {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.btn-more:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }

/* ---------- Status badges (Linear badge 4px) ---------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 400;
  padding: 0 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  white-space: nowrap;
}
.status svg, .status i { width: 13px; height: 13px; }
.status.active, .status.success { background: var(--success-bg); color: var(--success); }
.status.expiring, .status.warning { background: var(--warning-bg); color: var(--warning); }
.status.expired, .status.danger { background: var(--danger-bg); color: var(--danger); }
.status.vacant { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); }

/* ---------- Pagination ---------- */
.pagination-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; }
.pg-info { font-size: 12px; color: var(--text-muted); }
.pagination-btns { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-btn {
  min-width: 32px; height: 32px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}
.page-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 510; }

/* ---------- Drawer ---------- */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 700;
  opacity: 0; pointer-events: none;
  transition: opacity 180ms ease;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.side-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 400px;
  max-width: 92vw;
  background: #202329; background: var(--elev, #202329);
  border-left: 1px solid #3f444b; border-left: 1px solid var(--elev-border, #3f444b);
  z-index: 701;
  transform: translateX(100%);
  transition: transform 220ms ease;
  display: flex;
  flex-direction: column;
}
.side-drawer.open { transform: translateX(0); }
.drawer-handle { display: none; }
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.drawer-title { font-size: 15px; font-weight: 510; letter-spacing: -0.011em; color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.info-row:last-child { border-bottom: none; }
.info-row .lbl { color: var(--text-muted); font-size: 12px; }
.info-row .val { color: var(--text); font-weight: 510; }
.info-row .val.normal { font-weight: 400; color: var(--text-secondary); }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 800;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: 480px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: #202329; background: var(--elev, #202329);
  border: 1px solid #3f444b; border: 1px solid var(--elev-border, #3f444b);
  border-radius: 12px;
  box-shadow: rgba(8, 9, 10, 0.6) 0px 4px 32px 0px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header .title { font-size: 15px; font-weight: 510; letter-spacing: -0.011em; color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}
.preset-row { display: flex; gap: 8px; flex-wrap: wrap; }
.preset-btn {
  flex: 1;
  min-width: 60px;
  padding: 4px 12px;
  border-radius: 9999px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}
.preset-btn:hover { color: var(--text); }
.preset-btn.active { background: var(--primary-bg); color: var(--primary); font-weight: 510; }

/* ---------- Global action menu (desktop) ---------- */
.global-action-menu {
  position: fixed;
  z-index: 900;
  min-width: 200px;
  background: #202329; background: var(--elev, #202329);
  border: 1px solid #3f444b; border: 1px solid var(--elev-border, #3f444b);
  border-radius: 12px;
  box-shadow: rgba(8, 9, 10, 0.6) 0px 4px 32px 0px;
  padding: 5px;
  display: none;
}
.global-action-menu.open { display: block; }
.action-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  color: #ffffff; color: var(--elev-text, #ffffff);
  cursor: pointer;
  text-align: left;
}
.action-menu-item:hover { background: rgba(128, 128, 128, 0.18); color: #ffffff; color: var(--elev-text, #ffffff); }
.action-menu-item.danger { color: var(--danger); }
.action-menu-divider { height: 1px; background: var(--border); margin: 4px 2px; }

/* ---------- Mobile action sheet ---------- */
.mobile-action-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1001;
  background: #202329; background: var(--elev, #202329);
  border-top: 1px solid #3f444b; border-top: 1px solid var(--elev-border, #3f444b);
  border-radius: 12px 12px 0 0;
  padding: 10px 16px 24px;
  transform: translateY(100%);
  transition: transform 220ms ease;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: rgba(8, 9, 10, 0.6) 0px -8px 32px 0px;
}
.mobile-action-sheet.open { transform: translateY(0); }
.sheet-handle-bar { width: 44px; height: 5px; border-radius: 9999px; background: var(--border); margin: 4px auto 12px; cursor: grab; touch-action: none; }
.sheet-handle-bar:active { cursor: grabbing; }
/* Nền sheet filter/action (admin): nhạt hơn nền dialog để đỡ tối thui trên mobile */
#sheetBackdrop { background: rgba(0, 0, 0, 0.45); }
.sheet-head-info { margin-bottom: 10px; }
.sheet-title { font-size: 15px; font-weight: 510; letter-spacing: -0.011em; color: var(--text); }
.sheet-sub { font-size: 12px; color: var(--text-muted); }
.sheet-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: none;
  background: transparent;
  font-size: 14px;
  color: #ffffff; color: var(--elev-text, #ffffff);
  cursor: pointer;
  border-radius: 6px;
  text-align: left;
}
.sheet-item:hover { background: rgba(128, 128, 128, 0.18); color: #ffffff; color: var(--elev-text, #ffffff); }
.sheet-item.active { color: var(--primary); font-weight: 510; }
.sheet-item.danger { color: var(--danger); }
.sheet-item.cancel { color: var(--text-muted); justify-content: center; }
.sheet-divider { height: 1px; background: var(--border); margin: 6px 0; }

/* ---------- Bottom nav (mobile admin) ---------- */
.bottom-nav { display: none; }

/* ---------- Skeleton sizes ---------- */
.skeleton-table-wrap { display: flex; flex-direction: column; gap: 8px; }
.skeleton-table-row { display: flex; gap: 8px; }
.skeleton-line.medium { height: 14px; flex: 2; }
.skeleton-line.short { height: 14px; flex: 1; }

/* ---------- History ---------- */
.history-item { padding: 8px 4px; border-bottom: 1px solid var(--border); }
.history-item:last-child { border-bottom: none; }
.h-time { font-size: 12px; color: var(--text-muted); }
.h-action { font-size: 13px; font-weight: 510; color: var(--text); margin-top: 2px; }
.h-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.h-days { font-size: 12px; font-weight: 510; color: var(--primary); margin-top: 2px; }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 26px 14px; }
.label { font-size: 12px; color: var(--text-muted); }
.value { font-size: 24px; font-weight: 400; letter-spacing: -0.012em; color: var(--text); }
.title { color: var(--text); }
.desc { font-size: 12px; color: var(--text-muted); }
.welcome-header { margin-bottom: 14px; }
.dashboard-left-col, .dashboard-right-col { min-width: 0; }
.dh-name { font-weight: 510; font-size: 13px; color: var(--text); }
.dh-role { font-size: 12px; color: var(--text-muted); }
.history-timeline-grouped { display: flex; flex-direction: column; gap: 8px; }
.btn-full-mobile { min-height: 40px; }

/* ---------- Bulk select (xóa hàng loạt) ---------- */
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #202329;
  background: var(--elev, #202329);
  border: 1px solid var(--primary);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.bulk-count { font-size: 13px; font-weight: 510; color: var(--text); }
.bulk-actions { display: flex; gap: 8px; }
.box-card.selected { border-color: var(--primary); }
.data-table tr.selected td { background: var(--primary-bg); }
.bulk-check { display: inline-flex; cursor: pointer; }
.bulk-check input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 18px; height: 18px;
  margin: 0;
  padding: 0;
  border-radius: 6px;
  border: 1px solid #3f444b;
  border: 1px solid var(--elev-border, #3f444b);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 130ms ease, border-color 130ms ease, transform 100ms ease;
}
.bulk-check input:hover { border-color: var(--text-secondary); }
.bulk-check input:active { transform: scale(0.9); }
.bulk-check input:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.bulk-check input:checked::after {
  content: '';
  position: absolute;
  left: 5.5px; top: 2px;
  width: 5px; height: 9px;
  border: solid var(--on-primary, #08090a);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.bulk-cell { width: 40px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .page-content { padding: 16px 14px 96px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-row-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .filter-group.status-group, .filter-group.sort-group { min-width: 0; }
  .modal-footer { flex-direction: column; }
  .modal-footer .btn { width: 100%; padding: 10px 16px; }
  .btn-full-mobile { width: 100%; }
}
@media (max-width: 767px) {
  html, body { overflow-x: hidden; }
  /* Header component nằm ở style.css — bật lại hiển thị trên mobile */
body[data-admin-page] .app-header { display: flex; }
  .bottom-nav {
    display: none !important;
  }
  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; }
  .data-table-wrap.desktop-only { display: none !important; }

  /* Hamburger mở sidebar drawer */
  .header-menu-btn { display: inline-flex; }
}
@media (min-width: 768px) {
  .mobile-only { display: none !important; }
  .mobile-action-sheet { display: none; }
  body[data-admin-page] .app-header { margin-left: 248px; }
}

/* ==========================================================================
   UI POLISH LAYER (admin) — Linear precision details, không đổi layout/logic
   ========================================================================== */
/* Tiêu đề trang kiểu display lớn, tracking chặt */
@media (min-width: 768px) {
  .page-header h1, .page-header .title { font-size: 32px; line-height: 1.13; letter-spacing: -0.022em; }
}

/* Số liệu tabular */
.stat-card .value, .page-header .sub, .pg-info {
  font-variant-numeric: tabular-nums;
}

/* Card/box hover biên sáng dần */
.box-card:hover, .action-card:hover { border-color: var(--text-muted); }
.stat-card { transition: border-color 150ms ease; }

/* Bottom nav mobile: chấm lime khi active */
.bottom-nav .nav-btn { position: relative; transition: color 150ms ease; }
.bottom-nav .nav-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  width: 20px; height: 2px;
  border-radius: 9999px;
  background: var(--primary);
}

/* Menu popup hiện mượt */
.global-action-menu.open { animation: menuIn 130ms ease both; transform-origin: top right; }
@keyframes menuIn {
  from { opacity: 0; transform: scale(0.97) translateY(-3px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.user-dropdown-menu.open { animation: menuIn 130ms ease both; transform-origin: top right; }

/* Hàng được chọn (bulk) có vạch lime trái */
.data-table tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--primary); }
.box-card.selected { box-shadow: inset 2px 0 0 var(--primary); }

/* Checkbox + nút bulk chuyển mượt */
.bulk-bar { animation: cardIn 200ms ease both; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Focus rõ cho thao tác bàn phím */
.btn:focus-visible, .page-btn:focus-visible, .preset-btn:focus-visible,
.nav-btn:focus-visible, .s-nav-item:focus-visible, .sheet-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Tôn trọng reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
