/* ==========================================================
   Pepla WMS - unified stylesheet
   Built from the five page files with no visual change.
   Rules shared by all five pages are unscoped; every other
   rule is scoped to the pages that had it, via data-page.
   ========================================================== */

@keyframes fadeIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }

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

@keyframes pulse { 0%,100% { opacity:0.4; } 50% { opacity:0.9; } }

/* ---------- shared by all five pages ---------- */

/* Dark mode is neutral gray, YouTube's bg and surface (Mustafa, 2026-10-17);
   it was navy-purple (#0f0f1a / #1a1a2e). :root and [data-theme="dark"]
   carry the same values. */

:root {
  --bg: #0f0f0f;
  --surface: #212121;
  --surface2: #181818;
  --border: rgba(255,255,255,0.12);
  --accent: #D5A999;
  --accent-hover: #CC9783;
  --accent-active: #BE8974;
  --accent-light: #D7BFB6;
  --text: #f1f1f1;
  --text-muted: #aaaaaa;
  --text-placeholder: rgba(241,241,241,0.4);
  --text-disabled: rgba(241,241,241,0.3);
  --success: #4ade80;
  --error: #f87171;
  --warning: #fbbf24;
  --info: #c084fc;
  --processing: #60a5fa;
  --overlay: rgba(0,0,0,0.65);
  --disabled-bg: rgba(255,255,255,0.02);
  --disabled-border: rgba(255,255,255,0.06);
  --hover-bg: rgba(255,255,255,0.03);
  --radius: 12px;
  --radius-sm: 8px;
  --on-accent: #0f0f0f;
}

:root {
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --duration-slow: 300ms;
  --ease: cubic-bezier(0.4,0,0.2,1);
}

[data-theme="dark"] {
  --bg: #0f0f0f;
  --surface: #212121;
  --surface2: #181818;
  --border: rgba(255,255,255,0.12);
  --accent: #D5A999;
  --accent-hover: #CC9783;
  --accent-active: #BE8974;
  --accent-light: #D7BFB6;
  --text: #f1f1f1;
  --text-muted: #aaaaaa;
  --text-placeholder: rgba(241,241,241,0.4);
  --text-disabled: rgba(241,241,241,0.3);
  --success: #4ade80;
  --error: #f87171;
  --warning: #fbbf24;
  --info: #c084fc;
  --processing: #60a5fa;
  --overlay: rgba(0,0,0,0.65);
  --disabled-bg: rgba(255,255,255,0.02);
  --disabled-border: rgba(255,255,255,0.06);
  --hover-bg: rgba(255,255,255,0.03);
  --radius: 12px;
  --radius-sm: 8px;
  --on-accent: #0f0f0f;
}

[data-theme="light"] {
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --surface2: #F5F3EF;
  --border: #E8E5DF;
  --accent: #B16043;
  --accent-hover: #9B543A;
  --accent-active: #854832;
  --accent-light: #C2795F;
  --text: #1A1A1A;
  --text-muted: #6B6560;
  --text-placeholder: rgba(26,26,26,0.35);
  --text-disabled: rgba(26,26,26,0.3);
  --success: #15803D;
  --error: #DC2626;
  --warning: #B45309;
  --info: #7C3AED;
  --processing: #2563EB;
  --overlay: rgba(0,0,0,0.4);
  --disabled-bg: rgba(0,0,0,0.02);
  --disabled-border: rgba(0,0,0,0.06);
  --hover-bg: rgba(0,0,0,0.02);
  --radius: 12px;
  --radius-sm: 8px;
  --on-accent: #FFFFFF;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  -webkit-tap-highlight-color: transparent;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

[data-theme="dark"] body {
  background-image: radial-gradient(ellipse at 20% 20%, rgba(192,132,252,0.06) 0%, transparent 50%), radial-gradient(ellipse at 80% 80%, rgba(213,169,153,0.07) 0%, transparent 50%);
  background-attachment: fixed;
}

svg {
  display: block;
}

.ms-wrap {
  position: relative;
}

.ms-trigger:disabled {
  opacity: 0.55;
  cursor: wait;
}

.ms-wrap.open .ms-trigger {
  border-color: var(--accent);
}

.ms-wrap.open .select-chevron {
  transform: translateY(-50%) rotate(180deg);
}

.ms-wrap.open .ms-panel {
  display: block;
}

.ms-option:hover {
  background: var(--hover-bg);
}

.ms-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ms-box svg {
  width: 11px;
  height: 11px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--duration-fast) ease, transform var(--duration-fast) ease;
}

