/* ==========================================================================
   Hadhramout Bank — Sanctions Screening
   Design system: formal banking palette, Arabic-first typography, RTL layout.
   ========================================================================== */

:root {
    /* Brand — deep navy conveys institutional trust; teal accent for actions. */
    --brand-900: #0b1f3a;
    --brand-800: #12294a;
    --brand-700: #1a355c;
    --brand-600: #234476;
    --brand-500: #2f5b96;
    --brand-100: #e8eef7;
    --brand-050: #f4f7fb;

    --accent-600: #0d7a6f;
    --accent-500: #109c8e;
    --accent-100: #e3f5f3;

    /* Risk semantics — used by confidence badges and list status. */
    --risk-high: #b42318;
    --risk-high-bg: #fef3f2;
    --risk-med: #b54708;
    --risk-med-bg: #fffaeb;
    --risk-low: #475467;
    --risk-low-bg: #f2f4f7;
    --ok-600: #067647;
    --ok-bg: #ecfdf3;

    /* Neutrals */
    --ink-900: #101828;
    --ink-700: #344054;
    --ink-500: #667085;
    --ink-300: #d0d5dd;
    --ink-200: #e4e7ec;
    --ink-100: #f2f4f7;
    --surface: #ffffff;
    --canvas: #f7f9fc;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .1), 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, .1), 0 2px 4px -2px rgba(16, 24, 40, .06);
    --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, .08), 0 4px 6px -2px rgba(16, 24, 40, .03);

    --nav-h: 64px;
}

/* The page title introduces the card directly beneath it, so it should sit closer to that
   card than to the header. admin-shared.css ships 2rem; this file loads after it. */
.page-title-section {
    margin-bottom: 1.25rem;
}

/* --------------------------------------------------------------- base ---- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    /* Tajawal is the bank's Arabic face. This file loads AFTER hadhramout-bank-theme.css,
       so it must repeat the family — otherwise it silently overrides the theme. */
    font-family: 'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif;
    background-color: var(--canvas);
    color: var(--ink-900);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.6;
    /* Never scroll the page body sideways: wide content (tables, long names)
       scrolls inside its own container instead. */
    overflow-x: hidden;
    max-width: 100%;
}

/* Sticky footer: the page shell fills the viewport so the footer always sits at
   the bottom even on short pages. */
body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-main { flex: 1 0 auto; }

h1, h2, h3, h4, h5, h6 {
    color: var(--brand-900);
    font-weight: 650;
    letter-spacing: -.01em;
}

h1 { font-size: 1.75rem; }
h1:focus { outline: none; }

a {
    color: var(--brand-600);
    text-decoration: none;
    transition: color .15s ease;
}
a:hover { color: var(--accent-600); }

.text-muted { color: var(--ink-500) !important; }
.small, small { font-size: .8125rem; }

/* --------------------------------------------------------------- navbar -- */

.app-nav {
    background: linear-gradient(105deg, var(--brand-900) 0%, var(--brand-700) 100%);
    height: var(--nav-h);
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--shadow-md);
}

.app-nav .nav-inner {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    height: 100%;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: #fff;
    font-weight: 650;
    font-size: 1.0625rem;
    white-space: nowrap;
}
.app-brand:hover { color: #fff; }

.app-brand .mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
    display: grid;
    place-items: center;
    font-size: 1rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}

.app-brand .sub {
    font-size: .6875rem;
    font-weight: 400;
    color: rgba(255,255,255,.62);
    display: block;
    line-height: 1.2;
    letter-spacing: .02em;
}

.app-links {
    display: flex;
    align-items: center;
    gap: .25rem;
    height: 100%;
    flex: 1;
}

.app-links a {
    color: rgba(255,255,255,.78);
    padding: .5rem .875rem;
    border-radius: var(--radius-sm);
    font-size: .9375rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    transition: background-color .15s ease, color .15s ease;
}

.app-links a:hover {
    color: #fff;
    background-color: rgba(255,255,255,.09);
}

.app-links a.active {
    color: #fff;
    background-color: rgba(255,255,255,.14);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}

.nav-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255,255,255,.25);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: .375rem .625rem;
    cursor: pointer;
    font-size: 1.125rem;
    line-height: 1;
}

