/* KingRockOTP — compatibility layer for pages with local color tokens */
html[data-theme="dark"] {
  color-scheme: dark;

  /* Shared tokens, declared with higher specificity than page-local :root rules. */
  --bg: #0B1220;
  --bg2: #111827;
  --surface: #111827;
  --surface2: #1F2937;
  --border: #263449;
  --text: #E6EDF3;
  --muted: #94A3B8;
  --accent: #60A5FA;
  --accent-d: #3B82F6;
  --accent2: #38BDF8;
  --blue: #60A5FA;
  --green: #60A5FA;
  --green-d: #93C5FD;
  --green-xl: #1E3A5F;
  --amber: #FBBF24;
  --red: #F87171;
  --purple: #A5B4FC;
  --shadow: 0 4px 20px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.50);
  --header-bg: rgba(11,18,32,.92);
  --nav-bg: rgba(17,24,39,.96);
  --card-hover: #1B2434;

  /* Admin page tokens. */
  --s: #111827;
  --s2: #1F2937;
  --br: #263449;
  --tx: #E6EDF3;
  --mu: #94A3B8;

  /* Aplikasi and hosting page tokens. */
  --a-bg: #0B1220;
  --a-surface: #111827;
  --a-card: #111827;
  --a-border: #263449;
  --a-text: #E6EDF3;
  --a-muted: #94A3B8;
  --a-shadow: 0 8px 28px rgba(0,0,0,.28);
  --h-bg: #0B1220;
  --h-surface: #111827;
  --h-card: #111827;
  --h-border: #263449;
  --h-text: #E6EDF3;
  --h-muted: #94A3B8;
  --h-shadow: 0 8px 28px rgba(0,0,0,.28);

  /* NOKOS page's separate green-scale tokens. */
  --g50: #0B1220;
  --g100: #172338;
  --g300: #31425D;
  --g400: #60A5FA;
  --g500: #3B82F6;
  --g600: #60A5FA;
  --g700: #93C5FD;
  --g800: #BFDBFE;
  --g900: #E6EDF3;
  --danger-soft: #3B1B20;
  --amber-soft: #3C2D10;
}

html[data-theme="dark"] body {
  background-color: var(--bg);
  color: var(--text);
}

/* Common surfaces shared by marketplace, account, history, and utility pages. */
html[data-theme="dark"] :is(
  .card, .tool-card, .status-card, .chart-card, .trx-card, .stat-card,
  .ep-card, .service-card, .product, .order, .download-card, .instructions,
  .modal-box, .modal-content, .mbox, .mcard, .chbox, .tbox, .lb,
  .stepper-wrap, .timer-card, .dep-pay-caption, .help-note
) {
  background-color: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

html[data-theme="dark"] :is(input, select, textarea, .my-api-key-input, .fi, .mi, .sfi) {
  background-color: var(--surface2);
  border-color: var(--border);
  color: var(--text);
}

html[data-theme="dark"] :is(input, textarea)::placeholder {
  color: #8291A7;
  opacity: 1;
}

html[data-theme="dark"] :is(.page-header, .app-bar, .app-head, .head, .navbar, .bottom-nav) {
  background-color: var(--header-bg);
  border-color: var(--border);
}

html[data-theme="dark"] :is(.tab-btn.active, .seg-btn.active, .tab.active) {
  background-color: var(--surface2);
  color: var(--text);
}

/* Sign-in page alerts and fields. */
html[data-theme="dark"] .alert-error,
html[data-theme="dark"] .banned-notice,
html[data-theme="dark"] .btn-cancel-dep,
html[data-theme="dark"] .status-btn.stop {
  background: rgba(248,113,113,.12);
  border-color: rgba(248,113,113,.30);
  color: #FCA5A5;
}

html[data-theme="dark"] .alert-success {
  background: rgba(59,130,246,.12);
  border-color: rgba(96,165,250,.28);
  color: #BFDBFE;
}

/* API documentation: the API key panel is intentionally light in the original CSS. */
html[data-theme="dark"] .my-api-key-value,
html[data-theme="dark"] #myKeyBox .my-api-key-copy {
  background: #172B48;
  border-color: #31537C;
  color: #BFDBFE;
}
html[data-theme="dark"] .my-api-key-text { color: #BFDBFE; }
html[data-theme="dark"] .my-api-key-input { background: var(--surface2); color: var(--text); }

/* Download Script page had a hard-coded light palette and no theme tokens. */
html[data-theme="dark"] .download-card,
html[data-theme="dark"] .instructions,
html[data-theme="dark"] .footer {
  background: var(--surface);
  border-color: var(--border);
}
html[data-theme="dark"] .download-card h1,
html[data-theme="dark"] .instructions h3,
html[data-theme="dark"] .file-info-table td:last-child {
  color: var(--text);
}
html[data-theme="dark"] .download-card p.subtitle,
html[data-theme="dark"] .file-info-table td:first-child,
html[data-theme="dark"] .instructions ol {
  color: var(--muted);
}
html[data-theme="dark"] .instructions { background: var(--surface2); }

/* Softer status and category chips on dark backgrounds. */
html[data-theme="dark"] :is(.s-ok, .badge.completed, .ep-method.get) {
  background: rgba(34,197,94,.14);
  color: #86EFAC;
}
html[data-theme="dark"] :is(.s-pnd, .badge.processing, .badge.pending, .badge.in_progress, .ep-method.post) {
  background: rgba(59,130,246,.16);
  color: #BFDBFE;
}
html[data-theme="dark"] :is(.s-can, .badge.partial, .badge.canceled) {
  background: rgba(245,158,11,.14);
  color: #FCD34D;
}
html[data-theme="dark"] :is(.trx-ico, .trx-ico.dep, .modal-key) {
  background: rgba(59,130,246,.14);
}

html[data-theme="dark"] .empty-ico { color: #475569; }
html[data-theme="dark"] .status-btn.stop:hover,
html[data-theme="dark"] .btn-cancel-dep:hover { background: rgba(248,113,113,.2); }

@media (prefers-reduced-motion: reduce) {
  html[data-theme] *, html[data-theme] *::before, html[data-theme] *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}


/* Prevent a second gray surface inside already-styled field containers.
   The outer wrapper owns the background; nested controls stay transparent. */
html[data-theme="dark"] body .auth-box .input-wrap > input,
html[data-theme="dark"] body .input-box > input,
html[data-theme="dark"] body .input-box > select,
html[data-theme="dark"] body .search-box > input,
html[data-theme="dark"] body .search-picker-control > input {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  caret-color: var(--text);
}

/* NOKOS search fields are standalone controls, so keep one unified dark fill. */
html[data-theme="dark"] body .search-input {
  background-color: var(--g50, var(--bg)) !important;
  color: var(--text);
}

/* Keep Chrome's saved-credential autofill legible without a bright browser fill. */
html[data-theme="dark"] body .auth-box .input-wrap > input:-webkit-autofill {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset !important;
  caret-color: var(--text);
}
html[data-theme="dark"] body .input-box > input:-webkit-autofill {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset !important;
  caret-color: var(--text);
}