.ms-option.checked .ms-box {
  background: var(--accent);
  border-color: var(--accent);
}

.ms-option.checked .ms-box svg {
  opacity: 1;
  transform: scale(1);
}

.ms-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  text-align: left;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 38px 12px 14px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans',sans-serif;
  font-size: 13px;
  min-height: 44px;
  cursor: pointer;
  transition: border-color var(--duration-base) ease;
}

.ms-value {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms-panel {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  max-height: 264px;
  overflow-y: auto;
  padding: 6px;
}

.ms-option {
  display: flex;
  align-items: center;
  text-align: left;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-family: 'DM Sans',sans-serif;
  font-size: 13px;
  color: var(--text);
  transition: background var(--duration-fast) ease;
}

.ms-box {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-accent);
  transition: background var(--duration-base) ease, border-color var(--duration-base) ease;
}

.ms-order {
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Sans',sans-serif;
  font-weight: 600;
  font-size: 10px;
}

.ms-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms-empty {
  padding: 12px 10px;
  font-family: 'DM Sans',sans-serif;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- page: transfer ---------- */

.ms-value.is-placeholder {
  color: var(--text-placeholder);
}

.ms-wrap .select-chevron {
  transition: transform var(--duration-base) ease;
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* ==========================================================================
   [Item 77] LAST IN THE FILE, ON PURPOSE - DO NOT MOVE THIS BLOCK UP.
   Page rules give :disabled their own opacity at the SAME specificity
   (.big-btn 0.35, .create-btn 0.35),
   so whichever comes last wins. In V48, when this block sat higher, the
   confirm sheet's Yes button rendered at 0.35. Being last - plus !important on
   opacity, measured necessary on the login page - is what makes every waiting
   button fade by the same amount on all five pages.
   NO data-page prefix, deliberately: this is the one component that must look
   the same everywhere (Item 72).
   ========================================================================== */

/* [Item 77 - Mustafa, 2026-09-13] PATTERN A: THE WORDS STAY.
   A waiting button keeps its words; the spinner takes the leading icon's place,
   or sits just before the words when there is no icon. setBtnLoading in
   common.js locks the button's size, hides the icon (keeping its space) and
   writes where the spinner goes into --wss-spin-x / --wss-spin-y. Without those
   the spinner falls back to the centre.
   The spinner is drawn in currentColor. V48's pattern hid the words by making
   the text transparent, so the spinner could not inherit and needed a hand-kept
   list of accent-filled classes (1.80:1 and 1.12:1 were measured before that
   list existed). The words are visible now, so the spinner in the same ink is
   exactly as legible as the words on every surface and in both themes. */

.is-loading {
  pointer-events: none;
  cursor: default;
  opacity: 0.65 !important;
  transition: none !important;
}

.is-loading::after {
  content: "";
  position: absolute;
  left: var(--wss-spin-x, 50%);
  top: var(--wss-spin-y, 50%);
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  box-sizing: border-box;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  pointer-events: none;
  animation: spin 0.7s linear infinite;
}

/* visibility, not display: the icon keeps its space, so nothing moves. */

.wss-icon-hidden {
  visibility: hidden !important;
}

/* ---------- shared by dashboard / scanner / transfer / settings ---------- */

/* One write at a time (common.js): while a write is at the server every other
   control is dimmed and its click is dropped. The button that was pressed keeps
   its own spinner, and the side menu stays live. The 150ms delay keeps a write
   that answers at once - the median is 0.34s - from flashing the whole page. */

html.wss-locked :is(button, a, [onclick]):not([aria-busy="true"], .menu-toggle, .side-menu *, .side-menu-drawer *) {
  cursor: not-allowed;
}

html.wss-locked button:not([aria-busy="true"], .menu-toggle, .side-menu *, .side-menu-drawer *) {
  opacity: 0.45;
  transition: opacity 120ms ease 150ms;
}