@media (max-width: 767.98px) {
    .app-nav .nav-inner { padding: 0 1rem; gap: 1rem; }
    .nav-toggle { display: block; }
    .app-brand .sub { display: none; }

    .app-links {
        position: absolute;
        top: var(--nav-h);
        inset-inline: 0;
        flex-direction: column;
        align-items: stretch;
        background: var(--brand-800);
        padding: .5rem;
        gap: .125rem;
        height: auto;
        box-shadow: var(--shadow-lg);
        display: none;
    }
    .app-links.open { display: flex; }
    .app-links a { padding: .75rem 1rem; }
}

/* -------------------------------------------------------------- layout --- */

.app-main {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* Grid/flex children must be allowed to shrink below their content width,
   otherwise long unbroken names force the whole page wider than the viewport. */
.stat, .card, .result-card, .table-wrap { min-width: 0; }
.result-card .entity-name, .name-row > span:first-child { overflow-wrap: anywhere; }

@media (max-width: 767.98px) {
    .app-main { padding: 1.25rem 1rem 3rem; }
}

.app-footer {
    border-top: 1px solid var(--ink-200);
    background: var(--surface);
    padding: 1.25rem 1.5rem;
    color: var(--ink-500);
    font-size: .8125rem;
}
.app-footer .footer-inner {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    justify-content: space-between;
    align-items: center;
}

/* page header block */
.page-head { margin-bottom: 1.75rem; }
.page-head .eyebrow {
    color: var(--accent-600);
    font-size: .75rem;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: .375rem;
}
.page-head h1 { margin: 0 0 .375rem; }
.page-head p { color: var(--ink-500); margin: 0; max-width: 65ch; }

/* --------------------------------------------------------------- cards --- */

.card {
    background: var(--surface);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}

.card-header {
    background: var(--brand-050);
    border-bottom: 1px solid var(--ink-200);
    font-weight: 600;
    color: var(--brand-800);
    padding: .75rem 1.125rem;
    font-size: .9375rem;
    border-start-start-radius: var(--radius);
    border-start-end-radius: var(--radius);
}

.card-body { padding: 1.25rem; }

/* search panel — the visual centrepiece */
.search-panel {
    background: var(--surface);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

.search-field { position: relative; }

.search-field .icon {
    position: absolute;
    inset-inline-start: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-500);
    pointer-events: none;
    font-size: 1.125rem;
    line-height: 1;
}

/* padding-inline start clears the leading icon (RTL-aware). */
.search-input {
    width: 100%;
    height: 54px;
    padding-inline-start: 3.25rem;
    padding-inline-end: 1rem;
    font-size: 1.0625rem;
    border: 1.5px solid var(--ink-300);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink-900);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.search-input::placeholder { color: var(--ink-500); }
.search-input:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 4px var(--brand-100);
}

/* ------------------------------------------------------------- buttons --- */

.btn {
    border-radius: var(--radius-sm);
    font-weight: 550;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
}
.btn:active { transform: translateY(1px); }

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--brand-100);
}
.btn:focus, .btn:active:focus, .form-control:focus, .form-check-input:focus { box-shadow: none; }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--brand-100); }

.btn-primary {
    background-color: var(--brand-600);
    border-color: var(--brand-600);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background-color: var(--brand-700);
    border-color: var(--brand-700);
    color: #fff;
}
.btn-primary:disabled { background-color: var(--brand-500); border-color: var(--brand-500); opacity: .6; }

.btn-accent {
    background-color: var(--accent-600);
    border-color: var(--accent-600);
    color: #fff;
}
.btn-accent:hover:not(:disabled) { background-color: var(--accent-500); border-color: var(--accent-500); color: #fff; }

.btn-outline-primary {
    color: var(--brand-600);
    border-color: var(--ink-300);
    background: var(--surface);
}
.btn-outline-primary:hover:not(:disabled) {
    background-color: var(--brand-050);
    border-color: var(--brand-500);
    color: var(--brand-700);
}

.btn-lg { height: 54px; padding-inline: 1.75rem; font-size: 1rem; }
.btn-sm { padding: .3125rem .75rem; font-size: .8125rem; }

/* --------------------------------------------------------------- forms --- */

.form-label {
    font-weight: 550;
    font-size: .875rem;
    color: var(--ink-700);
    margin-bottom: .375rem;
}

.form-control, .form-select {
    border: 1px solid var(--ink-300);
    border-radius: var(--radius-sm);
    padding: .5625rem .75rem;
    color: var(--ink-900);
    background-color: var(--surface);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px var(--brand-100);
    outline: none;
}

.form-check-input:checked {
    background-color: var(--accent-600);
    border-color: var(--accent-600);
}
.form-check-input { border-color: #98a2b3; cursor: pointer; }
.form-check-label { cursor: pointer; font-size: .875rem; color: var(--ink-700); }

/* -------------------------------------------------------- result cards --- */

.result-card {
    background: var(--surface);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    transition: box-shadow .18s ease, border-color .18s ease, transform .18s ease;
    border-inline-start: 4px solid var(--ink-300);
}
.result-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--ink-300);
    transform: translateY(-1px);
}
.result-card.risk-high { border-inline-start-color: var(--risk-high); }
.result-card.risk-med  { border-inline-start-color: var(--risk-med); }
.result-card.risk-low  { border-inline-start-color: var(--ink-300); }

