/*
 * Ship Mammoth accessibility overrides for Backpack's Tabler theme (loaded via config/backpack/ui.php 'styles').
 * Found by the UX layer (e2e/tests/ux): WCAG 2.2 AA contrast and mobile sizing. Only CSS variables and
 * sizes change; hues are kept. Contrast (WCAG ratio, normal text needs >= 4.5):
 *   primary #6a54ed (was #7c69ef): 5.12 on #fff, 4.67 on #f1f5f9, 4.89 under white text  (was 4.10 / 3.74 / 3.92)
 *   success #2b7a62 (was #42ba96): 5.17 on #fff, 4.68 on #eaf7ec, 4.94 under white text  (was 2.42 / 2.19 / 2.31)
 */
:root,
[data-bs-theme="light"] {
    --tblr-primary: #6a54ed;
    --tblr-primary-rgb: 106, 84, 237;
    --tblr-primary-darken: #5238ea;
    --tblr-tabler: #6a54ed;
    --tblr-tabler-rgb: 106, 84, 237;
    --tblr-link-color: #6a54ed;
    --tblr-link-color-rgb: 106, 84, 237;
    --tblr-link-hover-color: #5238ea;
    --tblr-link-hover-color-rgb: 82, 56, 234;
    --tblr-success: #2b7a62;
    --tblr-success-rgb: 43, 122, 98;
    --tblr-success-darken: #236350;
}

.btn-primary {
    --tblr-btn-bg: #6a54ed;
    --tblr-btn-border-color: #6a54ed;
    --tblr-btn-hover-bg: #5238ea;
    --tblr-btn-hover-border-color: #5238ea;
    --tblr-btn-active-bg: #3a1de7;
    --tblr-btn-active-border-color: #3a1de7;
}

.btn-outline-primary {
    --tblr-btn-color: #6a54ed;
    --tblr-btn-border-color: #6a54ed;
    --tblr-btn-hover-bg: #6a54ed;
    --tblr-btn-hover-border-color: #6a54ed;
    --tblr-btn-active-bg: #5238ea;
}

.btn-success {
    --tblr-btn-bg: #2b7a62;
    --tblr-btn-border-color: #2b7a62;
    --tblr-btn-hover-bg: #236350;
    --tblr-btn-hover-border-color: #236350;
    --tblr-btn-active-bg: #1b4d3e;
    --tblr-btn-active-border-color: #1b4d3e;
}

/* Light ("-lt") status badges: text darkened to >= 4.6:1 on the tinted background and on white. */
.bg-success-lt {
    color: #2b7a62 !important;
}

.bg-warning-lt {
    color: #896700 !important; /* was #ffc107: 1.46:1 on #fef0e6 (pending top-ups) */
}

.bg-danger-lt {
    color: #cb2a2a !important;
}

.bg-info-lt,
.bg-azure-lt {
    color: #1d71b7 !important;
}

.bg-orange-lt {
    color: #b74c05 !important;
}

.bg-yellow-lt {
    color: #996300 !important;
}

/*
 * Page header (title, breadcrumb, subheading) sits on the theme's dark band, which is a fixed-height
 * .navbar::after layer. Give the header its own matching background so (a) text never falls onto the
 * light page when the header wraps taller than the band on small screens, and (b) contrast checkers
 * measure the real background. Desktop only: below the lg breakpoint the theme has no band and draws the
 * header in dark text on the light page.
 */
@media (min-width: 992px) {
    .header-operation,
    nav[aria-label="breadcrumb"],
    .breadcrumb {
        background-color: rgb(34, 30, 38);
    }

    /* Links on the dark band: #8877f1 is 4.65:1 on #221e26 (brand purple is only 3.2:1 there). */
    .header-operation a,
    .header-operation .btn-link,
    .header-operation .font-sm > span,
    .breadcrumb a {
        color: #8877f1;
    }
}

/* Help text: #667380 is 4.85:1 on white (theme #73818f was 3.98). */
.help-block,
.form-text {
    color: #667380;
}

/* Mobile: readable text and comfortable tap targets (WCAG 2.5.8 minimum 24px; 44px where layout allows). */
@media (max-width: 767.98px) {
    .small,
    small,
    .badge,
    .form-text,
    .form-label-description,
    .help-block,
    .font-sm,
    .table,
    .dataTables_info,
    .breadcrumb {
        font-size: max(12px, 1em) !important;
    }

    .table > thead > tr > th,
    .avatar {
        font-size: 12px !important;
    }

    /* Small standalone links: list reset, "back to" links, footer credit, credit-log link. */
    #crudTable_reset_button,
    a.d-print-none,
    a.d-inline-block,
    .footer a {
        min-height: 24px;
        display: inline-flex;
        align-items: center;
    }

    input.primary_list {
        width: 24px;
        height: 24px;
    }

    .btn,
    .nav-link,
    .navbar .dropdown-toggle {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .btn-sm,
    .dropdown-item,
    .page-link,
    .form-select-sm {
        min-height: 32px;
    }

    .form-check-input,
    .form-switch .form-check-input {
        min-width: 24px;
        min-height: 24px;
    }

    .form-switch {
        padding-left: 3.5rem;
    }

    .form-switch .form-check-input {
        width: 3rem;
        height: 1.5rem;
        margin-left: -3.5rem;
    }
}

/* Shipping-defaults warning bar: Tabler colours alert text with the alert colour (red #df4759 is 4.05:1).
   Body text dark; heading in a darker red/amber (>= 6.3:1 on white and on the tinted alert background). */
.sm-defaults-banner {
    color: #1d273b;
}

.sm-defaults-banner.alert-danger strong {
    color: #a61e2d;
}

.sm-defaults-banner.alert-warning strong {
    color: #8a5300;
}

/* Persistent address/carrier notices in the order's shipping-rates panel: same AA-contrast text treatment. */
.sm-rate-notice {
    color: #1d273b;
}

/* Toasts (Noty, Backpack "backstrap" theme): near-white text on mid-tone colours failed contrast
   (warning was 1.57:1). Warning gets dark text; the others darker backgrounds (all >= 4.5:1). */
.noty_theme__backstrap.noty_type__warning {
    color: #1d273b;
}

.noty_theme__backstrap.noty_type__error {
    background-color: #b02a37;
    border-color: #8f1f2b;
}

.noty_theme__backstrap.noty_type__info,
.noty_theme__backstrap.noty_type__information {
    background-color: #2f62a8;
    border-color: #244c84;
}

.noty_theme__backstrap.noty_type__success {
    background-color: #2b7a62;
    border-color: #236350;
}
