/*
 * SACCO alert polish (loaded after the theme by layouts/app and layouts/auth).
 *
 * Why: the theme (public/assets/css/main.css, ".alert" in "15. Alert CSS") makes every .alert
 * `display: inline-flex; align-items: center`, so each inline child (<strong>, <code>, <i>, text)
 * becomes its own flex column and sentences are torn apart. Its variants are also solid colours
 * with white text (white on #ffb200 = 1.8:1, on #0dcaf0 = 2.0:1, pink <code> on red = 1.3:1).
 *
 * Scope: only `.alert` and its variants, plus the C2B "Last registration attempt" card.
 * Alerts that ask for flex with Bootstrap's `.d-flex` keep it (`.d-flex` is !important).
 * Every text/background pair below is >= 4.5:1 (WCAG AA) in the light and dark themes.
 */

/* ---------- base ---------- */
.alert {
    --sa-bg: #F4F5F7;
    --sa-border: #E3E6EA;
    --sa-accent: #9CA3AF;
    --sa-text: #374151;
    --sa-strong: #1F2937;
    --sa-chip: rgba(156, 163, 175, .18);

    display: block;
    position: relative;
    padding: 12px 16px;
    line-height: 1.5;
    color: var(--sa-text);
    background-color: var(--sa-bg);
    border: 1px solid var(--sa-border);
    border-left: 4px solid var(--sa-accent);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

/* Variants: two-class selectors so they win over the theme's solid single-class colours. */
.alert.alert-primary   { --sa-bg: #F3F1FF; --sa-border: #DCD7FE; --sa-accent: #6C5FFC; --sa-text: #3B2F9E; --sa-strong: #2A2075; --sa-chip: rgba(108, 95, 252, .14); }
.alert.alert-secondary { --sa-bg: #F4F5F7; --sa-border: #E3E6EA; --sa-accent: #9CA3AF; --sa-text: #374151; --sa-strong: #1F2937; --sa-chip: rgba(156, 163, 175, .20); }
.alert.alert-success   { --sa-bg: #EEF9EF; --sa-border: #C9EBCC; --sa-accent: #34B53A; --sa-text: #1E5B25; --sa-strong: #14421A; --sa-chip: rgba(52, 181, 58, .16); }
.alert.alert-info      { --sa-bg: #EBF7FD; --sa-border: #C4E6F7; --sa-accent: #0EA5E9; --sa-text: #0B4F72; --sa-strong: #083A55; --sa-chip: rgba(14, 165, 233, .16); }
.alert.alert-warning   { --sa-bg: #FFF7E6; --sa-border: #FBE2B0; --sa-accent: #F59E0B; --sa-text: #6B4500; --sa-strong: #4D3100; --sa-chip: rgba(245, 158, 11, .18); }
.alert.alert-danger    { --sa-bg: #FFF0EE; --sa-border: #F9CDC8; --sa-accent: #FF3A29; --sa-text: #9B1C10; --sa-strong: #73140B; --sa-chip: rgba(255, 58, 41, .14); }

.alert.alert-primary, .alert.alert-secondary, .alert.alert-success,
.alert.alert-info, .alert.alert-warning, .alert.alert-danger {
    color: var(--sa-text);
    background-color: var(--sa-bg);
    border-color: var(--sa-border);
    border-left-color: var(--sa-accent);
}

/* Theme rules that force white text inside the solid variants. */
.alert p,
.alert .alert-heading,
.alert h1, .alert h2, .alert h3, .alert h4, .alert h5, .alert h6 {
    color: inherit;
}
.alert .alert-heading,
.alert h5, .alert h6 {
    color: var(--sa-strong);
    font-weight: 600;
}

/* Inline content flows as text again. */
.alert strong,
.alert b {
    display: inline;
    color: var(--sa-strong);
    font-weight: 600;
}
.alert strong ~ p {
    display: block;
}
.alert ul,
.alert ol {
    padding-left: 1.25rem;
}

/* <code> as a neat monospace pill (no pink-on-red). */
.alert code {
    color: inherit;
    background: rgba(0, 0, 0, .06);
    padding: .1em .4em;
    border-radius: 4px;
    font-size: .875em;
    word-break: break-word;
}

/* Links underlined in the variant colour (buttons untouched). */
.alert a:not(.btn),
.alert .alert-link {
    color: var(--sa-strong);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
}

/* Leading icon -> small round chip on the first line (decorative large icons excluded). */
.alert > i:first-child:not(.d-block):not(.fa-2x):not(.fa-3x):not(.fa-4x):not(.fs-1):not(.fs-2):not(.fs-3):not(.fs-4) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: static;
    width: 22px;
    height: 22px;
    margin-inline-end: 8px;
    border-radius: 50%;
    background: var(--sa-chip);
    color: var(--sa-accent);
    font-size: 11px;
    line-height: 1;
    vertical-align: -5px;
    flex-shrink: 0;
}
.alert.alert-warning > i:first-child { color: #B45309; }
.card__wrapper .alert > i:first-child ~ p { padding-inline-start: 0; }

/* Dismissible: close button top-right, dark glyph on the pale surface. */
.alert.alert-dismissible {
    padding-right: 3rem;
}
.alert.alert-dismissible .btn-close {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: .65rem;
    filter: none;
    opacity: .55;
}
.alert.alert-dismissible .btn-close:hover,
.alert.alert-dismissible .btn-close:focus {
    opacity: .9;
}

/* Full-width fixed notices (e.g. session timeout) keep their square edge-to-edge look. */
.alert.position-fixed {
    border-radius: 0;
    border-width: 0 0 1px 0;
    box-shadow: 0 2px 6px rgba(16, 24, 40, .08);
}

/* ---------- dark theme ---------- */
:root[bd-theme=bd-theme-dark] .alert                  { --sa-bg: #303A48; --sa-border: #4B5563; --sa-accent: #9CA3AF; --sa-text: #E5E7EB; --sa-strong: #F9FAFB; --sa-chip: rgba(156, 163, 175, .22); box-shadow: none; }
:root[bd-theme=bd-theme-dark] .alert.alert-primary    { --sa-bg: #2D335A; --sa-border: #463F9A; --sa-accent: #8B80FF; --sa-text: #C9C3FF; --sa-strong: #E4E0FF; --sa-chip: rgba(139, 128, 255, .22); }
:root[bd-theme=bd-theme-dark] .alert.alert-secondary  { --sa-bg: #303A48; --sa-border: #4B5563; --sa-accent: #9CA3AF; --sa-text: #E5E7EB; --sa-strong: #F9FAFB; --sa-chip: rgba(156, 163, 175, .22); }
:root[bd-theme=bd-theme-dark] .alert.alert-success    { --sa-bg: #223F37; --sa-border: #2F6B3A; --sa-accent: #4ADE80; --sa-text: #A7E8AC; --sa-strong: #D3F5D6; --sa-chip: rgba(74, 222, 128, .18); }
:root[bd-theme=bd-theme-dark] .alert.alert-info       { --sa-bg: #1C3D53; --sa-border: #23597A; --sa-accent: #38BDF8; --sa-text: #A5DDF7; --sa-strong: #D6F0FC; --sa-chip: rgba(56, 189, 248, .18); }
:root[bd-theme=bd-theme-dark] .alert.alert-warning    { --sa-bg: #413C30; --sa-border: #6B5520; --sa-accent: #FBBF24; --sa-text: #FCD98A; --sa-strong: #FEF0C7; --sa-chip: rgba(251, 191, 36, .18); }
:root[bd-theme=bd-theme-dark] .alert.alert-danger     { --sa-bg: #432C35; --sa-border: #7A3530; --sa-accent: #FF6B5E; --sa-text: #FFB4AB; --sa-strong: #FFDAD5; --sa-chip: rgba(255, 107, 94, .2); }
:root[bd-theme=bd-theme-dark] .alert code             { background: rgba(255, 255, 255, .1); }
:root[bd-theme=bd-theme-dark] .alert.alert-warning > i:first-child { color: var(--sa-accent); }
:root[bd-theme=bd-theme-dark] .alert.alert-dismissible .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* ---------- C2B "Last registration attempt" card ---------- */
.c2b-register-result {
    --c2b-accent: #9CA3AF;
    background: var(--clr-bg-card, #FFFFFF);
    color: var(--clr-heading-primary, #444050);
    border: 1px solid var(--clr-border-1, #EAEAEA);
    border-left: 4px solid var(--c2b-accent);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    padding: 12px 16px;
    line-height: 1.5;
}
.c2b-register-result--failed  { --c2b-accent: #FF3A29; }
.c2b-register-result--success { --c2b-accent: #34B53A; }
.c2b-register-result__title {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--clr-text-label, #495057);
    margin-bottom: 6px;
}
.c2b-register-result__head { display: flex; align-items: flex-start; gap: 8px; }
.c2b-register-result__badge {
    display: inline-block;
    flex-shrink: 0;
    padding: 1px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.6;
    border: 1px solid transparent;
}
.c2b-register-result__badge--failed  { background: #FFF0EE; color: #9B1C10; border-color: #F9CDC8; }
.c2b-register-result__badge--success { background: #EEF9EF; color: #1E5B25; border-color: #C9EBCC; }
.c2b-register-result__message { overflow-wrap: anywhere; word-break: break-word; font-weight: 500; }
.c2b-register-result__list {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    margin: 10px 0 0;
    font-size: .875rem;
}
.c2b-register-result__list dt,
.c2b-register-result__list dd {
    margin: 0;
    padding: 5px 0;
    border-top: 1px solid var(--clr-border-1, #EAEAEA);
}
.c2b-register-result__list dt { padding-right: 16px; font-weight: 600; color: var(--clr-text-label, #495057); }
.c2b-register-result__list dd { overflow-wrap: anywhere; word-break: break-word; }
.c2b-register-result__mono {
    display: inline-block;
    max-width: 100%;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: .8125rem;
    padding: 0 6px;
    border-radius: 4px;
    background: rgba(108, 95, 252, .08);
    user-select: all;
    overflow-wrap: anywhere;
    word-break: break-all;
}
.c2b-register-result__hint {
    margin: 10px 0 0;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: .8125rem;
    background: #FFF7E6;
    color: #6B4500;
}
@media (max-width: 575.98px) {
    .c2b-register-result__list { grid-template-columns: minmax(0, 1fr); }
    .c2b-register-result__list dd { border-top: 0; padding-top: 0; }
}
:root[bd-theme=bd-theme-dark] .c2b-register-result { box-shadow: none; }
:root[bd-theme=bd-theme-dark] .c2b-register-result__badge--failed  { background: #432C35; color: #FFB4AB; border-color: #7A3530; }
:root[bd-theme=bd-theme-dark] .c2b-register-result__badge--success { background: #223F37; color: #A7E8AC; border-color: #2F6B3A; }
:root[bd-theme=bd-theme-dark] .c2b-register-result__mono { background: rgba(255, 255, 255, .08); }
:root[bd-theme=bd-theme-dark] .c2b-register-result__hint { background: #413C30; color: #FCD98A; }

/* ---------- hard guarantee: plain alerts are block, never the theme's inline-flex ---------- */
.alert:not(.d-flex) { display: block !important; }
.alert:not(.d-flex) > i:first-child:not([class*="fa-2x"]):not([class*="fa-3x"]) { margin-inline-end: 8px; }