.result-card .entity-name {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--brand-800);
    margin: 0 0 .25rem;
}
.result-card .entity-name a { color: inherit; }
.result-card .entity-name a:hover { color: var(--accent-600); }

.matched-name {
    background: var(--brand-050);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-sm);
    padding: .5rem .75rem;
    margin-top: .75rem;
    font-size: .875rem;
}
.matched-name .value { font-weight: 600; color: var(--ink-900); }

/* --------------------------------------------------------------- badges -- */

.badge {
    font-weight: 600;
    font-size: .75rem;
    padding: .3125rem .5625rem;
    border-radius: 999px;
    letter-spacing: .01em;
}

.score-badge {
    font-variant-numeric: tabular-nums;
    font-size: 1rem;
    padding: .375rem .75rem;
    border-radius: 999px;
    font-weight: 700;
    display: inline-block;
}
.score-high { background: var(--risk-high-bg); color: var(--risk-high); box-shadow: inset 0 0 0 1px rgba(180,35,24,.2); }
.score-med  { background: var(--risk-med-bg);  color: var(--risk-med);  box-shadow: inset 0 0 0 1px rgba(181,71,8,.2); }
.score-low  { background: var(--risk-low-bg);  color: var(--risk-low);  box-shadow: inset 0 0 0 1px rgba(71,84,103,.16); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .75rem;
    font-weight: 550;
    padding: .1875rem .5rem;
    border-radius: var(--radius-sm);
    background: var(--ink-100);
    color: var(--ink-700);
    border: 1px solid var(--ink-200);
}
.chip-list  { background: var(--brand-900); color: #fff; border-color: var(--brand-900); font-weight: 600; letter-spacing: .03em; }
.chip-ai    { background: var(--accent-100); color: var(--accent-600); border-color: rgba(13,122,111,.25); }
.chip-arabic{ font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif; }

/* --------------------------------------------------------------- tables -- */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

.table {
    margin: 0;
    color: var(--ink-700);
    border-color: var(--ink-200);
    /* Keep columns readable on phones: the wrapper scrolls rather than the cells
       collapsing into unreadable vertical text. */
    min-width: 720px;
}

.table-wrap .table-responsive { overflow-x: auto; }

.table > thead > tr > th {
    background: var(--brand-050);
    color: var(--brand-800);
    font-weight: 600;
    font-size: .8125rem;
    letter-spacing: .02em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--ink-200);
    padding: .75rem 1rem;
    white-space: nowrap;
}

.table > tbody > tr > td {
    padding: .875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--ink-100);
}
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table > tbody > tr:hover > td { background: var(--brand-050); }

.num { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-900); }

/* ---------------------------------------------------------- stat tiles --- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

@media (max-width: 575.98px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat .value { font-size: 1.375rem; }
}

.stat {
    background: var(--surface);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    padding: 1.125rem 1.25rem;
    box-shadow: var(--shadow-xs);
}
.stat .label {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-500);
    margin-bottom: .375rem;
}
.stat .value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--brand-800);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}
.stat .meta { font-size: .75rem; color: var(--ink-500); margin-top: .25rem; }

/* --------------------------------------------------------------- alerts -- */

