/* OneAccess reusable components (ADR-0003, Phase 4B). Loaded after oa-shell.css. Vendor files are never edited. */

/* Server-side validation state on enhanced controls: Select2 and the Quill surface replace the visible input,
   so Bootstrap's .is-invalid on the native control would otherwise not show. */
.is-invalid + .select2-container .select2-selection,
[data-oa-editor] .is-invalid ~ .ql-container {
    border-color: var(--bs-form-invalid-border-color, #f1416c);
}

/* Quill: match Metronic form controls. */
[data-oa-editor] .ql-toolbar.ql-snow {
    border-color: var(--bs-border-color);
    border-radius: 0.475rem 0.475rem 0 0;
}

[data-oa-editor] .ql-container.ql-snow {
    border-color: var(--bs-border-color);
    border-radius: 0 0 0.475rem 0.475rem;
    font-family: inherit;
    font-size: 1rem;
}

/* Visible keyboard focus on the Select2 control and the editor, which Metronic's outline reset hides. */
.select2-container--focus .select2-selection,
.select2-container--open .select2-selection,
[data-oa-editor] .ql-container:focus-within {
    outline: 2px solid var(--oa-primary-600, #0b5cad);
    outline-offset: 1px;
}

@media (prefers-reduced-motion: reduce) {
    .oa-ui-field *, [data-oa-loading-overlay] .spinner-border {
        animation-duration: 1.5s;
    }
}

/* Authentication layout: ICT Authority brand panel. Colour from the OneAccess tokens (loaded by oa-bridge.css). */
.oa-auth-aside {
    background: var(--oa-navy-900, #0b2545);
}

.oa-auth-aside__lead {
    color: #e3ebf5;
}

.oa-skip-link {
    position: absolute;
    left: 1rem;
    top: -4rem;
    padding: 0.75rem 1rem;
    border-radius: 0.475rem;
    background: var(--oa-navy-900, #0b2545);
    color: #fff;
}

.oa-skip-link:focus {
    top: 1rem;
    z-index: 1;
    color: #fff;
}

/* ---- Migrated pages (Phase A): Metronic cards around existing page content ------------------------------------------
   Page templates put headings, definition lists, forms and tables directly inside .card (the old card had its own padding).
   These rules give such children the card's horizontal and vertical rhythm without adding wrapper markup to every view.
   Full-bleed children (tables, scroll regions, states, alerts) are excluded. */
.oa-metronic .card > :not(.card-header):not(.card-body):not(.card-footer):not(.table-responsive):not(.oa-state):not(.alert):not(.visually-hidden):not(.px-5) {
    margin-left: 1.75rem;
    margin-right: 1.75rem;
}

.oa-metronic .card > .card-header + :not(.card-body):not(.table-responsive):not(.oa-state) {
    margin-top: 1.5rem;
}

.oa-metronic .card > :last-child:not(.card-header):not(.card-body):not(.table-responsive) {
    margin-bottom: 1.5rem;
}

.oa-metronic .card > .alert,
.oa-metronic .card > .oa-state {
    margin: 1.5rem 1.75rem;
}

.oa-metronic .card-header > h2,
.oa-metronic .card-header > h3,
.oa-metronic .card-header > div > h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--bs-gray-900);
}

.oa-metronic .card-header {
    align-items: center;
    gap: 0.75rem;
}

/* Page title row */
.oa-metronic h1.fs-2 + p {
    margin-top: 0.25rem;
}

/* Tables */
.oa-metronic .table > :not(caption) > * > * {
    vertical-align: middle;
}

.oa-metronic .table th a.oa-sort-link {
    color: inherit;
    text-decoration: none;
}

.oa-metronic .table th a.oa-sort-link:hover {
    color: var(--bs-primary);
}

/* Alerts keep the icon and body on one line */
.oa-metronic .alert > i {
    margin-top: 0.15rem;
}

.oa-metronic .alert p {
    margin: 0;
}

/* Grids of cards */
.oa-metronic .oa-grid {
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

/* Filter bars: fields share the row; the field wrapper's bottom margin is the row gap */
.oa-metronic form.d-flex.align-items-end > .mb-5 {
    margin-bottom: 0 !important;
}

/* ---- Accessibility fixes found by the signed-in crawl (Phase A) ---------------------------------------------------- */

/* Metronic's default link blue (#1b84ff) is 3.6:1 on white. Use the OneAccess brand blue (tokens loaded by oa-bridge.css, >= 4.5:1). */
.oa-metronic,
.oa-metronic .card {
    --bs-link-color: var(--oa-primary-600, #0b57d0);
    --bs-link-hover-color: var(--oa-primary-700, #0a47a8);
    --bs-link-color-rgb: 11, 87, 208;
    --bs-link-hover-color-rgb: 10, 71, 168;
}

.oa-metronic a:not([class]),
.oa-metronic .table a:not(.btn):not(.page-link):not(.menu-link) {
    color: var(--oa-primary-600, #0b57d0);
}

/* A positioned scroll container clips the absolutely positioned .visually-hidden text inside its tables. Without this the hidden
   text sits at the far right of the table and widens the whole page on narrow screens. */
.oa-metronic .table-responsive {
    position: relative;
}

/* Links inside running text must not rely on colour alone (WCAG 1.4.1). */
.oa-metronic p a:not(.btn):not(.page-link),
.oa-metronic .alert a,
.oa-metronic .oa-state__text a,
.oa-metronic dd a {
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

/* Code and message previews wrap instead of scrolling sideways (a scrolling region would need its own tab stop). */
.oa-metronic pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    overflow: visible;
}

/* ---- oa-grid (OneAccess layout component, previously in shell.css, which is not loaded with the Metronic shell) ----- */
.oa-grid { display: grid; gap: 1.25rem; min-width: 0; }
.oa-grid--stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.oa-grid--main-side { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.oa-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }

@media (max-width: 75rem) {
    .oa-grid--stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .oa-grid--main-side, .oa-grid--three { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 36rem) {
    .oa-grid--stats { grid-template-columns: minmax(0, 1fr); }
}

.oa-auth-card__section { margin-top: 1.25rem; }

.oa-metronic .oa-hero { margin-bottom: 1.25rem; }

/* A card whose first child is content (no header) needs top spacing. */
.oa-metronic .card > :first-child:not(.card-header):not(.card-body):not(.table-responsive):not(.oa-state):not(.alert) {
    margin-top: 1.5rem;
}

/* ---- Phase B1 ---------------------------------------------------------------------------------------------------- */

/* Metronic's "info" is purple. ICT Authority uses its brand blue for informational states (tokens loaded by oa-bridge.css). */
.oa-metronic {
    --bs-info: var(--oa-primary-700, #0a47a8);
    --bs-info-active: var(--oa-primary-700, #0a47a8);
    --bs-info-light: var(--oa-primary-50, #e8f0fe);
    --bs-info-text-emphasis: var(--oa-primary-700, #0a47a8);
    --bs-info-bg-subtle: var(--oa-primary-50, #e8f0fe);
    --bs-info-border-subtle: var(--oa-primary-600, #0b57d0);
}

/* Demo 1 gives list columns a minimum width (min-w-125px on the header cells). On narrow screens the table then scrolls inside its
   container instead of squeezing every column to a few characters. */
.oa-metronic .table-responsive > .table {
    min-width: 40rem;
}

/* Demo 1 table text uses gray-500/600 and text-muted (#99a1b7 / #78829d), which are 2.6:1 and 3.9:1 on white and fail WCAG AA.
   These OneAccess overrides keep the Demo 1 look with accessible values (>= 4.5:1 on white and on the #fafafa page background). */
.oa-metronic {
    --bs-gray-500: #5f6a80;
    --bs-gray-600: #54607a;
    --bs-text-muted: #5f6a80;
}

.oa-metronic {
    --bs-text-gray-500: #5f6a80;
    --bs-text-gray-600: #54607a;
    --bs-secondary-color: #5f6a80;
}

/* ---- Profile picture (oa-avatar-input + avatar symbol) --------------------------------------------------------
   Original OneAccess component. States: --empty (no picture, initials shown) and --changed (a new picture is selected
   and not yet saved). The three actions sit on the circle: change at the top right, cancel and remove at the bottom
   right. oa-avatar.js toggles the state classes. */
.oa-avatar-input { position: relative; display: inline-block; border-radius: 50%; }
.oa-avatar-input__wrapper {
  border-radius: 50%;
  border: 3px solid var(--bs-body-bg);
  box-shadow: var(--bs-box-shadow);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}
.oa-avatar-input__initials { display: none; }
/* Bootstrap utilities (d-flex) carry !important, so the hidden state needs it too. */
.oa-avatar-input--empty .oa-avatar-input__initials { display: flex !important; }
.oa-avatar-input__action { cursor: pointer; position: absolute; left: 100%; transform: translate(-100%, 0); top: 0; }
.oa-avatar-input__action--cancel,
.oa-avatar-input__action--remove { top: 100%; transform: translate(-100%, -100%); }
.oa-avatar-input__action--change input { width: 0 !important; height: 0 !important; overflow: hidden; opacity: 0; }
.oa-avatar-input__action--cancel { display: none; }
.oa-avatar-input--changed .oa-avatar-input__action--cancel { display: flex; }
.oa-avatar-input--changed .oa-avatar-input__action--remove,
.oa-avatar-input--empty .oa-avatar-input__action--remove { display: none; }
.oa-avatar-input__action:focus-visible,
.oa-avatar-input__action:focus-within {
  outline: 2px solid var(--bs-primary, #0b5cab);
  outline-offset: 2px;
}
.symbol > img.symbol-label-image { object-fit: cover; }
@media (prefers-reduced-motion: reduce) {
  .oa-avatar-input__wrapper { transition: none; }
}
