/* =====================================================================
   ERPidex layout (Views/Shared/_LayoutErpidex.cshtml)
   Design language of the ERPidex reference application: dark sidebar,
   white top bar with breadcrumb, cards on a light plane.
   Everything is prefixed ex- so it does not clash with Bootstrap 3, which
   the existing pages still use; the "legacy" part at the end restyles the
   common page widgets (filter boxes, buttons, DataTables) to match.
   ===================================================================== */
:root {
    --ex-font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    /* brand */
    --ex-blue: #1591d1; --ex-blue-2: #0e6fa6; --ex-blue-weak: #e7f3fb; --ex-blue-ring: rgba(21,145,209,.28);
    --ex-red: #e11f26;
    /* content */
    --ex-plane: #eef1f6; --ex-surface: #ffffff; --ex-surface-2: #f6f8fb; --ex-head: #f4f7fa;
    --ex-line: #e3e8ef; --ex-line-2: #eef2f7;
    --ex-ink: #111b2b; --ex-ink-2: #57637a; --ex-ink-3: #8994a6;
    /* sidebar */
    --ex-nav: #0e1a2c; --ex-nav-2: #13253c; --ex-nav-line: #1e3049; --ex-nav-ink: #aab6c8; --ex-nav-ink-2: #6b7a92; --ex-nav-hover: #182a41;
    /* status */
    --ex-good: #0ca35a; --ex-good-bg: #e4f6ec; --ex-good-ink: #0a7f47;
    --ex-warn-bg: #fbf0d8; --ex-warn-ink: #9a6600;
    --ex-crit-bg: #fbe6e6; --ex-crit-ink: #b32626;
    --ex-shadow: 0 1px 2px rgba(17,27,43,.06), 0 1px 3px rgba(17,27,43,.04);
    --ex-r: 12px; --ex-r-sm: 9px;
}

html, body.ex-body { height: 100%; }
body.ex-body { margin: 0; padding: 0; background: var(--ex-plane); color: var(--ex-ink); font-family: var(--ex-font); font-size: 13.5px; -webkit-font-smoothing: antialiased; }

/* ---------- frame ---------- */
.ex-app { display: grid; grid-template-columns: 250px 1fr; height: 100vh; height: 100dvh; transition: grid-template-columns .22s cubic-bezier(.4,0,.2,1); }
.ex-app.collapsed { grid-template-columns: 72px 1fr; }

.ex-side { background: linear-gradient(180deg, var(--ex-nav) 0%, var(--ex-nav-2) 100%); color: var(--ex-nav-ink); display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--ex-nav-line); }
.ex-side-top { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid var(--ex-nav-line); min-height: 64px; }
.ex-side-logo { display: block; overflow: hidden; flex: none; padding: 2px 4px; }
.ex-side-logo img { height: 30px; width: auto; display: block; }
.ex-app.collapsed .ex-side-logo { width: 23px; padding: 0; }   /* only the S mark */
.ex-app.collapsed .ex-logout { display: none; }
.ex-app.collapsed .ex-side-user { justify-content: center; }

.ex-nav { flex: 1; overflow-y: auto; padding: 12px; scrollbar-width: thin; scrollbar-color: #2c466a transparent; }
.ex-nav-search { margin: 0 0 8px; position: relative; }
.ex-nav-search input { width: 100%; max-width: none; height: 34px; border: 1px solid var(--ex-nav-line); border-radius: 8px; background: var(--ex-nav-hover); color: #fff; font: inherit; font-size: 12.5px; padding: 0 10px 0 32px; }
.ex-nav-search input::placeholder { color: var(--ex-nav-ink-2); }
.ex-nav-search input:focus { outline: none; border-color: var(--ex-blue); box-shadow: 0 0 0 3px var(--ex-blue-ring); }
.ex-nav-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--ex-nav-ink-2); }
.ex-nav-lab { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ex-nav-ink-2); padding: 14px 10px 7px; }

