/*
MIT License

Copyright (c) 2023 Uiverse.io

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/*
 * Adapted from uiverse-io/galaxy at adbd2adde0a299a3956ea288fb444ec01891ca41.
 * Buttons/krlozCJ_blue-dodo-17.html — press depth / shadow
 * Checkboxes/G4b413l_smooth-duck-62.html — border-to-check transition
 * loaders/mrhyddenn_massive-newt-28.html — rotating ring
 * Exact sources and original copies: third-party/galaxy/.
 * Finance adaptations: semantic colors, smaller travel, native focus/validation,
 * actual request state, disabled controls, reduced motion and touch sizing.
 */

/* Press feedback, adapted from krlozCJ. */
.button {
  border-radius: 9px;
  min-height: 40px;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
  box-shadow: 0 2px 0 var(--line-strong);
}
.button.primary { box-shadow: 0 2px 0 var(--brand-action-hover, var(--brand-dark)), 0 3px 8px rgb(25 46 95 / 10%); }
.button.ghost { box-shadow: none; }
.button:active:not(:disabled):not([aria-disabled="true"]) {
  transform: translateY(2px);
  box-shadow: 0 0 0 transparent;
}
.button:focus-visible, .customer-card:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
}
.button:disabled { cursor: not-allowed; transform: none; box-shadow: none; }
.button[aria-busy="true"] { cursor: progress; opacity: .85; }
.button.small { min-height: 32px; }

/* Ring from mrhyddenn. Text stays present even when motion is reduced. */
.galaxy-loader, .button[aria-busy="true"]::before {
  content: "";
  display: inline-block;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: galaxy-ring 1.2s linear infinite;
}
.galaxy-loader { width: 28px; height: 28px; border-width: 3px; color: var(--brand); }
@keyframes galaxy-ring { to { transform: rotate(360deg); } }
.galaxy-loading { display: flex; align-items: center; gap: 16px; padding: 32px 0; color: var(--ink); }
.galaxy-loading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.galaxy-loading h2 { margin: 0; }

/* Border-to-check feedback from G4b413l, retaining a real required checkbox. */
.galaxy-check-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 16px;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.galaxy-check-card input[type="checkbox"] {
  position: absolute;
  left: 12px;
  top: calc(50% - 16px);
  width: 32px;
  height: 32px;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.galaxy-checkmark {
  display: block;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 2px solid var(--muted);
  border-radius: 6px;
  transition: transform .3s ease, width .3s ease, margin .3s ease, border-color .3s ease, border-radius .3s ease;
  pointer-events: none;
}
.galaxy-check-card input:checked + .galaxy-checkmark {
  transform: translateY(-3px) rotate(45deg);
  width: 13px;
  margin-left: 5px;
  margin-right: 4px;
  border-width: 3px;
  border-color: var(--brand);
  border-top-color: transparent;
  border-left-color: transparent;
  border-radius: 0;
}
.galaxy-check-card:has(input:checked) { border-color: var(--brand); background: var(--brand-light); }
.galaxy-check-card:has(input:focus-visible) { outline: 3px solid var(--brand); outline-offset: 3px; }
.galaxy-check-copy { display: grid; gap: 5px; min-width: 0; }
.galaxy-check-copy strong { color: var(--ink); font-size: 14px; }
.galaxy-check-copy small { color: var(--muted); font-size: 12px; line-height: 1.7; }

/* Project-specific companion states, kept separate from the upstream components. */
.customer-card { position: relative; min-width: 0; transition: border-color .2s ease, background .2s ease, box-shadow .2s ease, transform .15s ease; }
.customer-card.selected { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.customer-card:active { transform: translateY(1px); }
.customer-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.customer-name-text { min-width: 0; overflow-wrap: anywhere; }
.kpi-value, .big-number, .customer-card .amount { max-width: 100%; overflow-x: auto; white-space: nowrap; scrollbar-width: thin; }
.galaxy-selection { display: inline-flex; justify-content: center; align-items: center; flex: 0 0 18px; width: 18px; height: 18px; border: 1px solid var(--line-strong); border-radius: 50%; color: transparent; font-size: 12px; transition: color .18s ease, background .18s ease, border-color .18s ease; }
.customer-card[aria-pressed="true"] .galaxy-selection { color: #fff; background: var(--brand-action, var(--brand)); border-color: var(--brand-action, var(--brand)); }
.customer-card.selected .amount { color: var(--brand); }
.customer-cards .row { flex-wrap: wrap; }
.toast { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 12px; padding: 14px 18px; font-size: 13px; }
.toast-mark { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%; font-size: 14px; font-weight: 700; background: var(--brand-light); color: var(--brand); }
.toast[data-kind="success"] .toast-mark { background: var(--green-light); color: var(--green); }
.toast[data-kind="error"] .toast-mark { background: var(--red-light); color: var(--red); }
.appearance-picker { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.appearance-picker select { min-height: 36px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 8px; background: var(--surface); color: var(--ink-soft); font: inherit; }
.auth-appearance { flex-direction: row !important; justify-content: flex-end; margin: 0 0 16px !important; }
.auth-appearance select { width: auto; min-height: 36px; padding: 6px 8px; }
@media (hover: hover) {
  .button:hover:not(:disabled) { filter: brightness(.98); }
  .galaxy-check-card:hover, .customer-card:hover { border-color: var(--brand); }
}
@media (max-width: 600px) {
  .button { min-height: 44px; }
  .button.small { min-height: 38px; }
  .topbar { flex-wrap: wrap; }
  .topbar-actions { flex-wrap: wrap; }
  .appearance-picker select { min-height: 36px; max-width: 102px; }
  .wf-actions .button { min-height: 44px; }
  .customer-cards, .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .customer-card { padding: 16px; }
  .customer-card .amount { margin: 8px 0; }
  .kpi-value { font-size: clamp(22px, 6vw, 28px); }
  dialog.modal.wf-dialog { width: 100%; max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .galaxy-loader, .button[aria-busy="true"]::before { animation: none; }
  .button, .galaxy-checkmark, .galaxy-check-card, .galaxy-selection, .customer-card { transition: none; }
  .button:active:not(:disabled), .customer-card:active { transform: none; }
}
@media (forced-colors: active) {
  .galaxy-check-card:has(input:checked), .customer-card.selected { border-color: Highlight; }
  .galaxy-check-card input:checked + .galaxy-checkmark { border-right-color: Highlight; border-bottom-color: Highlight; }
  .customer-card[aria-pressed="true"] .galaxy-selection { color: HighlightText; background: Highlight; forced-color-adjust: none; }
}
@media print { .appearance-picker, .galaxy-loading { display: none; } }
