/* Colors that meet WCAG AA (4.5:1 text) in both themes. Several Velzon defaults
   (text-muted, btn-success, soft buttons, -emphasis badges in light mode) fall below
   that, so new screens use these tokens instead. Ratios measured against the card
   background (#fff light, #212529 dark). */

:root {
    --app-muted-strong: #626574;        /* 5.78:1 on #fff */
    --app-accent: #405189;              /* 7.62:1 on #fff */
    --app-accent-contrast: #fff;
    --app-danger-strong: #b23b22;       /* 5.93:1 on #fff */
    --app-danger-contrast: #fff;
    --app-focus: #405189;
    --app-badge-warning-text: #856404;  /* 5.04:1 on warning-subtle */
    --app-badge-success-text: #0a6e60;  /* 5.33:1 on success-subtle */
    --app-badge-info-text: #1b6894;     /* 5.21:1 on info-subtle */
}

[data-bs-theme="dark"] {
    --app-muted-strong: #9599a8;        /* 5.44:1 on #212529 */
    --app-accent: #a9b4dc;              /* 7.53:1 on #212529 */
    --app-accent-contrast: #212529;
    --app-danger-strong: #f3846d;       /* 6.12:1 on #212529 */
    --app-danger-contrast: #212529;
    --app-focus: #a9b4dc;
    --app-badge-warning-text: var(--vz-warning-text-emphasis);
    --app-badge-success-text: var(--vz-success-text-emphasis);
    --app-badge-info-text: #6fc3ef;     /* 6.47:1 on dark info-subtle */
}

.text-muted-strong {
    color: var(--app-muted-strong) !important;
}

/* Outline buttons for secondary actions. Main actions use .btn-primary (7.62:1). */
.btn-action,
.btn-action-danger {
    --vz-btn-bg: transparent;
    --vz-btn-disabled-bg: transparent;
    --vz-btn-focus-shadow-rgb: 64, 81, 137;
}

.btn-action {
    --vz-btn-color: var(--app-accent);
    --vz-btn-border-color: var(--app-accent);
    --vz-btn-hover-color: var(--app-accent-contrast);
    --vz-btn-hover-bg: var(--app-accent);
    --vz-btn-hover-border-color: var(--app-accent);
    --vz-btn-active-color: var(--app-accent-contrast);
    --vz-btn-active-bg: var(--app-accent);
    --vz-btn-active-border-color: var(--app-accent);
    --vz-btn-disabled-color: var(--app-accent);
    --vz-btn-disabled-border-color: var(--app-accent);
}

.btn-action-danger {
    --vz-btn-color: var(--app-danger-strong);
    --vz-btn-border-color: var(--app-danger-strong);
    --vz-btn-hover-color: var(--app-danger-contrast);
    --vz-btn-hover-bg: var(--app-danger-strong);
    --vz-btn-hover-border-color: var(--app-danger-strong);
    --vz-btn-active-color: var(--app-danger-contrast);
    --vz-btn-active-bg: var(--app-danger-strong);
    --vz-btn-active-border-color: var(--app-danger-strong);
    --vz-btn-disabled-color: var(--app-danger-strong);
    --vz-btn-disabled-border-color: var(--app-danger-strong);
}

/* box-shadow, not outline: the theme sets button, a { outline: none !important }. */
.btn.btn-action:focus-visible,
.btn.btn-action-danger:focus-visible,
.btn.btn-primary:focus-visible {
    box-shadow: 0 0 0 2px var(--vz-secondary-bg), 0 0 0 4px var(--app-focus);
}

/* Status badges: text label plus a tinted background, never color alone. */
.badge-status-draft {
    background-color: var(--vz-warning-bg-subtle);
    color: var(--app-badge-warning-text);
}

.badge-status-published {
    background-color: var(--vz-success-bg-subtle);
    color: var(--app-badge-success-text);
}

.badge-status-cancelled {
    background-color: var(--vz-tertiary-bg);
    color: var(--vz-body-color);
}

/* Error message inside .alert-danger: theme alert text is 3.59:1 in light mode. */
.alert-app-danger {
    --vz-alert-color: var(--app-danger-strong);
    color: var(--app-danger-strong);
}

/* Warning notice: text #856404 on warning-subtle is 5.04:1 (theme alert text is lighter). */
.alert-app-warning {
    --vz-alert-bg: var(--vz-warning-bg-subtle);
    --vz-alert-border-color: var(--vz-warning-border-subtle);
    --vz-alert-color: var(--app-badge-warning-text);
    --vz-alert-link-color: var(--app-badge-warning-text);
    color: var(--app-badge-warning-text);
}

/* Keyboard focus, app-wide. The theme sets `button, a { outline: none !important }`
   and Bootstrap's replacement ring is ~1.5:1, so keyboard users could not see where
   they are. Drawn with box-shadow (outline is blocked by the theme). */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
[role="button"]:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible,
.page-link:focus-visible,
.dropdown-item:focus-visible,
.nav-link:focus-visible,
summary:focus-visible {
    box-shadow: 0 0 0 2px var(--vz-secondary-bg), 0 0 0 4px var(--app-focus) !important;
}

/* Inside menus the item fills the row: use an inset ring so it is not clipped. */
.dropdown-item:focus-visible {
    box-shadow: inset 0 0 0 2px var(--app-focus) !important;
}

/* Dark/colored sidebar and topbar (primary or near-black), where the primary ring
   would vanish: white inset ring instead (7.62:1 on #405189). */
html:not([data-sidebar="light"]) .app-menu a:focus-visible,
html:not([data-sidebar="light"]) .app-menu button:focus-visible,
[data-topbar="dark"] #page-topbar a:focus-visible,
[data-topbar="dark"] #page-topbar button:focus-visible,
[data-bs-theme="dark"] #page-topbar a:focus-visible,
[data-bs-theme="dark"] #page-topbar button:focus-visible {
    box-shadow: inset 0 0 0 2px #fff !important;
}

/* Form fields: a solid border plus 1px ring in the focus color (7.62:1) instead of
   the theme's pale glow. */
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--app-focus);
    box-shadow: 0 0 0 1px var(--app-focus);
}

/* Generic tone badges (text label + tint), AA in both themes. */
.badge-tone-primary { background-color: var(--vz-primary-bg-subtle); color: var(--app-accent); }
.badge-tone-info { background-color: var(--vz-info-bg-subtle); color: var(--app-badge-info-text); }
.badge-tone-warning { background-color: var(--vz-warning-bg-subtle); color: var(--app-badge-warning-text); }
.badge-tone-success { background-color: var(--vz-success-bg-subtle); color: var(--app-badge-success-text); }
.badge-tone-danger { background-color: var(--vz-danger-bg-subtle); color: var(--app-danger-strong); }
.badge-tone-neutral { background-color: var(--vz-tertiary-bg); color: var(--vz-body-color); }
