/* ==========================================================================
   MARKIDS ADMIN — Design System
   Tông: Indigo → Violet trên nền slate sáng. Dùng kèm Tailwind (Tailwind lo
   phần layout/spacing, file này lo phần "da" của component).
   ========================================================================== */

:root {
  /* Brand */
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-300: #a5b4fc;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --violet:    #7c3aed;

  /* Neutral */
  --ink-900: #0f172a;
  --ink-800: #1e293b;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --line: #e8eaf1;
  --line-strong: #dde1ec;
  --bg: #f5f6fb;
  --card: #ffffff;

  /* Semantic */
  --ok: #047857;      --ok-bg: #ecfdf5;
  --warn: #b45309;    --warn-bg: #fffbeb;
  --info: #1d4ed8;    --info-bg: #eff6ff;
  --danger: #b91c1c;  --danger-bg: #fef2f2;

  /* Shape */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --sh-sm: 0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.04);
  --sh-md: 0 14px 30px -16px rgba(49,46,129,.35);
}

* { -webkit-tap-highlight-color: transparent; }

body,
.adm-body {
  background: var(--bg);
  color: var(--ink-900);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif;
}

/* ============================ LAYOUT ============================ */

.adm-shell { display: flex; min-height: 100vh; }
.adm-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.adm-main { flex: 1; padding: 1.75rem; }

/* ============================ SIDEBAR ============================ */

