/* ==========================================================================
   ui-kit.css
   Application-wide finishing layer, injected into every HTML page after the
   page's own stylesheets (see includes/theme_loader.php).

   Scope: only presentation that must be identical on every screen — focus
   visibility, scrollbars, text selection, small typographic defaults and
   micro-interactions. Layout, spacing and density stay with the page owners
   (center-compact.css, report-standard.css, workspace-shell.css).
   ========================================================================== */

:root {
    --ui-radius-sm: 6px;
    --ui-radius-md: 8px;
    --ui-radius-lg: 10px;
    --ui-ring: color-mix(in srgb, var(--app-primary, #2563eb) 38%, white);
    --ui-scroll-thumb: #cbd5e1;
    --ui-scroll-thumb-hover: #94a3b8;
}

/* ---------- Text selection ---------- */
::selection {
    background: color-mix(in srgb, var(--app-primary, #2563eb) 24%, white);
    color: #0f172a;
}

/* ---------- Focus visibility ----------
   Keyboard users get an unmistakable ring; pointer users do not see it. */
:where(a, button, [role="button"], summary, [tabindex]):focus-visible {
    outline: 2px solid var(--ui-ring);
    outline-offset: 2px;
    border-radius: var(--ui-radius-sm);
}

:where(input, select, textarea, .form-control, .form-select):focus-visible {
    outline: none;
}

/* Checkboxes and radios keep the browser's reliable focus ring. */
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    outline: 2px solid var(--ui-ring);
    outline-offset: 1px;
}

/* ---------- Scrollbars ---------- */
:where(.table-responsive, .rp-list, .leftmenu, .modal-body, .card-body, textarea) {
    scrollbar-color: var(--ui-scroll-thumb) transparent;
    scrollbar-width: thin;
}

:where(.table-responsive, .rp-list, .leftmenu, .modal-body, .card-body, textarea)::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

:where(.table-responsive, .rp-list, .leftmenu, .modal-body, .card-body, textarea)::-webkit-scrollbar-track {
    background: transparent;
}

:where(.table-responsive, .rp-list, .leftmenu, .modal-body, .card-body, textarea)::-webkit-scrollbar-thumb {
    background: var(--ui-scroll-thumb);
    border: 2px solid transparent;
    border-radius: 99px;
    background-clip: content-box;
}

:where(.table-responsive, .rp-list, .leftmenu, .modal-body, .card-body, textarea)::-webkit-scrollbar-thumb:hover {
    background: var(--ui-scroll-thumb-hover);
    background-clip: content-box;
}

/* ---------- Typography defaults ----------
   Pages that set their own sizes keep them; this only settles the base. */
body {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration-thickness: from-font;
    text-underline-offset: 2px;
}

a:hover { text-decoration-color: currentColor; }

/* Numbers in money columns line up when tabular figures are available. */
.table td.text-end,
.table th.text-end,
.amount,
.amt,
.rp-amt,
.stat-value,
.exec-kpi-value,
.summary-value {
    font-variant-numeric: tabular-nums;
}

/* ---------- Micro-interactions ---------- */
.btn,
.btn-pro,
.app-btn,
.quick-action,
.stat-card,
.card,
.filter-btn {
    transition: background-color .16s ease, border-color .16s ease,
                box-shadow .16s ease, color .16s ease, transform .16s ease;
}

.btn:active,
.btn-pro:active,
.app-btn:active {
    transform: translateY(1px);
}

.btn:disabled,
.btn.disabled,
button:disabled {
    cursor: not-allowed;
    opacity: .62;
}

/* Bootstrap's default link-button blue would fight the module themes. */
.btn-link { text-decoration: none; }

/* ---------- Small shared details ---------- */
kbd,
.shortcut-key {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    box-shadow: 0 1px 0 #e2e8f0;
    color: #334155;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .92em;
    padding: 1px 5px;
}

hr {
    border: 0;
    border-top: 1px solid var(--app-border, #e2e8f0);
    margin: 14px 0;
}

/* Native date pickers otherwise render a heavy grey icon. */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: .55;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* Numeric inputs should not show spinners inside dense ledgers. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

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

/* ---------- Bottom action rows ----------
   Save / cancel / delete rows sit in the middle of their row on every page.
   Named rows are handled here; utility rows (.text-end, .justify-content-end)
   are upgraded by assets/js/action-bars.js at runtime. */
:is(.action-bar, .action-buttons, .action-footer, .form-actions, .form-footer,
    .page-footer, .sticky-footer, .theme-actions, .profile-actions,
    .manage-actions, .system-actions, .btn-group-actions, .modal-footer,
    .totals-bar-pro) {
    justify-content: center !important;
    text-align: center !important;
}

.app-actions-centered {
    align-items: center !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    justify-content: center !important;
    text-align: center !important;
    width: auto;
}

.app-actions-centered > * {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.app-actions-centered > .ms-auto,
.app-actions-centered > .me-auto {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Voucher pages float a standardised action bar; when it lives inside the
   fixed totals bar it should size to its buttons instead of forcing a new row. */
.totals-bar-pro [data-standard-actions="1"] {
    background: transparent !important;
    border: 0 !important;
    justify-content: center !important;
    padding: 0 !important;
    position: static !important;
    width: auto !important;
}

/* Print hygiene ---------- */

@media print {
    .btn,
    .filter-bar,
    .report-toolbar,
    .action-bar,
    .no-print,
    .hosted-window-controls { display: none !important; }

    body { background: #fff !important; }
}

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