/* ==========================================================================
   KSM168 Electrical — base: font, reset, tipografi, fokus, form dasar, utilitas, cetak.
   Bergantung pada tokens.css.
   ========================================================================== */

/* ---- Inter Variable (self-host, OFL-1.1; sumber: @fontsource-variable/inter 5.3.0) ---- */
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter/inter-latin-ext-wght-normal.woff2") format("woff2-variations"),
    url("../fonts/inter/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter/inter-latin-wght-normal.woff2") format("woff2-variations"),
    url("../fonts/inter/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Reset modern ---------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  /* Jangkar, scrollIntoView, dan fokus keyboard tidak berhenti di bawah header lengket,
     banner, atau bottom nav / submit bar (nilai per tampilan di layouts.css). */
  scroll-padding-top: calc(var(--chrome-top, 0px) + var(--header-offset, 0px) + var(--space-4));
  scroll-padding-bottom: calc(var(--chrome-bottom, 0px) + var(--space-4));
  hanging-punctuation: first last;
}

@media (prefers-reduced-motion: no-preference) {
  html:focus-within {
    scroll-behavior: smooth;
  }
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-normal);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

img,
picture,
video,
canvas {
  display: block;
  max-width: 100%;
}

img,
video {
  height: auto;
}

svg {
  flex-shrink: 0;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button,
[role="button"],
summary,
label[for],
select {
  cursor: pointer;
}

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
}

textarea {
  resize: vertical;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

fieldset {
  border: 0;
  padding: 0;
  min-width: 0;
}

legend {
  padding: 0;
}

hr {
  border: 0;
  border-top: var(--border-width) solid var(--border);
  margin-block: var(--space-4);
}

[hidden] {
  display: none !important;
}

dialog {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  max-width: none;
  max-height: none;
}

::selection {
  background: var(--accent-subtle-hover);
  color: var(--text);
}

/* ---- Tipografi ------------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--heading);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-2xl);
}

h2 {
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-lg);
}

h4 {
  font-size: var(--text-md);
}

h5,
h6 {
  font-size: var(--text-sm);
}

p {
  text-wrap: pretty;
}

small {
  font-size: var(--text-xs);
}

strong,
b {
  font-weight: var(--weight-semibold);
}

a {
  color: var(--accent-text);
  text-decoration: none;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration: underline;
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre {
  overflow: auto;
  white-space: pre;
}

abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

/* ---- Fokus keyboard -------------------------------------------------- */
:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ---- Form dasar ------------------------------------------------------ */
::placeholder {
  color: var(--text-subtle);
  opacity: 1;
}

/* iOS tidak auto-zoom bila font input >= 16px */
@media (pointer: coarse) {
  input,
  select,
  textarea {
    font-size: max(1rem, 16px);
  }
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* ---- Ikon sprite (kontrak 8) ----------------------------------------- */
.icon {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
  flex-shrink: 0;
  vertical-align: -0.25em;
  overflow: visible;
}

.icon--xs {
  width: 0.75rem;
  height: 0.75rem;
}

.icon--sm {
  width: 1rem;
  height: 1rem;
}

.icon--lg {
  width: 1.5rem;
  height: 1.5rem;
}

.icon--xl {
  width: 2rem;
  height: 2rem;
}

.icon--2xl {
  width: 3rem;
  height: 3rem;
}

.icon--spin {
  animation: ksm-spin 0.9s linear infinite;
}

@keyframes ksm-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- Skip link ------------------------------------------------------- */
.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-progress);
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: var(--weight-semibold);
  transform: translateY(-200%);
  transition: transform var(--duration-fast) var(--ease-standard);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: none;
  text-decoration: none;
}

/* ---- Utilitas -------------------------------------------------------- */
.visually-hidden,
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stack--xs {
  gap: var(--space-1);
}

.stack--sm {
  gap: var(--space-2);
}

.stack--md {
  gap: var(--space-3);
}

.stack--lg {
  gap: var(--space-6);
}

.stack--xl {
  gap: var(--space-8);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.cluster--xs {
  gap: var(--space-1);
}

.cluster--lg {
  gap: var(--space-4);
}

.cluster--between {
  justify-content: space-between;
}

.cluster--end {
  justify-content: flex-end;
}

.cluster--start {
  align-items: flex-start;
}

.cluster--nowrap {
  flex-wrap: nowrap;
  min-width: 0;
}

.grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}

.grid--2,
.grid--3,
.grid--4 {
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 640px) {
  .grid--2,
  .grid--3,
  .grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.flex-1 {
  flex: 1 1 0%;
  min-width: 0;
}

.w-full {
  width: 100%;
}

.text-muted {
  color: var(--text-muted);
}

.text-subtle {
  color: var(--text-subtle);
}

.text-xs {
  font-size: var(--text-xs);
}

.text-sm {
  font-size: var(--text-sm);
}

.text-md {
  font-size: var(--text-md);
}

.text-lg {
  font-size: var(--text-lg);
}

.text-xl {
  font-size: var(--text-xl);
}

.font-medium {
  font-weight: var(--weight-medium);
}

.font-semibold {
  font-weight: var(--weight-semibold);
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.tabular-nums,
.num {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
}

.nowrap {
  white-space: nowrap;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.list-reset {
  list-style: none;
  padding: 0;
}

@media (max-width: 767.98px) {
  .hide-mobile {
    display: none !important;
  }
}

@media (min-width: 768px) {
  .hide-desktop {
    display: none !important;
  }
}

/* ---- Gerak minimal --------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* Indikator memuat tetap berputar pelan agar tidak terlihat macet. */
  .spinner,
  .icon--spin {
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }
}

/* ---- Cetak ----------------------------------------------------------- */
@media print {
  @page {
    margin: 12mm;
  }

  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --text: #000000;
    --text-muted: #333333;
    --border: #999999;
  }

  html,
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .no-print,
  .sidebar,
  .sidebar-scrim,
  .topbar,
  .bottom-nav,
  .submit-bar,
  .toast-region,
  .banner,
  .top-progress,
  .skip-link,
  .m-header__back,
  .easy-bar__actions {
    display: none !important;
  }

  .card,
  .table tr,
  .stat {
    break-inside: avoid;
  }

  .card,
  .stat {
    box-shadow: none !important;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #333333;
  }
}
