/* App shell: icon rail + flyout panel (views/sidebar.php), instant-navigation skeleton (assets/js/app-nav.js). */
:root {
  --aff-rail-w: 92px;
  --aff-panel-w: 296px;
  --aff-header-h: 72px;
  --aff-brand: #673ab7;
  --aff-brand-soft: #f3eefc;
  --aff-brand-ring: #e4d8f7;
  --aff-ink: #1f2937;
  --aff-muted: #6b7280;
  --aff-line: #eef0f4;
}

/* ---------- Rail ---------- */
.aff-shell {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  display: flex;
  pointer-events: none;
}
.aff-rail {
  pointer-events: auto;
  width: var(--aff-rail-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 14px 10px;
  background: #fff;
  border-right: 1px solid var(--aff-line);
  overflow-y: auto;
  scrollbar-width: none;
}
.aff-rail::-webkit-scrollbar { display: none; }
.aff-rail-logo {
  display: grid;
  place-items: center;
  height: 44px;
  margin-bottom: 10px;
}
.aff-rail-items,
.aff-rail-bottom {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.aff-rail-bottom { margin-top: auto; padding-top: 10px; }
.aff-rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 2px 9px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #4b5563;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: color .15s ease, background-color .15s ease;
}
.aff-rail-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  transition: background-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.aff-rail-icon svg { width: 22px; height: 22px; }
.aff-rail-label { max-width: 100%; overflow-wrap: anywhere; }
.aff-rail-item:hover { color: var(--aff-brand); }
.aff-rail-item:hover .aff-rail-icon { background: #f6f3fb; }
.aff-rail-item:active .aff-rail-icon { transform: scale(.94); }
.aff-rail-item.is-active,
.aff-rail-item.is-open { color: var(--aff-brand); font-weight: 600; }
.aff-rail-item.is-active .aff-rail-icon,
.aff-rail-item.is-open .aff-rail-icon {
  background: var(--aff-brand-soft);
  box-shadow: inset 0 0 0 1px var(--aff-brand-ring);
}
.aff-rail-item:focus-visible { outline: 2px solid var(--aff-brand); outline-offset: 2px; }
.aff-rail-avatar { width: 30px; height: 30px; border-radius: 999px; object-fit: cover; }

.aff-badge {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
}
.aff-badge[hidden] { display: none; }

/* ---------- Flyout panel ---------- */
.aff-panel {
  pointer-events: auto;
  width: var(--aff-panel-w);
  height: 100%;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid var(--aff-line);
  box-shadow: 18px 0 40px -24px rgba(17, 24, 39, .18);
  transform: translateX(-12px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .16s ease, transform .16s ease, visibility 0s linear .16s;
}
.aff-shell.panel-open .aff-panel {
  transform: none;
  opacity: 1;
  visibility: visible;
  transition: opacity .16s ease, transform .16s ease;
}
.aff-panel-group { padding: 22px 16px 24px; }
.aff-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 6px 14px;
}
.aff-panel-head h2 { font-size: 21px; font-weight: 700; color: var(--aff-ink); letter-spacing: -.02em; }
.aff-panel-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
}
.aff-panel-close:hover { background: #f3f4f6; color: var(--aff-ink); }
.aff-panel-close svg { width: 18px; height: 18px; }
.aff-panel-section + .aff-panel-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--aff-line);
}
.aff-panel-heading {
  margin: 4px 10px 6px;
  color: #9aa1ad;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.aff-panel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 9px 10px;
  border-radius: 12px;
  color: #374151;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color .12s ease, color .12s ease;
}
.aff-panel-item > svg { flex: none; width: 20px; height: 20px; color: #9ca3af; }
.aff-panel-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.aff-panel-text small { color: #9ca3af; font-size: 12px; font-weight: 400; line-height: 1.35; margin-top: 1px; }
.aff-panel-item:hover { background: #f7f5fb; color: var(--aff-brand); }
.aff-panel-item:hover > svg { color: var(--aff-brand); }
.aff-panel-item.is-active { background: var(--aff-brand-soft); color: var(--aff-brand); font-weight: 600; }
.aff-panel-item.is-active > svg { color: var(--aff-brand); }
.aff-panel-item.is-soon { cursor: default; color: #9ca3af; }
.aff-panel-item.is-soon:hover { background: transparent; color: #9ca3af; }
.aff-panel-item.is-soon:hover > svg { color: #9ca3af; }
.aff-panel-item.is-danger { color: #dc2626; }
.aff-panel-item.is-danger > svg { color: #f87171; }
.aff-panel-item.is-danger:hover { background: #fef2f2; color: #b91c1c; }
.aff-panel-item .aff-badge { position: static; border: 0; }
.aff-soon {
  flex: none;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fef3c7;
  color: #a16207;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.aff-panel-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 6px 14px;
  padding: 12px;
  border-radius: 14px;
  background: #f9fafb;
}
.aff-panel-profile img { width: 40px; height: 40px; border-radius: 999px; object-fit: cover; }
.aff-panel-profile div { display: flex; flex-direction: column; min-width: 0; }
.aff-panel-profile strong { font-size: 14px; color: var(--aff-ink); }
.aff-panel-profile span { font-size: 12px; color: var(--aff-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.aff-shell-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(17, 24, 39, .08);
}
.aff-shell-overlay[hidden] { display: none; }

/* ---------- Header + main ---------- */
.aff-shell-header {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--aff-rail-w);
  z-index: 30;
  height: var(--aff-header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--aff-line);
}
.aff-shell-main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: var(--aff-header-h);
  padding-left: var(--aff-rail-w);
}
.aff-header-icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--aff-muted);
}
.aff-header-icon-btn:hover { background: #f3f4f6; color: var(--aff-brand); }
.aff-header-cta,
.aff-header-credit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .15s ease, box-shadow .15s ease;
}
.aff-header-cta { background: var(--aff-brand); color: #fff; box-shadow: 0 6px 16px -6px rgba(103, 58, 183, .55); }
.aff-header-cta:hover { background: #5e35b1; color: #fff; }
.aff-header-credit { background: var(--aff-brand-soft); color: #512da8; border: 1px solid var(--aff-brand-ring); }
.aff-header-credit:hover { background: #ebe2f8; }
.aff-shell-icon { width: 20px; height: 20px; stroke-width: 1.6; }

@media (max-width: 1023.98px) {
  .aff-shell { transform: translateX(-100%); transition: transform .22s ease; }
  .aff-shell.mobile-open { transform: none; }
  .aff-panel { width: min(var(--aff-panel-w), calc(100vw - var(--aff-rail-w))); }
  .aff-shell-header { left: 0; padding: 0 16px; }
  .aff-shell-main { padding-left: 0; }
}

/* ---------- Instant navigation ---------- */
#aff-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, #8b5cf6, var(--aff-brand));
  box-shadow: 0 0 8px rgba(103, 58, 183, .45);
  opacity: 0;
  pointer-events: none;
}
html.aff-navigating #aff-progress {
  opacity: 1;
  animation: aff-progress 8s cubic-bezier(.08, .7, .2, 1) forwards;
}
@keyframes aff-progress {
  0% { width: 0; }
  10% { width: 45%; }
  100% { width: 92%; }
}

#aff-skeleton {
  position: fixed;
  top: var(--aff-header-h);
  right: 0;
  bottom: 0;
  left: var(--aff-rail-w);
  z-index: 25;
  overflow: hidden;
  padding: 24px;
  background: #f4f6f9;
}
#aff-skeleton[hidden] { display: none; }
@media (max-width: 1023.98px) {
  #aff-skeleton { left: 0; padding: 16px; }
}
/* Public pages have no app header: cover the whole viewport below their own navbar. */
.aff-public #aff-skeleton { top: 0; left: 0; background: #fff; }

.aff-sk-wrap { max-width: 1600px; margin: 0 auto; display: grid; gap: 20px; }
.aff-sk {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: #e2e6ed;
}
.aff-sk::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent);
  animation: aff-shimmer 1.1s infinite;
}
@keyframes aff-shimmer { 100% { transform: translateX(100%); } }
.aff-sk-card { background: #fff; border: 1px solid var(--aff-line); border-radius: 18px; padding: 20px; display: grid; gap: 12px; }
.aff-sk-row { display: grid; gap: 20px; }
.aff-sk-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.aff-sk-cols-2 { grid-template-columns: 2fr 1fr; }
.aff-sk-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .aff-sk-cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .aff-sk-cols-2, .aff-sk-cols-3 { grid-template-columns: 1fr; }
}
.aff-sk-line { height: 12px; }
.aff-sk-title { height: 26px; width: 38%; }
.aff-sk-sub { height: 14px; width: 24%; }
.aff-sk-block { height: 220px; }
.aff-sk-tr { height: 44px; border-radius: 10px; }

@media (prefers-reduced-motion: reduce) {
  .aff-sk::after, html.aff-navigating #aff-progress { animation: none; }
  .aff-panel, .aff-shell { transition: none; }
}

/* Same-origin page changes cross-fade instead of flashing white (Chrome/Edge/Safari 18+). */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: .12s; }
.aff-rail { view-transition-name: aff-rail; }
.aff-shell-header { view-transition-name: aff-header; }

/* Header pieces (own classes: the prebuilt tailwind.css lacks most responsive variants). */
.aff-header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.aff-header-greeting { min-width: 0; }
.aff-header-greeting h2 { font-size: 17px; font-weight: 600; color: var(--aff-ink); letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aff-header-greeting p { font-size: 13px; color: var(--aff-muted); }
.aff-header-right { display: flex; align-items: center; gap: 10px; }
.aff-header-dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border: 2px solid #fff; border-radius: 999px; background: #ef4444; }
.aff-header-avatar-btn { display: flex; padding: 2px; border-radius: 999px; }
.aff-header-avatar-btn img { width: 38px; height: 38px; border-radius: 999px; object-fit: cover; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.aff-header-avatar-btn:hover img { box-shadow: 0 0 0 3px var(--aff-brand-ring); }
.aff-mobile-only { display: none; }
@media (max-width: 1023.98px) { .aff-mobile-only { display: grid; } }
@media (max-width: 640px) {
  .aff-header-greeting, .aff-hide-sm { display: none; }
  .aff-header-cta, .aff-header-credit { padding: 0 11px; }
  .aff-header-right { gap: 6px; }
}
/* The floating chat bubble would sit on top of the open mobile menu. */
body:has(.aff-shell.mobile-open) .chat-icon,
body:has(.aff-shell.panel-open) .chat-icon,
body:has(#chat-box) .chat-icon { display: none; } /* on /support the bubble only links back to the same page */

/* ---------- Page polish: one rhythm for every app page (spacing and type only, layouts unchanged) ---------- */
.aff-shell-body #app-main > div {
  max-width: 1480px;
  padding: 28px 32px 40px;
}
@media (max-width: 1023.98px) {
  .aff-shell-body #app-main > div { padding: 20px 16px 32px; }
}
/* Pages wrap their content in .pc-content with their own side/top padding on top of the frame's;
   keep each page's width but let the frame own the outer spacing. */
.aff-shell-body #app-main .pc-container { padding-bottom: 0; }
.aff-shell-body #app-main .pc-content {
  padding-left: 0 !important;
  padding-right: 0 !important;
  padding-top: 0 !important;
}
.aff-shell-body #app-main .pc-content.max-w-7xl { max-width: none; }

/* Page titles: same size and weight everywhere. */
.aff-shell-body #app-main :is(h1, h2, h3, h4, h5).text-2xl.font-black,
.aff-shell-body #app-main h1:is(.text-2xl, .text-3xl, .text-\[22px\]) {
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -.02em;
}
.aff-shell-body #app-main :is(h1, h2, h3, h4, h5, h6).font-black { font-weight: 700; }
.aff-shell-body #app-main :is(h1, h2, h3, h4, h5, h6).font-extrabold { font-weight: 700; }
/* Breadcrumbs under titles. */
.aff-shell-body #app-main ul.list-none.text-sm:is(.text-gray-500, .text-white\/70) { font-size: 13px; margin-top: 6px; }

/* Cards: one border colour and one soft shadow. */
.aff-shell-body #app-main .bg-white:is(.border-gray-100, .border-gray-200, .border-slate-100, .border-slate-200) { border-color: #e9ebf1; }
.aff-shell-body #app-main .bg-white.shadow-sm { box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .03); }

/* Admin page banners used a blue gradient; keep the banner, use the brand purple. */
.aff-shell-body #app-main .bg-gradient-to-r.from-blue-600 { background-image: linear-gradient(120deg, #5e35b1 0%, #7e57c2 100%); }

/* Inputs: same focus ring on every page. */
.aff-shell-body #app-main :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select, textarea):focus-visible {
  outline: none;
  border-color: #673ab7;
  box-shadow: 0 0 0 3px rgba(103, 58, 183, .15);
}

/* Footer inside the app: same width and side spacing as the content; room on the right for the chat bubble. */
.aff-shell-body #app-main footer > div { max-width: 1480px; padding-left: 32px; padding-right: 88px; }
@media (max-width: 1023.98px) { .aff-shell-body #app-main footer > div { padding-left: 16px; padding-right: 16px; padding-bottom: 56px; } }

/* "Điền theo tỷ lệ" steps (views/components/fill-steps.php). */
.aff-fill-steps { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; padding: 0; list-style: none; }
.aff-fill-steps li { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1px solid #e9ebf1; border-radius: 999px; background: #fff; color: #6b7280; font-size: 13px; font-weight: 500; }
.aff-fill-step-num { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 999px; background: #f3f4f6; font-size: 12px; font-weight: 700; }
.aff-fill-steps li.is-current { border-color: #d6c6f2; background: #f3eefc; color: #4c2a92; font-weight: 600; }
.aff-fill-steps li.is-current .aff-fill-step-num { background: #673ab7; color: #fff; }
.aff-fill-steps li.is-done .aff-fill-step-num { background: #dcfce7; color: #15803d; }
@media (max-width: 640px) { .aff-fill-steps li:not(.is-current) .aff-fill-step-label { display: none; } }

/* Filled dots: these names are missing from the bundled Tabler Icons 1.41 font, so draw them. */
.ti-circle-filled::before, .ti-point-filled::before { content: ""; display: inline-block; width: .72em; height: .72em; border-radius: 50%; background: currentColor; vertical-align: middle; }
.ti-point-filled::before { width: .5em; height: .5em; }
/* Newer Tabler names (e.g. typed into Admin > Gói dịch vụ) mapped to glyphs that exist in the bundled 1.41 font. */
.ti-coins::before { content: '\eb82'; }
.ti-arrow-move-right::before { content: '\ea1f'; }
.ti-brain::before { content: '\ea51'; }
.ti-checklist::before { content: '\eb6a'; }
.ti-clock-dollar::before { content: '\ea70'; }
.ti-clock-x::before { content: '\ea70'; }
.ti-file-description::before { content: '\eaa2'; }
.ti-help-circle::before { content: '\eabf'; }
.ti-inbox-off::before { content: '\eac4'; }
.ti-info-square-rounded::before { content: '\eac6'; }
.ti-layout-sections::before { content: '\ead8'; }
.ti-list-details::before { content: '\eb6b'; }
.ti-loader-2::before { content: '\eca3'; }
.ti-mail-off::before { content: '\eae5'; }
.ti-message-chatbot::before { content: '\eaee'; }
.ti-player-play-filled::before { content: '\ed46'; }
.ti-qrcode-off::before { content: '\eb11'; }
.ti-robot::before { content: '\eaee'; }
.ti-rosette-discount-check::before { content: '\ebbd'; }
.ti-search-off::before { content: '\eb1c'; }
.ti-sparkles::before { content: '\ebcb'; }
.ti-users-plus::before { content: '\eb4b'; }
.ti-transfer::before { content: '\edb0'; }
.ti-user-search::before { content: '\eb4d'; }
.ti-user-circle::before { content: '\eb4d'; }
.ti-fan::before { content: '\ec34'; }
.ti-clock-exclamation::before { content: '\ea05'; }
.ti-shield-edit::before { content: '\eb24'; }
.ti-shield-plus::before { content: '\eb24'; }
.ti-settings-2::before { content: '\eb20'; }
.ti-file-spreadsheet::before { content: '\eba1'; }
.ti-book-2::before { content: '\ea39'; }
.ti-arrows-exchange::before { content: '\edb0'; }
.ti-table-row::before { content: '\eba1'; }
.ti-arrow-big-up-lines::before { content: '\eddd'; }
.ti-database-cog::before { content: '\ea88'; }
.ti-copy-plus::before { content: '\ea7a'; }
.ti-star-filled::before { content: '\eb2e'; }
.ti-layout-dashboard::before { content: '\ea87'; }
.ti-gavel::before { content: '\ebc2'; }
.ti-mail-fast::before { content: '\eeac'; }

/* ---- Help videos (config/help_videos.php, assets/js/help-video.js) ---- */
.aff-help-video-btn { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px 6px 7px; border: 1px solid var(--aff-brand-ring); border-radius: 999px; background: #fff; color: var(--aff-brand); font-size: 13px; font-weight: 600; line-height: 1.2; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.aff-help-video-btn:hover { background: var(--aff-brand-soft); border-color: #cdb8f0; box-shadow: 0 2px 8px rgba(103, 58, 183, .12); }
.aff-help-video-btn:focus-visible { outline: 2px solid var(--aff-brand); outline-offset: 2px; }
.aff-help-video-btn svg { width: 22px; height: 22px; flex: none; }
.aff-help-video-btn small { font-size: 12px; font-weight: 500; color: var(--aff-muted); }
.aff-help-video-btn.is-block { display: flex; width: 100%; justify-content: center; }
dialog.aff-help-video { width: min(1100px, calc(100vw - 24px)); max-width: none; padding: 0; border: 0; border-radius: 16px; background: #0f0a1f; box-shadow: 0 30px 80px rgba(15, 10, 31, .45); }
dialog.aff-help-video::backdrop { background: rgba(15, 10, 31, .72); }
.aff-help-video-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 18px; color: #fff; font-size: 15px; }
.aff-help-video-head b { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aff-help-video-close { display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .1); color: #fff; cursor: pointer; }
.aff-help-video-close:hover { background: rgba(255, 255, 255, .2); }
.aff-help-video-close svg { width: 20px; height: 20px; }
dialog.aff-help-video video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 0 0 16px 16px; }
.aff-hv-thumb { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0; overflow: hidden; background: var(--aff-brand-soft); cursor: pointer; }
.aff-hv-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.aff-hv-thumb:hover img { transform: scale(1.03); }
.aff-hv-play { position: absolute; left: 10px; bottom: 10px; display: flex; width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: 999px; background: var(--aff-brand); color: #fff; font-size: 20px; box-shadow: 0 6px 16px rgba(103, 58, 183, .35); transition: transform .15s; }
.aff-hv-thumb:hover .aff-hv-play { transform: scale(1.1); }
.aff-hv-duration { position: absolute; right: 10px; bottom: 12px; padding: 2px 8px; border-radius: 6px; background: rgba(17, 12, 40, .72); color: #fff; font-size: 12px; font-weight: 600; }