.adm-sidebar {
  width: 15rem;
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  display: none;
  flex-direction: column;
  color: #e2e8ff;
  background: linear-gradient(180deg, #1e1b4b 0%, #171532 55%, #10101f 100%);
  border-right: 1px solid rgba(255,255,255,.06);
}
@media (min-width: 768px) { .adm-sidebar { display: flex; } }

.adm-brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 1.1rem 1.15rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.adm-brand-mark {
  height: 2.35rem;
  width: 2.35rem;
  flex: none;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-500), var(--violet));
  box-shadow: 0 10px 20px -10px rgba(99,102,241,.95);
}
.adm-brand-name { font-weight: 800; letter-spacing: -.01em; color: #fff; line-height: 1.1; }
.adm-brand-sub { font-size: .68rem; text-transform: uppercase; letter-spacing: .14em; color: #a5b4fc; }

.adm-nav { flex: 1; padding: .9rem .7rem; display: flex; flex-direction: column; gap: .22rem; overflow-y: auto; }
.adm-nav-label {
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #7c86c9;
  padding: .55rem .75rem .3rem;
}
.adm-nav a {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .58rem .75rem;
  border-radius: var(--r-sm);
  font-size: .875rem;
  font-weight: 600;
  color: #c3caf5;
  text-decoration: none;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.adm-nav a i { width: 1.1rem; text-align: center; font-size: .95rem; }
.adm-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.adm-nav a.active {
  background: linear-gradient(90deg, rgba(99,102,241,.95), rgba(139,92,246,.85));
  color: #fff;
  box-shadow: 0 12px 24px -14px rgba(99,102,241,1);
}
.adm-sidebar-foot {
  padding: .9rem;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.adm-user { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.adm-avatar {
  height: 2rem; width: 2rem; flex: none;
  border-radius: 999px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.12);
  color: #fff; font-size: .8rem; font-weight: 700;
}
.adm-user-name { font-size: .8rem; font-weight: 700; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-user-role { font-size: .68rem; color: #9aa4e0; }
.adm-logout {
  display: flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .5rem .75rem;
  border-radius: var(--r-sm);
  font-size: .8rem; font-weight: 700;
  color: #fecdd3;
  background: rgba(244,63,94,.14);
  border: 1px solid rgba(244,63,94,.28);
  text-decoration: none;
  transition: .16s ease;
}
.adm-logout:hover { background: rgba(244,63,94,.24); color: #fff; }

/* ============================ PAGE HEAD ============================ */

.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; font-size: .78rem; color: var(--ink-400); margin-bottom: .45rem; }
.breadcrumb a { color: var(--brand-600); text-decoration: none; font-weight: 600; }
.breadcrumb a:hover { text-decoration: underline; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-title { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink-900); display: flex; align-items: center; gap: .6rem; }
.page-title i { color: var(--brand-600); }
.page-sub { font-size: .875rem; color: var(--ink-500); margin-top: .2rem; }

/* ============================ CARD ============================ */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.card-title { display: flex; align-items: center; gap: .5rem; font-size: .95rem; font-weight: 700; color: var(--ink-800); }
.card-title i { color: var(--brand-500); }
.card-body { padding: 1.25rem; }

/* ============================ STAT ============================ */

.stat {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 1rem 1.05rem;
  box-shadow: var(--sh-sm);
  display: flex;
  flex-direction: column;
  gap: .55rem;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--sh-md); border-color: var(--brand-200); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.stat-icon { height: 2.3rem; width: 2.3rem; flex: none; border-radius: 12px; display: grid; place-items: center; font-size: 1rem; }
.stat-label { font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-400); }
.stat-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink-900); line-height: 1.1; }
.stat-value-sm { font-size: 1.15rem; }
.stat-foot { font-size: .74rem; color: var(--ink-400); }

.tone-brand  { background: var(--brand-50);  color: var(--brand-600); }
.tone-violet { background: #f5f3ff;         color: var(--violet); }
.tone-ok     { background: var(--ok-bg);    color: var(--ok); }
.tone-warn   { background: var(--warn-bg);  color: var(--warn); }
.tone-info   { background: var(--info-bg);  color: var(--info); }
.tone-danger { background: var(--danger-bg);color: var(--danger); }

/* ============================ TABLE ============================ */

.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }
.tbl thead th {
  background: #fafbff;
  color: var(--ink-500);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: left;
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl tbody td { padding: .7rem .9rem; border-bottom: 1px solid var(--line); color: var(--ink-700); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .15s ease; }
.tbl tbody tr:hover { background: #fafbff; }
.tbl .cell-strong { font-weight: 700; color: var(--ink-900); }
.tbl .cell-sub { font-size: .76rem; color: var(--ink-400); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .center { text-align: center; }

.row-actions { display: flex; align-items: center; gap: .35rem; }

/* ============================ BADGE ============================ */

.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .72rem; font-weight: 700; line-height: 1.6;
  white-space: nowrap;
}
.badge i { font-size: .68rem; }
.badge-brand  { background: var(--brand-50);   color: var(--brand-700); }
.badge-ok     { background: var(--ok-bg);      color: var(--ok); }
.badge-warn   { background: var(--warn-bg);    color: var(--warn); }
.badge-info   { background: var(--info-bg);    color: var(--info); }
.badge-danger { background: var(--danger-bg);  color: var(--danger); }
.badge-muted  { background: #f1f5f9;           color: var(--ink-500); }

/* ============================ BUTTON ============================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem 1rem;
  border-radius: 12px;
  font-size: .875rem; font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: filter .16s ease, transform .16s ease, background .16s ease, border-color .16s ease, color .16s ease;
}
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-600), var(--violet));
  color: #fff;
  box-shadow: 0 12px 22px -14px rgba(79,70,229,1);
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost { background: #fff; border-color: var(--line-strong); color: var(--ink-700); }
.btn-ghost:hover { border-color: var(--brand-300); color: var(--brand-700); background: var(--brand-50); }
.btn-soft { background: var(--brand-50); color: var(--brand-700); }
.btn-soft:hover { background: var(--brand-100); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: .34rem .65rem; font-size: .78rem; border-radius: 10px; }
.btn-block { width: 100%; }

/* ============================ FORM ============================ */

.label { display: block; font-size: .8rem; font-weight: 700; color: var(--ink-600); margin-bottom: .35rem; }
.label .req { color: #e11d48; }

.input, .select, .textarea {
  width: 100%;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  padding: .58rem .8rem;
  font-size: .875rem;
  font-family: inherit;
  color: var(--ink-900);
  background: #fff;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-300);
  box-shadow: 0 0 0 4px var(--brand-50);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-300); }
.select { appearance: none; background-image: none; }
.input::placeholder, .textarea::placeholder { color: var(--ink-300); }
/* Ô nhập có icon bên trái (không dùng utility pl-* để tránh phụ thuộc thứ tự CSS) */
.input.has-icon { padding-left: 2.35rem; }
.icon-in-field {
  position: absolute;
  left: .8rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .85rem;
  color: var(--ink-400);
  pointer-events: none;
}
.hint { font-size: .75rem; color: var(--ink-400); margin-top: .3rem; }

.field { display: flex; flex-direction: column; }
.field-row { display: grid; gap: .9rem; }

.check { display: flex; align-items: center; gap: .55rem; font-size: .875rem; color: var(--ink-700); font-weight: 600; }
.check input[type="checkbox"] { height: 1.05rem; width: 1.05rem; accent-color: var(--brand-600); border-radius: 4px; }

/* ============================ EMPTY / PAGER ============================ */

.empty { text-align: center; padding: 3rem 1rem; color: var(--ink-400); }
.empty i { display: block; font-size: 2.1rem; color: var(--ink-300); margin-bottom: .6rem; }
.empty p { font-size: .9rem; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.pager-info { font-size: .82rem; color: var(--ink-500); }
.pager-ctrl { display: flex; align-items: center; gap: .4rem; }
.pager-ctrl .page-now { font-size: .82rem; color: var(--ink-600); font-weight: 700; padding: 0 .35rem; }

/* ============================ MISC ============================ */

.admin-link { text-decoration: none; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-thumb { transition: transform .2s ease, box-shadow .2s ease; }
.product-thumb:hover { transform: scale(1.08); box-shadow: 0 8px 18px -8px rgba(15,23,42,.45); }

.thumb-box {
  height: 2.6rem; width: 2.6rem; flex: none;
  border-radius: 10px;
  background: #f1f5f9;
  border: 1px solid var(--line);
  display: grid; place-items: center;
  overflow: hidden;
  color: var(--ink-300);
  font-size: .9rem;
}
.thumb-box img { height: 100%; width: 100%; object-fit: cover; }

.alert {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .7rem .9rem;
  border-radius: var(--r-sm);
  font-size: .85rem;
  border: 1px solid transparent;
}
.alert i { margin-top: .1rem; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #a7f3d0; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #bfdbfe; }

/* Thanh lưu cố định ở form dài */
.save-bar {
  position: sticky;
  bottom: 1rem;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1rem;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-md);
}

/* Mục lục tiến trình đơn hàng */
.timeline { position: relative; padding-left: 1.35rem; }
.timeline::before {
  content: ''; position: absolute; left: .34rem; top: .35rem; bottom: .35rem;
  width: 2px; background: var(--line-strong);
}
.timeline-item { position: relative; padding-bottom: .85rem; font-size: .82rem; color: var(--ink-600); }
.timeline-item::before {
  content: ''; position: absolute; left: -1.19rem; top: .3rem;
  height: .6rem; width: .6rem; border-radius: 999px;
  background: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100);
}
.timeline-item:last-child { padding-bottom: 0; }

/* ============================ MOBILE BARS ============================ */
/* Ẩn mặc định, chỉ hiện dưới 768px — dùng media query của riêng file này
   để không phụ thuộc thứ tự nạp CSS với Tailwind. */
.adm-mobile-top,
.adm-mobile-bottom { display: none; }

.adm-mobile-top {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  height: 3.1rem;
  align-items: center; justify-content: space-between;
  gap: .75rem;
  padding: 0 1rem;
  color: #fff;
  background: linear-gradient(90deg, #1e1b4b, #312e81);
  box-shadow: 0 10px 24px -18px rgba(15,23,42,.9);
}
.adm-mobile-bottom {
  position: fixed; inset: auto 0 0 0; z-index: 40;
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px -18px rgba(15,23,42,.5);
}
.adm-mobile-bottom a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  padding: .5rem .2rem .55rem;
  font-size: .66rem; font-weight: 700;
  color: var(--ink-400);
  text-decoration: none;
}
.adm-mobile-bottom a i { font-size: 1.02rem; }
.adm-mobile-bottom a.active { color: var(--brand-600); }
.adm-mobile-bottom a.active i { transform: translateY(-1px); }

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

@media (max-width: 767px) {
  /* Thanh trên + thanh dưới cố định chỉ hiện ở màn hình nhỏ */
  .adm-mobile-top { display: flex; }
  .adm-mobile-bottom { display: flex; }

  /* Chừa chỗ cho 2 thanh cố định */
  .adm-main { padding: 4.4rem 1rem 5.6rem; }
  .adm-main .overflow-x-auto { max-width: 100%; -webkit-overflow-scrolling: touch; }
  .page-title { font-size: 1.2rem; }
  .stat-value { font-size: 1.4rem; }
  .save-bar { bottom: 4.6rem; }
}

@media (max-width: 1023px) {
  .adm-main .overflow-x-auto { max-width: 100%; }
  .tbl thead th, .tbl tbody td { padding: .6rem .65rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