.alert {
    border-radius: var(--radius);
    border-width: 1px;
    padding: .875rem 1.125rem;
    font-size: .875rem;
}
.alert-warning { background: var(--risk-med-bg); border-color: rgba(181,71,8,.22); color: #93370d; }
.alert-danger  { background: var(--risk-high-bg); border-color: rgba(180,35,24,.22); color: #912018; }
.alert-success { background: var(--ok-bg); border-color: rgba(6,118,71,.22); color: #05603a; }
.alert-secondary { background: var(--ink-100); border-color: var(--ink-200); color: var(--ink-700); }
.alert-info { background: var(--accent-100); border-color: rgba(13,122,111,.22); color: var(--accent-600); }

/* ------------------------------------------------------------ progress --- */

.progress { background: var(--ink-100); border-radius: 999px; height: .5rem; }
.progress-bar { background-color: var(--accent-600); }

/* ------------------------------------------------------- empty & misc ---- */

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--ink-500);
}
.empty-state .glyph { font-size: 2.5rem; opacity: .35; margin-bottom: .75rem; }

.spinner-border { color: var(--brand-600); }

dl.detail-list { margin: 0; }
dl.detail-list dt {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--ink-500);
    padding-block: .5rem .125rem;
}
dl.detail-list dd { margin: 0 0 .5rem; color: var(--ink-900); font-size: .875rem; }

/* Multi-valued detail (branch addresses, several IDs): one scannable row each. */
ul.value-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 20rem;
    overflow-y: auto;
}
ul.value-list li {
    padding: .375rem 0 .375rem .625rem;
    border-bottom: 1px dashed var(--ink-100);
    border-inline-start: 2px solid var(--ink-200);
    padding-inline-start: .625rem;
    line-height: 1.5;
}
ul.value-list li:last-child { border-bottom: 0; }

.name-group { margin-bottom: 1.25rem; }
.name-group:last-child { margin-bottom: 0; }
.name-group .group-title {
    font-size: .75rem;
    font-weight: 650;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--ink-500);
    padding-bottom: .375rem;
    border-bottom: 1px solid var(--ink-100);
    margin-bottom: .5rem;
}
.name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .4375rem 0;
    font-size: .9375rem;
    border-bottom: 1px dashed var(--ink-100);
}
.name-row:last-child { border-bottom: 0; }

/* ---------------------------------------------------- framework bits ----- */

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--ok-600); }
.invalid { outline: 1px solid var(--risk-high); }
.validation-message { color: var(--risk-high); }

.blazor-error-boundary {
    background: var(--risk-high);
    padding: 1rem;
    color: #fff;
    border-radius: var(--radius);
}
.blazor-error-boundary::after { content: "حدث خطأ غير متوقع."; }

#blazor-error-ui {
    color-scheme: light only;
    background: #fffaeb;
    border-top: 1px solid rgba(181,71,8,.3);
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(16,24,40,.12);
    box-sizing: border-box;
    display: none;
    inset-inline: 0;
    padding: .75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1050;
    font-size: .875rem;
    color: #93370d;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; inset-inline-end: 1rem; top: .5rem; }
/* ============================================================================
   Generic .table → cards on phones
   ----------------------------------------------------------------------------
   Applies to tables using the plain .table class (currently /lists). The audit and
   users tables carry .hb-table plus their own class and handle this in their scoped
   stylesheets, because scoped rules out-specify this file and a copy here would lose.

   The critical line is `min-width: 0`. `.table` above sets min-width: 720px so columns
   stay legible while the wrapper scrolls; that value survives `display: block` and
   would otherwise produce 720px-wide cards spilling out of a 390px viewport.
   ============================================================================ */

@media (max-width: 768px) {
    .table-wrap { overflow: visible; }
    .table-wrap .table-responsive { overflow-x: visible; }

    .table thead { display: none; }

    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .table tbody tr {
        background: #fff;
        border: 2px solid #e9ecef;
        border-radius: 12px;
        margin-bottom: 1rem;
        padding: 0.85rem 1rem;
        box-shadow: 0 2px 8px rgba(0, 61, 122, 0.08);
    }

    .table tbody td {
        position: relative;
        border: none;
        padding: 0.5rem 45% 0.5rem 0;
        text-align: right;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* Only cells that were given a data-label get one; a cell without the attribute simply
       renders full width rather than showing an empty label column. */
    .table tbody td[data-label]::before {
        content: attr(data-label);
        position: absolute;
        right: 0;
        width: 42%;
        text-align: right;
        font-weight: 700;
        color: #003d7a;
        white-space: nowrap;
    }

    .table tbody td:not([data-label]) { padding-right: 0; }

    /* text-end is for a table cell in a row; inside a card it would push the button away
       from the label it belongs to. */
    .table tbody td.text-end { text-align: right; }
}

@media (max-width: 480px) {
    .table tbody td { padding-right: 0; }

    .table tbody td[data-label]::before {
        position: static;
        display: block;
        width: auto;
        margin-bottom: 0.15rem;
        font-size: 0.75rem;
    }

    .table tbody tr { padding: 0.75rem 0.85rem; }
}
