
/* ARK UI UNIFIED V7 */

:root {
  --ark-ui-scroll: var(--accent, #e11d2e);
  --ark-ui-scroll-track: transparent;
  --ark-ui-control: 16px;
}

/* ===================================================
   SCROLLBAR - TAT CA VUNG CUON
   =================================================== */

html,
body,
body *:not(svg):not(svg *) {
  scrollbar-width: thin;
  scrollbar-color:
    var(--ark-ui-scroll)
    var(--ark-ui-scroll-track);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: transparent;
}

::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

::-webkit-scrollbar-thumb {
  background: color-mix(
    in srgb,
    var(--ark-ui-scroll) 66%,
    transparent
  );

  border: 2px solid transparent;
  border-radius: 99px;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ark-ui-scroll);
  background-clip: padding-box;
}

/* Vung cuon ben trong tab, dialog, JSON */

:where(
  textarea,
  pre,
  code,
  .mono,
  .pending-item,
  dialog,
  [role="dialog"],
  [role="tabpanel"],
  .table-wrap,
  .table-responsive,
  .scroll-area,
  .scrollbox
) {
  overscroll-behavior: contain;
}

:where(
  #tabs,
  .subtabs,
  .sub-tabs,
  .subnav,
  .sub-nav,
  .tab-list,
  .tabs-sm,
  .pill,
  .modes,
  [role="tablist"]
) {
  max-width: 100%;
  scrollbar-width: thin;
  scrollbar-color:
    var(--ark-ui-scroll) transparent;
}

