/* ============================================================
   shadcn-style.css — Tái tạo design system shadcn/ui (theme Zinc)
   Dùng cho HTML thuần / Flask / Jinja2. Không cần Tailwind/React.
   Dark mode: thêm class "dark" vào <html> hoặc <body>.
   ============================================================ */

/* ---------- 1. DESIGN TOKENS ---------- */
:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --success: 142 71% 35%;
  --success-foreground: 0 0% 98%;
  --warning: 38 92% 50%;
  --warning-foreground: 240 10% 3.9%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 10% 3.9%;
  --radius: 0.5rem;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.dark {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 3.9%;
  --card-foreground: 0 0% 98%;
  --popover: 240 10% 3.9%;
  --popover-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62.8% 50%;
  --destructive-foreground: 0 0% 98%;
  --success: 142 71% 45%;
  --warning: 38 92% 55%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --ring: 240 4.9% 83.9%;
}

/* ---------- 2. BASE ---------- */
*, *::before, *::after { box-sizing: border-box; border-color: hsl(var(--border)); }

body {
  margin: 0;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.875rem;            /* 14px — chuẩn shadcn */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 2.25rem; font-weight: 800; letter-spacing: -0.025em; line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.25; margin: 0 0 .5rem; }
h3 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.025em; margin: 0 0 .5rem; }
h4 { font-size: 1.125rem; font-weight: 600; margin: 0 0 .5rem; }

a { color: hsl(var(--primary)); text-decoration: underline; text-underline-offset: 4px; }
a:hover { text-decoration-thickness: 2px; }

.text-muted { color: hsl(var(--muted-foreground)); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

/* ---------- 3. BUTTON ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  height: 2.25rem;               /* 36px */
  padding: 0 1rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: color .15s, background-color .15s, border-color .15s, box-shadow .15s, opacity .15s;
  text-decoration: none;
  user-select: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  line-height: 1;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring)); }
.btn:disabled { pointer-events: none; opacity: 0.5; }
.btn svg { width: 1rem; height: 1rem; flex-shrink: 0; }

.btn-primary { background-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background-color: hsl(var(--primary) / 0.9); }

.btn-secondary { background-color: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background-color: hsl(var(--secondary) / 0.8); }

.btn-destructive { background-color: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); box-shadow: var(--shadow-sm); }
.btn-destructive:hover { background-color: hsl(var(--destructive) / 0.9); }

.btn-outline { border-color: hsl(var(--input)); background-color: hsl(var(--background)); box-shadow: var(--shadow-sm); }
.btn-outline:hover { background-color: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }

.btn-ghost:hover { background-color: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }

.btn-link { color: hsl(var(--primary)); text-underline-offset: 4px; }
.btn-link:hover { text-decoration: underline; }

.btn-sm { height: 2rem; padding: 0 0.75rem; font-size: 0.8125rem; border-radius: calc(var(--radius) - 2px); }
.btn-lg { height: 2.5rem; padding: 0 2rem; border-radius: var(--radius); }
.btn-icon { width: 2.25rem; padding: 0; }

/* ---------- 4. CARD ---------- */
.card {
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header { display: flex; flex-direction: column; gap: 0.375rem; padding: 1.5rem; }
.card-title { font-size: 1rem; font-weight: 600; line-height: 1; letter-spacing: -0.01em; margin: 0; }
.card-description { font-size: 0.875rem; color: hsl(var(--muted-foreground)); margin: 0; }
.card-content { padding: 1.5rem; padding-top: 0; }
.card-footer { display: flex; align-items: center; padding: 1.5rem; padding-top: 0; gap: 0.5rem; }

/* ---------- 5. FORM ---------- */
.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  margin-bottom: 0.5rem;
}
.input, .textarea, .select {
  display: flex;
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--input));
  background-color: transparent;
  padding: 0.25rem 0.75rem;
  height: 2.25rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: hsl(var(--foreground));
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 4rem; padding: 0.5rem 0.75rem; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: hsl(var(--muted-foreground)); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 1px hsl(var(--ring));
}
.input:disabled, .textarea:disabled, .select:disabled { cursor: not-allowed; opacity: 0.5; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}
.form-group { margin-bottom: 1rem; }
.form-hint { font-size: 0.8125rem; color: hsl(var(--muted-foreground)); margin-top: 0.375rem; }
.form-error { font-size: 0.8125rem; color: hsl(var(--destructive)); margin-top: 0.375rem; font-weight: 500; }
.input.is-invalid, .textarea.is-invalid, .select.is-invalid { border-color: hsl(var(--destructive)); }

/* Checkbox & Radio */
.checkbox, .radio {
  appearance: none;
  width: 1rem; height: 1rem;
  border: 1px solid hsl(var(--primary));
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  display: inline-block;
  vertical-align: middle;
  position: relative;
  margin: 0;
  flex-shrink: 0;
  transition: background-color .15s;
}
.radio { border-radius: 50%; }
.checkbox:checked, .radio:checked { background-color: hsl(var(--primary)); }
.checkbox:checked::after {
  content: "";
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-size: 0.75rem;
  background-position: center;
  background-repeat: no-repeat;
}
.dark .checkbox:checked::after { filter: invert(1); }
.radio:checked::after {
  content: "";
  position: absolute; inset: 3px;
  border-radius: 50%;
  background: hsl(var(--primary-foreground));
}
.check-label { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; font-weight: 500; cursor: pointer; }