.ex-nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 11px; border: none; background: none; color: var(--ex-nav-ink); border-radius: 9px; font-size: 13.5px; font-weight: 550; text-align: left; position: relative; text-decoration: none !important; transition: background .12s, color .12s; cursor: pointer; }
.ex-nav-item:hover, .ex-nav-item:focus { background: var(--ex-nav-hover); color: #fff; }
.ex-nav-item svg { width: 19px; height: 19px; flex: none; }
.ex-nav-item span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-nav-item.on { background: linear-gradient(90deg, rgba(21,145,209,.22), rgba(21,145,209,.05)); color: #fff; }
.ex-nav-item.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--ex-blue); }
.ex-nav-item.on svg { color: #4fb6ea; }
.ex-nav-item .ex-chev { width: 14px; height: 14px; color: var(--ex-nav-ink-2); transition: transform .15s; }
.ex-nav-group.open > .ex-nav-item .ex-chev { transform: rotate(90deg); }
.ex-nav-sub { display: none; padding: 2px 0 6px 31px; }
.ex-nav-group.open > .ex-nav-sub { display: block; }
.ex-nav-sub a { display: block; padding: 6px 10px; border-radius: 7px; color: var(--ex-nav-ink); font-size: 12.8px; text-decoration: none !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-nav-sub a:hover { background: var(--ex-nav-hover); color: #fff; }
.ex-nav-sub a.on { color: #fff; font-weight: 650; background: rgba(21,145,209,.16); }
.ex-nav-empty { display: none; padding: 8px 11px; font-size: 12px; color: var(--ex-nav-ink-2); }

.ex-side-user { border-top: 1px solid var(--ex-nav-line); padding: 12px; display: flex; align-items: center; gap: 10px; }
.ex-avatar { width: 36px; height: 36px; border-radius: 9px; background: linear-gradient(145deg, var(--ex-blue), var(--ex-blue-2)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.ex-user-meta { min-width: 0; flex: 1; }
.ex-user-meta b { display: block; font-size: 13px; color: #fff; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-user-meta small { font-size: 11px; color: var(--ex-nav-ink-2); }
.ex-logout { width: 32px; height: 32px; color: var(--ex-nav-ink-2); display: grid; place-items: center; border-radius: 8px; }
.ex-logout:hover { background: var(--ex-nav-hover); color: #fff; }
.ex-logout svg { width: 17px; height: 17px; }
.ex-side-powered { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 12px 12px; border-top: 1px solid var(--ex-nav-line); font-size: 10px; color: var(--ex-nav-ink-2); }
.ex-side-powered b { color: var(--ex-nav-ink); letter-spacing: .04em; }

.ex-app.collapsed .ex-nav-lab, .ex-app.collapsed .ex-nav-item span, .ex-app.collapsed .ex-nav-item .ex-chev,
.ex-app.collapsed .ex-user-meta, .ex-app.collapsed .ex-nav-search, .ex-app.collapsed .ex-nav-sub, .ex-app.collapsed .ex-side-powered { display: none; }
.ex-app.collapsed .ex-side-top { justify-content: center; }
.ex-app.collapsed .ex-nav-item { justify-content: center; padding: 10px; }

.ex-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ex-topbar { display: flex; align-items: center; gap: 16px; margin: 0; padding: 0 22px !important; height: 64px; background: var(--ex-surface); border-bottom: 1px solid var(--ex-line); flex: none; text-align: left !important; font-family: var(--ex-font) !important; }
.ex-burger { width: 36px; height: 36px; border: 1px solid var(--ex-line); background: var(--ex-surface); border-radius: 9px; display: grid; place-items: center; color: var(--ex-ink-2); flex: none; padding: 0; }
.ex-burger:hover { background: var(--ex-surface-2); color: var(--ex-ink); }
.ex-burger svg { width: 18px; height: 18px; }
.ex-crumb { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.ex-crumb h1 { margin: 0 !important; font-size: 18px !important; font-weight: 750; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ex-ink); }
.ex-bc { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 2px; flex-wrap: wrap; }
.ex-bc-sep { color: var(--ex-ink-3); opacity: .5; }
.ex-bc-mid { color: var(--ex-ink-3); }
.ex-bc-cur { color: var(--ex-blue-2); font-weight: 700; }
.ex-top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.ex-unit { display: inline-flex; align-items: center; gap: 8px; height: 38px; margin: 0; padding: 0 6px 0 12px; border: 1px solid var(--ex-line); border-radius: 9px; background: var(--ex-surface-2); color: var(--ex-ink-2); font-size: 13px; }
.ex-unit svg { width: 16px; height: 16px; color: var(--ex-blue-2); flex: none; }
.ex-unit select { border: none; background: transparent; height: 34px; min-width: 150px; max-width: 260px; width: auto; font: inherit; font-weight: 650; color: var(--ex-ink); cursor: pointer; padding: 0 4px; margin: 0; }
.ex-unit select:focus { outline: none; }
.ex-unit-fixed { padding-right: 12px; font-weight: 650; color: var(--ex-ink); }
.ex-pill { display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.ex-pill-warn { background: var(--ex-warn-bg); color: var(--ex-warn-ink); }
.ex-pill-good { background: var(--ex-good-bg); color: var(--ex-good-ink); }
.ex-pill-crit { background: var(--ex-crit-bg); color: var(--ex-crit-ink); }

.ex-content { flex: 1; overflow-y: auto; padding: 16px 22px 22px; min-height: 0; }
.ex-content-plain { padding: 0; }
footer.ex-footer { margin-top: 24px; padding: 12px 0 0; border: none !important; box-shadow: none !important; border-top: 1px solid var(--ex-line) !important; background: none; font-family: var(--ex-font); font-size: 11.5px; color: var(--ex-ink-3); text-align: center; }

/* ---------- reusable blocks for new / reworked pages ---------- */
.ex-page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.ex-page-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.ex-page-head .ex-sub { color: var(--ex-ink-2); font-size: 13.5px; margin-top: 3px; }
.ex-page-head .ex-act { margin-left: auto; display: flex; gap: 10px; }
.ex-card { background: var(--ex-surface); border: 1px solid var(--ex-line); border-radius: var(--ex-r); box-shadow: var(--ex-shadow); margin-bottom: 16px; }
.ex-card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--ex-line-2); }
.ex-card-h h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.ex-card-b { padding: 18px; }
.ex-btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--ex-blue); background: var(--ex-blue); color: #fff !important; font-size: 13.5px; font-weight: 650; white-space: nowrap; box-shadow: var(--ex-shadow); text-decoration: none !important; cursor: pointer; }
.ex-btn:hover { background: var(--ex-blue-2); border-color: var(--ex-blue-2); }
.ex-btn.ghost { background: var(--ex-surface); color: var(--ex-ink-2) !important; border-color: var(--ex-line); }
.ex-btn.ghost:hover { background: var(--ex-surface-2); color: var(--ex-ink) !important; }

/* ---------- legacy page widgets, restyled ---------- */
/* a row of filter boxes (list / report pages) becomes one filter panel */
.ex-content .row.clearleft-custom { margin: 0 0 16px; padding: 6px 4px 2px; background: var(--ex-surface); border: 1px solid var(--ex-line); border-radius: var(--ex-r); box-shadow: var(--ex-shadow); }
.ex-content .row.clearleft-custom .thumbnail.thumbnail-mod-1 { border: none; box-shadow: none; background: transparent; margin-bottom: 4px; max-width: none; padding: 0; }
/* single form card (entry pages) */
.ex-content .thumbnail.thumbnail-mod-1 { max-width: none; background: var(--ex-surface); border: 1px solid var(--ex-line); border-top: 3px solid var(--ex-blue); border-radius: var(--ex-r); box-shadow: var(--ex-shadow); padding: 4px 6px; margin-bottom: 14px; }
.ex-content .form { background: transparent; padding-top: 8px; }
.ex-content .form p.contact, .ex-content p.contact { color: var(--ex-ink-2); font-size: 12.5px; font-weight: 650; }
.ex-content .form label, .ex-content .form fieldset label { font-family: var(--ex-font); color: var(--ex-ink-2); }
.ex-content .form input, .ex-content .form textarea, .ex-content .form select { font-family: var(--ex-font); font-size: 13px; color: var(--ex-ink); border: 1px solid var(--ex-line); border-radius: 8px; padding: 5px 8px; }
.ex-content .form input:focus, .ex-content .form textarea:focus, .ex-content .form select:focus { outline: none; border-color: var(--ex-blue); box-shadow: 0 0 0 3px var(--ex-blue-ring); }
.ex-content input[type="submit"], .ex-content input[type="button"].btn-primary, .ex-content .form input[type="submit"] {
    background: var(--ex-blue); border: 1px solid var(--ex-blue); color: #fff; font-family: var(--ex-font); font-size: 13px; font-weight: 650; border-radius: 9px; padding: 7px 14px; box-shadow: var(--ex-shadow); }
.ex-content input[type="submit"]:hover { background: var(--ex-blue-2); border-color: var(--ex-blue-2); }
.ex-content .btn { border-radius: 8px; }
.ex-content .btn-primary { background: var(--ex-blue); border-color: var(--ex-blue); }
.ex-content .btn-primary:hover { background: var(--ex-blue-2); border-color: var(--ex-blue-2); }

/* tables / DataTables */
.ex-content .dataTables_wrapper, .ex-content table.table { background: var(--ex-surface); }
.ex-content .dataTables_wrapper { border: 1px solid var(--ex-line); border-radius: var(--ex-r); box-shadow: var(--ex-shadow); padding: 10px 12px; overflow-x: auto; }
.ex-content table.dataTable tbody tr, .ex-content table.dataTable tbody tr.odd, .ex-content table.dataTable tbody tr.even { background: var(--ex-surface) !important; }
.ex-content table.dataTable tbody tr.odd { background: var(--ex-surface-2) !important; }
.ex-content table.dataTable tbody tr:hover, .ex-content table.dataTable tbody tr:hover td { background: var(--ex-blue-weak) !important; }
.ex-content .dataTables_length select { border: 1px solid var(--ex-line); border-radius: 8px; height: 32px; padding: 0 8px; }
.ex-content .dataTables_info { color: var(--ex-ink-2); font-size: 12.5px; }
.ex-content .pagination > li > a, .ex-content .page-link { color: var(--ex-blue-2); border-color: var(--ex-line); }
.ex-content table.table { border-color: var(--ex-line); font-size: 13px; }
.ex-content table.table > thead > tr > th { background: var(--ex-head); color: var(--ex-ink-3); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; border-bottom: 1px solid var(--ex-line) !important; white-space: nowrap; }
.ex-content table.table > tbody > tr > td { border-color: var(--ex-line-2); vertical-align: middle; }
.ex-content table.table-striped > tbody > tr:nth-of-type(odd) { background: var(--ex-surface-2); }
.ex-content .table tbody tr:hover { background-color: var(--ex-blue-weak) !important; }
.ex-content .table tbody tr:hover td:hover { background-color: #d5ebf8 !important; }
.ex-content .yellowtext { background: var(--ex-warn-bg); color: var(--ex-warn-ink); border-radius: 20px; font-weight: 700; }
.ex-content .redtext { background: var(--ex-crit-bg); color: var(--ex-crit-ink); border-radius: 20px; font-weight: 700; }
.ex-content .greentext { background: var(--ex-good-bg); color: var(--ex-good-ink); border-radius: 20px; padding: 1px 9px; font-weight: 700; }
.ex-content .pagination > .active > a, .ex-content .pagination > .active > a:hover, .ex-content .page-item.active .page-link { background: var(--ex-blue); border-color: var(--ex-blue); color: #fff !important; }

/* ---------- small screens: sidebar becomes a drawer ---------- */
@media (max-width: 900px) {
    .ex-app, .ex-app.collapsed { grid-template-columns: 1fr; }
    .ex-side { position: fixed; z-index: 1000; top: 0; bottom: 0; left: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
    .ex-app.collapsed .ex-side { transform: none; }
    .ex-app.collapsed .ex-nav-lab, .ex-app.collapsed .ex-nav-item span, .ex-app.collapsed .ex-user-meta,
    .ex-app.collapsed .ex-nav-search, .ex-app.collapsed .ex-side-powered { display: revert; }
    .ex-app.collapsed .ex-nav-item .ex-chev { display: block; }
    .ex-app.collapsed .ex-side-logo { width: auto; padding: 2px 4px; }
    .ex-app.collapsed .ex-nav-group.open > .ex-nav-sub { display: block; }
    .ex-app.collapsed .ex-nav-item { justify-content: flex-start; padding: 9px 11px; }
    .ex-topbar { padding: 0 12px !important; gap: 10px; }
    .ex-bc { display: none; }
    .ex-content { padding: 12px; }
    .ex-unit select { min-width: 0; max-width: 130px; }
}

/* phone drawer backdrop */
.ex-scrim { display: none; }
@media (max-width: 900px) {
    .ex-app.collapsed .ex-scrim { display: block; position: fixed; inset: 0; z-index: 999; background: rgba(10,18,30,.45); }
}

/* ---------- loader: the erpidex logo, letter by letter (images/erpidex-mark.svg) ---------- */
.ex-loader { width: 124px; height: 36px; display: inline-grid; place-items: center; flex: none; }
.ex-loader img { width: 124px; height: auto; display: block; }
/* the pages' own wait overlay (~285 pages: <div id="loading" style="…grey…"><p style="…">Loading, please wait…<img ajax-loading.gif></p></div>,
   shown / hidden by the page with $('#loading').show() / .hide()): the same ERPidex loader, from here only.
   !important beats the inline styles; the page keeps deciding when it shows. */
#loading { background: rgba(255, 255, 255, .96) !important; opacity: 1 !important; filter: none !important; backdrop-filter: blur(1.5px); }
#loading > p { top: 50% !important; left: 50% !important; transform: translate(-50%, -50%); margin: 0; color: var(--ex-ink-2) !important;
    font: 600 13px var(--ex-font); display: flex; flex-direction: column; align-items: center; gap: 14px;
    background: #fff; padding: 26px 34px 22px; border-radius: 14px; white-space: nowrap; }
#loading > p::before { content: ""; width: 124px; height: 36px; background: url("../images/erpidex-mark.svg") center / contain no-repeat; }
#loading img[src*="ajax-loading"] { display: none; }
/* a list area while its rows load: <div class="ex-loading"><span class="ex-loader"><img src="erpidex-mark.svg"></span>Loading…</div> */
.ex-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 56px 16px; color: var(--ex-ink-2); font-size: 13px; }