:where(
  .subtabs,
  .sub-tabs,
  .subnav,
  .sub-nav,
  .tab-list,
  .tabs-sm,
  [role="tablist"]
) {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

/* ===================================================
   FORM, CHECKBOX, RADIO, SELECT
   =================================================== */

:where(button, input, select, textarea) {
  font-family:
    "Be Vietnam Pro",
    system-ui,
    sans-serif;
}

:where(
  input[type="checkbox"],
  input[type="radio"]
) {
  box-sizing: border-box !important;

  width: var(--ark-ui-control) !important;
  height: var(--ark-ui-control) !important;

  min-width: var(--ark-ui-control) !important;
  min-height: var(--ark-ui-control) !important;

  max-width: var(--ark-ui-control) !important;

  padding: 0 !important;
  margin: 0 !important;

  flex: 0 0 var(--ark-ui-control) !important;

  accent-color:
    var(--accent, #e11d2e) !important;

  appearance: auto !important;
  cursor: pointer;
  vertical-align: middle;
}

:where(
  input[type="checkbox"],
  input[type="radio"]
):focus-visible {
  outline: 2px solid var(--accent, #e11d2e);
  outline-offset: 3px;
}

:where(input[type="range"]) {
  accent-color: var(--accent, #e11d2e);
  cursor: pointer;
}

/* Mui ten select thong nhat */

:where(
  select:not([multiple]):not([size])
) {
  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='%239b9294' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"
  );

  background-repeat: no-repeat;
  background-size: 16px;
  background-position: right 10px center;
  padding-right: 34px;
}

:where(details > summary)::marker {
  color: var(--accent, #e11d2e);
}

/* Focus cho tat ca dieu khien */

:where(
  button,
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea,
  a,
  summary
):focus-visible {
  outline: 2px solid var(--accent, #e11d2e);
  outline-offset: 2px;
}

:where(
  button,
  select,
  [role="tab"],
  summary
) {
  touch-action: manipulation;
}

:where(
  button,
  select,
  [role="tab"]
) {
  min-height: 30px;
}

:where(button) svg,
:where(button) .lucide,
:where(.icon-btn) svg {
  width: 1.1em;
  height: 1.1em;
  flex: none;
}

:where(summary) {
  cursor: pointer;
}

/* Checkbox PKCE nam ngang voi nhan */

#fields .fld:has(
  > input[type="checkbox"]
) {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;

  gap: 12px !important;
  min-height: 40px;
}

#fields .fld:has(
  > input[type="checkbox"]
) > span {
  line-height: 1.5;
  flex: 0 1 auto;
}

/* ===================================================
   CAC TAB NHO - MAU ACTIVE CHUNG
   =================================================== */

:where(
  .subtabs,
  .sub-tabs,
  .subnav,
  .sub-nav,
  .tabs-sm,
  [role="tablist"]
)
:is(button, [role="tab"])
[aria-selected="true"],

:where(
  .subtabs,
  .sub-tabs,
  .subnav,
  .sub-nav,
  .tabs-sm
)
button:is(.active, .on) {
  color: var(--on-accent, #fff);
  background: var(--accent, #e11d2e);
  border-radius: 9px;
}

/* ===================================================
   DIALOG - EDITOR, AI SETUP, DOC THU
   =================================================== */

:where(
  dialog[open],
  [role="dialog"][open]
) {
  overflow-x: hidden;
  overflow-y: auto;

  max-width: calc(100vw - 24px);
  max-height: min(84dvh, 850px);

  scrollbar-gutter: stable;
}

:where(
  dialog textarea,
  dialog pre,
  .pending-item pre,
  #readOutput
) {
  overflow: auto;
  scrollbar-gutter: stable;
}

html.ark-conn-embedded body {
  scrollbar-width: none;
}

/* ===================================================
   TOAST - MOT GIAO DIEN CHO TAT CA CAC TRANG
   =================================================== */

html body :is(
  #toasts,
  #arkHostToasts
) {
  position: fixed;

  right: 16px;
  bottom: max(
    16px,
    env(safe-area-inset-bottom)
  );

  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;

  width: min(390px, calc(100vw - 32px));
  z-index: 2147483640;

  pointer-events: none;
}

html body :is(
  #toasts,
  #arkHostToasts
) > :is(
  .toast,
  .ark-ut,
  .ark-host-toast
) {
  --c1: #3b82f6;
  --c2: #06b6d4;
  --c3: #8b5cf6;

  pointer-events: auto;
  position: relative;
  box-sizing: border-box;
  overflow: hidden;

  min-width: 0;
  width: 100%;
  max-width: 100%;

  display: grid;

  grid-template-columns:
    26px minmax(0, 1fr) auto 20px;

  grid-template-areas:
    "ti tk tt tx"
    "ti tm tm tm";

  gap: 4px 10px;
  align-items: start;

  padding: 13px 11px 17px 13px;

  border: 2px solid transparent;
  border-radius: 16px;

  color: var(--ink, #f4f1f1);

  font:
    14px/1.45 "Be Vietnam Pro",
    system-ui,
    sans-serif;

  background:
    linear-gradient(
      var(--surface, #18181b),
      var(--surface, #18181b)
    ) padding-box,

    conic-gradient(
      from var(--ang, 0deg),
      var(--c1),
      var(--c2),
      var(--c3),
      var(--c1)
    ) border-box;

  box-shadow:
    0 14px 40px #0007,
    0 0 24px
      color-mix(
        in srgb,
        var(--c1) 25%,
        transparent
      );
}

/* Thanh cong */

html body :is(
  #toasts,
  #arkHostToasts
) > :is(
  .toast,
  .ark-ut,
  .ark-host-toast
):is(.ok, .save) {
  --c1: #22c55e;
  --c2: #2dd4bf;
  --c3: #a3e635;
}

/* Loi */

html body :is(
  #toasts,
  #arkHostToasts
) > :is(
  .toast,
  .ark-ut,
  .ark-host-toast
).err {
  --c1: #ff3b30;
  --c2: #ff9f1c;
  --c3: #e11d2e;
}

/* Canh bao / Xac nhan */

html body :is(
  #toasts,
  #arkHostToasts
) > :is(
  .toast,
  .ark-ut,
  .ark-host-toast
):is(.warn, .ask) {
  --c1: #f59e0b;
  --c2: #fbbf24;
  --c3: #ef4444;
}

/* Tai khoan */

html body :is(
  #toasts,
  #arkHostToasts
) > :is(
  .toast,
  .ark-ut,
  .ark-host-toast
).auth {
  --c1: #8b5cf6;
  --c2: #06b6d4;
  --c3: #ec4899;
}

/* Index cu co .tb bao ngoai */

html body :is(
  #toasts,
  #arkHostToasts
) > .toast .tb {
  display: contents;
}

/* Toast icon */

html body :is(
  #toasts,
  #arkHostToasts
) :is(
  .ti,
  .ark-ti,
  .toast-icon
) {
  grid-area: ti;

  display: grid;
  place-items: center;

  width: 26px;
  height: 26px;
  color: var(--c1);
}

html body :is(
  #toasts,
  #arkHostToasts
) :is(
  .ti,
  .ark-ti,
  .toast-icon
) svg {
  width: 26px;
  height: 26px;
}

/* Tieu de */

html body :is(
  #toasts,
  #arkHostToasts
) :is(
  .tk,
  .ark-tk,
  .toast-title
) {
  grid-area: tk;

  font-size: 11px;
  font-weight: 800;
  line-height: 1.5;

  text-transform: uppercase;
  letter-spacing: .07em;

  color: var(--c1);
  align-self: center;
}

/* Noi dung */

html body :is(
  #toasts,
  #arkHostToasts
) :is(
  .tm,
  .ark-tm,
  .toast-msg
) {
  grid-area: tm;

  min-width: 0;
  margin: 0;

  font-size: 13px;

  overflow-wrap: anywhere;
  overflow: auto;
  max-height: 12em;
}

/* Thoi gian */

html body :is(
  #toasts,
  #arkHostToasts
) :is(
  .tt,
  .ark-tt
) {
  grid-area: tt;

  color: var(--muted, #a3999a);

  font:
    12px/1.5 ui-monospace,
    monospace;

  align-self: center;
}

/* Nut dong */

html body :is(
  #toasts,
  #arkHostToasts
) :is(
  .tx,
  .ark-tx,
  .toast-close
) {
  grid-area: tx;

  justify-self: end;
  align-self: center;

  width: 22px;
  height: 24px;
  min-height: 0;

  padding: 0 !important;

  color: var(--muted, #a3999a);
  background: transparent;
  border: 0;

  cursor: pointer;

  font: 20px/1 system-ui, sans-serif;
  text-align: center;
}

html body :is(
  #toasts,
  #arkHostToasts
) :is(
  .tx,
  .ark-tx,
  .toast-close
):hover {
  color: var(--ink, #fff);
  background: var(--raise, #232327);
}

/* Thanh tien do */

html body :is(
  #toasts,
  #arkHostToasts
) :is(
  .tbar,
  .ark-tbar,
  .toast-bar,
  .progress
) {
  position: absolute;

  left: 0;
  bottom: 0;

  width: 100%;
  height: 4px;

  background:
    linear-gradient(
      90deg,
      var(--c1),
      var(--c2),
      var(--c3)
    );

  transform-origin: left;
  pointer-events: none;
}

/* Giu cac nut xac nhan */

html body :is(
  #toasts,
  #arkHostToasts
) .toast.ask :is(
  .dlg-b,
  .dlg-i,
  .dl,
  .toast-btns
) {
  grid-column: 2 / -1;
  max-width: 100%;
}

html body :is(
  #toasts,
  #arkHostToasts
) .toast.ask .dlg-b {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (
  prefers-reduced-motion: reduce
) {
  html body :is(
    #toasts,
    #arkHostToasts
  ) > :is(
    .toast,
    .ark-ut,
    .ark-host-toast
  ) {
    animation-duration: .01ms !important;
  }
}

@media (max-width: 640px) {
  :where(dialog[open]) {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
  }
}