/* Switch */
.switch {
  appearance: none;
  width: 2.25rem; height: 1.25rem;
  border-radius: 9999px;
  background-color: hsl(var(--input));
  position: relative;
  cursor: pointer;
  transition: background-color .15s;
  margin: 0; flex-shrink: 0;
  vertical-align: middle;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 1rem; height: 1rem;
  border-radius: 50%;
  background-color: hsl(var(--background));
  box-shadow: var(--shadow-sm);
  transition: transform .15s;
}
.switch:checked { background-color: hsl(var(--primary)); }
.switch:checked::after { transform: translateX(1rem); }

/* ---------- 6. BADGE ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-primary { background-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.badge-secondary { background-color: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-destructive { background-color: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.badge-success { background-color: hsl(var(--success)); color: hsl(var(--success-foreground)); }
.badge-warning { background-color: hsl(var(--warning)); color: hsl(var(--warning-foreground)); }
.badge-outline { border-color: hsl(var(--border)); color: hsl(var(--foreground)); }

/* ---------- 7. ALERT ---------- */
.alert {
  position: relative;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  font-size: 0.875rem;
}
.alert > svg { width: 1rem; height: 1rem; margin-top: 2px; grid-row: span 2; }
.alert:not(:has(> svg)) { grid-template-columns: 1fr; }
.alert-title { font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.alert-description { color: hsl(var(--muted-foreground)); margin: 0; }
.alert-destructive { border-color: hsl(var(--destructive) / 0.5); color: hsl(var(--destructive)); }
.alert-destructive .alert-description { color: hsl(var(--destructive) / 0.85); }
.alert-success { border-color: hsl(var(--success) / 0.5); color: hsl(var(--success)); }
.alert-success .alert-description { color: hsl(var(--success) / 0.85); }

/* ---------- 8. TABLE ---------- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid hsl(var(--border)); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; caption-side: bottom; }
.table th {
  height: 2.75rem;
  padding: 0 1rem;
  text-align: left;
  vertical-align: middle;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  border-bottom: 1px solid hsl(var(--border));
  white-space: nowrap;
}
.table td { padding: 0.75rem 1rem; vertical-align: middle; border-bottom: 1px solid hsl(var(--border)); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color .1s; }
.table tbody tr:hover { background-color: hsl(var(--muted) / 0.5); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 9. TABS ---------- */
.tabs-list {
  display: inline-flex;
  align-items: center;
  background-color: hsl(var(--muted));
  border-radius: var(--radius);
  padding: 0.25rem;
  gap: 0.25rem;
}
.tab-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3125rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  border: none;
  background: transparent;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  font-family: inherit;
  transition: color .15s, background-color .15s, box-shadow .15s;
}
.tab-trigger.active {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: var(--shadow-sm);
}
.tab-panel { margin-top: 1rem; }
.tab-panel:not(.active) { display: none; }

/* ---------- 10. DIALOG (dùng thẻ <dialog> native) ---------- */
.dialog {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 28rem;
}
.dialog::backdrop { background-color: rgb(0 0 0 / 0.8); }
.dialog-title { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 0.375rem; }
.dialog-description { font-size: 0.875rem; color: hsl(var(--muted-foreground)); margin: 0 0 1rem; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; }

/* ---------- 11. KHÁC ---------- */
.separator { height: 1px; background-color: hsl(var(--border)); border: none; margin: 1rem 0; }
.separator-vertical { width: 1px; align-self: stretch; height: auto; margin: 0 1rem; }

.skeleton {
  background-color: hsl(var(--muted));
  border-radius: calc(var(--radius) - 2px);
  animation: skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes skeleton-pulse { 50% { opacity: 0.5; } }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem; height: 2.5rem;
  border-radius: 50%;
  background-color: hsl(var(--muted));
  font-weight: 500;
  font-size: 0.875rem;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.kbd {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  font-size: 0.75rem;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  background-color: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  box-shadow: var(--shadow-sm);
}

/* Stat card (dashboard KPI) */
.stat-label { font-size: 0.875rem; font-weight: 500; color: hsl(var(--foreground)); margin: 0; }
.stat-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; margin: 0; font-variant-numeric: tabular-nums; }
.stat-delta { font-size: 0.75rem; color: hsl(var(--muted-foreground)); margin: 0; }
.stat-delta.up { color: hsl(var(--success)); }
.stat-delta.down { color: hsl(var(--destructive)); }

/* ---------- 12. LAYOUT HELPERS ---------- */
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 1.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; } .gap-2 { gap: 0.5rem; } .gap-3 { gap: 0.75rem; } .gap-4 { gap: 1rem; } .gap-6 { gap: 1.5rem; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 768px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.mt-2 { margin-top: 0.5rem; } .mt-4 { margin-top: 1rem; } .mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; } .mb-4 { margin-bottom: 1rem; } .mb-6 { margin-bottom: 1.5rem; }
.w-full { width: 100%; }

/* Sidebar layout (admin/dashboard) */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 16rem;
  flex-shrink: 0;
  border-right: 1px solid hsl(var(--border));
  background-color: hsl(var(--background));
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  text-decoration: none;
  transition: background-color .15s;
}
.sidebar-link svg { width: 1rem; height: 1rem; color: hsl(var(--muted-foreground)); }
.sidebar-link:hover { background-color: hsl(var(--accent)); text-decoration: none; }
.sidebar-link.active { background-color: hsl(var(--accent)); font-weight: 600; }
.sidebar-group-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  padding: 0.5rem 0.75rem 0.25rem;
}
.main-content { flex: 1; padding: 1.5rem; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
  padding: 0 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
}
@media (max-width: 768px) { .sidebar { display: none; } }
