/*
 * Momina ERP UI components that follow the colour theme: toasts, slim scrollbars, the themed
 * dropdown that replaces native <select> menus, and matching Bootstrap / Select2 menus.
 */

/* ---------- Toasts (flash messages, App.toast) ---------- */
.toast-stack { position: fixed; top: calc(var(--topbar-h, 60px) + .5rem); right: 1rem; z-index: 2100; display: flex; flex-direction: column; gap: .5rem; width: min(380px, calc(100vw - 2rem)); pointer-events: none; }
.app-toast { pointer-events: auto; display: flex; align-items: flex-start; gap: .65rem; padding: .75rem .85rem; border-radius: 10px; background: var(--surface, #fff); color: var(--ink, #1b2533);
    border: 1px solid var(--line, #e3e8ef); border-left: 4px solid var(--toast-accent); box-shadow: 0 10px 28px rgba(15, 23, 42, .18); font-size: .9rem; animation: toast-in .25s ease-out; }
.app-toast.is-leaving { animation: toast-out .25s ease-in forwards; }
.app-toast-icon { color: var(--toast-accent); font-size: 1.1rem; line-height: 1.3; }
.app-toast-body { flex: 1; line-height: 1.4; overflow-wrap: anywhere; }
.app-toast-close { font-size: .7rem; margin-top: .2rem; }
.app-toast.is-success { --toast-accent: #16a34a; }
.app-toast.is-danger { --toast-accent: #dc2626; }
.app-toast.is-warning { --toast-accent: #d97706; }
.app-toast.is-info { --toast-accent: var(--brand, #10498A); }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }
@media (prefers-reduced-motion: reduce) { .app-toast, .app-toast.is-leaving { animation: none; } }
body.auth .toast-stack { top: 1rem; }

/* ---------- Slim themed scrollbars (everywhere) ---------- */
:root { --scroll-thumb: rgba(100, 116, 139, .45); --scroll-thumb-hover: rgba(100, 116, 139, .7); }
[data-bs-theme="dark"] { --scroll-thumb: rgba(148, 163, 184, .32); --scroll-thumb-hover: rgba(148, 163, 184, .55); }
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }
.sidebar, .sidebar * { scrollbar-color: rgba(255, 255, 255, .22) transparent; }
.sidebar ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .22); border: 2px solid transparent; background-clip: padding-box; }

/* ---------- Themed dropdown for <select> (see UiSelect in app.js) ---------- */
.ui-select { position: relative; display: block; min-width: 0; }
.ui-select.is-inline { display: inline-block; vertical-align: middle; }
.ui-select > select.ui-select-native { position: absolute !important; inset: 0; width: 100% !important; height: 100% !important; opacity: 0 !important; pointer-events: none !important; }
.ui-select-btn { text-align: left; display: flex; align-items: center; gap: .5rem; width: 100%; cursor: pointer; white-space: nowrap; overflow: hidden; background-image: none !important; padding-right: .75rem; }
.ui-select-btn .ui-select-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.ui-select-btn .ui-select-label.is-placeholder { color: var(--muted, #64748b); }
.ui-select-btn .ui-select-caret { flex-shrink: 0; font-size: .7rem; color: var(--muted, #64748b); transition: transform .15s; }
.ui-select-btn[aria-expanded="true"] { border-color: rgba(var(--brand-rgb, 16, 73, 138), .55); box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb, 16, 73, 138), .15); }
.ui-select-btn[aria-expanded="true"] .ui-select-caret { transform: rotate(180deg); }
.ui-select-btn:disabled { cursor: default; background-color: var(--bs-secondary-bg, #e9ecef); opacity: 1; }
.ui-select:has(.is-invalid) ~ .invalid-feedback { display: block; }
.input-group > .ui-select { flex: 1 1 auto; width: 1%; }
.input-group > .ui-select:not(:first-child) .ui-select-btn { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group > .ui-select:not(:last-child) .ui-select-btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }

.ui-select-menu, .dropdown-menu, .select2-container--bootstrap-5 .select2-dropdown, .flatpickr-calendar {
    --menu-shadow: 0 12px 32px rgba(15, 23, 42, .16), 0 2px 6px rgba(15, 23, 42, .08);
}
.ui-select-menu { position: fixed; z-index: 2000; min-width: 160px; max-width: min(480px, calc(100vw - 16px)); background: var(--surface, #fff); color: var(--ink, #1b2533);
    border: 1px solid var(--line, #e3e8ef); border-radius: 10px; box-shadow: var(--menu-shadow); padding: .3rem; display: flex; flex-direction: column; font-size: .9rem; }
.ui-select-menu[hidden] { display: none; }
.ui-select-search { margin: .15rem .15rem .35rem; }
.ui-select-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; max-height: 280px; overscroll-behavior: contain; }
.ui-select-option { padding: .45rem .65rem; border-radius: 7px; cursor: pointer; display: flex; align-items: center; gap: .5rem; line-height: 1.3; }
.ui-select-option .bi-check2 { margin-left: auto; color: var(--brand, #10498A); visibility: hidden; }
.ui-select-option[aria-selected="true"] { font-weight: 600; color: var(--brand, #10498A); }
.ui-select-option[aria-selected="true"] .bi-check2 { visibility: visible; }
.ui-select-option.is-active { background: var(--brand-50, #eef4fb); }
.ui-select-option[aria-disabled="true"] { opacity: .45; cursor: default; }
.ui-select-group { padding: .5rem .65rem .2rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted, #64748b); }
.ui-select-group ~ .ui-select-option { padding-left: 1rem; }
.ui-select-empty { padding: .6rem .65rem; color: var(--muted, #64748b); }
[data-bs-theme="dark"] .ui-select-option[aria-selected="true"], [data-bs-theme="dark"] .ui-select-option .bi-check2 { color: color-mix(in srgb, var(--brand) 60%, #fff); }

/* Bootstrap dropdowns (user menu, notifications, split buttons) */
.dropdown-menu { border: 1px solid var(--line, #e3e8ef); border-radius: 10px; box-shadow: var(--menu-shadow); padding: .3rem; background: var(--surface, #fff); }
.dropdown-item { border-radius: 7px; padding: .45rem .75rem; color: var(--ink, #1b2533); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--brand-50, #eef4fb); color: var(--ink, #1b2533); }
.dropdown-item.active, .dropdown-item:active { background: var(--brand, #10498A); color: #fff; }
.dropdown-divider { border-color: var(--line, #e3e8ef); }
.notif-menu { padding: 0; overflow: hidden; }

/* Select2 (client / item / supplier pickers) to match */
.select2-container--bootstrap-5 .select2-dropdown { border: 1px solid var(--line, #e3e8ef) !important; border-radius: 10px !important; box-shadow: var(--menu-shadow); padding: .3rem; background: var(--surface, #fff); overflow: hidden; }
.select2-container--bootstrap-5.select2-container--open .select2-selection { border-color: rgba(var(--brand-rgb, 16, 73, 138), .55); box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb, 16, 73, 138), .15); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option { border-radius: 7px; padding: .45rem .65rem; color: var(--ink, #1b2533); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--highlighted { background: var(--brand-50, #eef4fb); color: var(--ink, #1b2533); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--selected { background: transparent; color: var(--brand, #10498A); font-weight: 600; }
.select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field { border-radius: 7px; border-color: var(--line, #e3e8ef); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options { scrollbar-width: thin; }

/* Flatpickr calendar to match */
.flatpickr-calendar { border-radius: 10px; box-shadow: var(--menu-shadow); border: 1px solid var(--line, #e3e8ef); }
.flatpickr-calendar.arrowTop::before, .flatpickr-calendar.arrowTop::after, .flatpickr-calendar.arrowBottom::before, .flatpickr-calendar.arrowBottom::after { display: none; }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--brand, #10498A); border-color: var(--brand, #10498A); }
.flatpickr-day.today { border-color: var(--gold, #FBBA00); }

/* Count next to a menu item (approvals waiting) */
.sidebar-link .badge-count { margin-left: auto; min-width: 1.4rem; padding: .05rem .4rem; border-radius: 999px; background: var(--gold, #FBBA00); color: #1b2533; font-size: .7rem; font-weight: 700; text-align: center; }

/* ---------- Guided tour (Tour in app.js) ---------- */
.tour-shield { position: fixed; inset: 0; z-index: 2190; background: transparent; }
.tour-spot { position: fixed; z-index: 2191; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .58); outline: 2px solid rgba(255, 255, 255, .9); pointer-events: none; transition: left .25s, top .25s, width .25s, height .25s; }
.tour-pop { position: fixed; z-index: 2192; background: var(--surface, #fff); color: var(--ink, #1b2533); border-radius: 12px; box-shadow: 0 18px 50px rgba(15, 23, 42, .35); padding: 1rem 1.1rem .85rem; border-top: 4px solid var(--brand, #10498A); }
.tour-shield[hidden], .tour-spot[hidden], .tour-pop[hidden] { display: none; }
.tour-x { position: absolute; top: .7rem; right: .7rem; font-size: .7rem; }
.tour-count { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted, #64748b); padding-right: 1.5rem; }
.tour-title { font-size: 1.05rem; font-weight: 700; margin: .3rem 0 .35rem; color: var(--brand, #10498A); }
.tour-text { margin: 0 0 .7rem; font-size: .9rem; line-height: 1.5; }
.tour-dots { display: flex; gap: 4px; margin-bottom: .7rem; flex-wrap: wrap; }
.tour-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--line, #e3e8ef); }
.tour-dots span.on { background: var(--brand, #10498A); width: 18px; border-radius: 4px; }
.tour-actions { display: flex; align-items: center; gap: .4rem; }
.tour-off { padding-left: 0; font-size: .78rem; color: var(--muted, #64748b); text-decoration: none; }
.tour-off:hover { text-decoration: underline; }
.tour-more { display: block; margin-top: .6rem; font-size: .82rem; }
[data-bs-theme="dark"] .tour-title, [data-bs-theme="dark"] .tour-more { color: color-mix(in srgb, var(--brand) 55%, #fff); }
@media (prefers-reduced-motion: reduce) { .tour-spot { transition: none; } }
.help-menu { min-width: 260px; }

/* ---------- Help centre ---------- */
.help-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.help-layout.has-toc { grid-template-columns: 250px minmax(0, 1fr) 200px; }
/* The topic list stays in view below the top bar while the page scrolls (the grid item itself is sticky). */
.help-nav-wrap { position: sticky; top: calc(var(--topbar-h, 60px) + 1rem); align-self: start; z-index: 1; }
.help-nav { position: relative; max-height: calc(100vh - var(--topbar-h, 60px) - 2rem); overflow-y: auto; overscroll-behavior: contain; font-size: .88rem; }
.help-nav h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted, #64748b); margin: 1rem 0 .3rem; font-weight: 700; }
.help-nav a { display: block; padding: .28rem .55rem; border-radius: 7px; color: var(--ink, #1b2533); text-decoration: none; }
.help-nav a:hover { background: var(--brand-50, #eef4fb); }
.help-nav a.active { background: var(--brand-50, #eef4fb); color: var(--brand, #10498A); font-weight: 600; }
.help-toc { position: sticky; top: calc(var(--topbar-h, 60px) + 1rem); font-size: .82rem; border-left: 2px solid var(--line, #e3e8ef); padding-left: .8rem; }
.help-toc a { display: block; padding: .2rem 0; color: var(--muted, #64748b); text-decoration: none; }
.help-toc a:hover, .help-toc a.active { color: var(--brand, #10498A); }
.help-article { max-width: 860px; line-height: 1.65; font-size: .95rem; }
.help-article h1 { font-size: 1.7rem; font-weight: 700; margin-bottom: .3rem; }
.help-article h2 { font-size: 1.3rem; font-weight: 700; margin: 2.2rem 0 .7rem; padding-top: .4rem; scroll-margin-top: calc(var(--topbar-h, 60px) + 1rem); color: var(--brand, #10498A); }
.help-article h3 { font-size: 1.05rem; font-weight: 700; margin: 1.5rem 0 .5rem; scroll-margin-top: calc(var(--topbar-h, 60px) + 1rem); }
.help-article h4 { font-size: .95rem; font-weight: 700; margin: 1.2rem 0 .4rem; }
.help-article ol, .help-article ul { padding-left: 1.4rem; }
.help-article li { margin-bottom: .35rem; }
.help-article li > ul, .help-article li > ol { margin-top: .35rem; }
.help-anchor { opacity: 0; font-size: .8em; text-decoration: none; margin-left: .3rem; color: var(--muted, #64748b); }
.help-article h2:hover .help-anchor, .help-article h3:hover .help-anchor { opacity: 1; }
.help-btn { display: inline-block; padding: 0 .45rem; border: 1px solid var(--line, #d7dee8); border-bottom-width: 2px; border-radius: 6px; background: var(--surface-2, #f6f8fb); font-size: .86em; font-weight: 600; white-space: nowrap; line-height: 1.55; }
.help-shot { margin: 1rem 0 1.4rem; }
.help-shot img { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line, #e3e8ef); box-shadow: 0 6px 20px rgba(15, 23, 42, .08); cursor: zoom-in; }
.help-shot figcaption { font-size: .82rem; color: var(--muted, #64748b); margin-top: .45rem; text-align: center; }
.help-callout { display: flex; gap: .7rem; padding: .75rem .95rem; border-radius: 10px; margin: 1rem 0; border: 1px solid; }
.help-callout > i { font-size: 1.1rem; line-height: 1.5; }
.help-callout p { margin: 0 0 .35rem; }
.help-callout p:last-child { margin-bottom: 0; }
.help-callout.is-tip { background: rgba(22, 163, 74, .07); border-color: rgba(22, 163, 74, .3); }
.help-callout.is-tip > i { color: #16a34a; }
.help-callout.is-note, .help-callout.is-example { background: rgba(var(--brand-rgb, 16, 73, 138), .06); border-color: rgba(var(--brand-rgb, 16, 73, 138), .25); }
.help-callout.is-note > i, .help-callout.is-example > i { color: var(--brand, #10498A); }
.help-callout.is-warning { background: rgba(217, 119, 6, .08); border-color: rgba(217, 119, 6, .35); }
.help-callout.is-warning > i { color: #d97706; }
.help-callout.is-important { background: rgba(220, 38, 38, .07); border-color: rgba(220, 38, 38, .3); }
.help-callout.is-important > i { color: #dc2626; }
.help-table { font-size: .88rem; }
.help-table th { white-space: nowrap; }
.help-code { background: var(--surface-2, #f6f8fb); border: 1px solid var(--line, #e3e8ef); border-radius: 8px; padding: .7rem .9rem; font-size: .85rem; }
.help-hero { background: linear-gradient(135deg, var(--brand, #10498A), var(--hero-end, #0a305b)); color: #fff; border-radius: 14px; padding: 1.8rem 1.6rem; margin-bottom: 1.5rem; }
.help-hero h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: .3rem; }
.help-hero .form-control { border: 0; padding: .7rem 1rem; font-size: 1rem; }
.help-suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 1050; margin-top: .3rem; background: var(--surface, #fff); color: var(--ink, #1b2533); border: 1px solid var(--line, #e3e8ef); border-radius: 10px; box-shadow: 0 12px 32px rgba(15, 23, 42, .18); overflow: hidden; }
.help-suggest a { display: block; padding: .55rem .85rem; color: inherit; text-decoration: none; border-bottom: 1px solid var(--line, #e3e8ef); }
.help-suggest a:last-child { border-bottom: 0; }
.help-suggest a:hover, .help-suggest a.is-active { background: var(--brand-50, #eef4fb); }
.help-topic-card { display: flex; gap: .8rem; padding: .85rem; border-radius: 10px; border: 1px solid var(--line, #e3e8ef); background: var(--surface, #fff); color: inherit; text-decoration: none; height: 100%; transition: border-color .15s, box-shadow .15s; }
.help-topic-card:hover { border-color: rgba(var(--brand-rgb, 16, 73, 138), .45); box-shadow: 0 6px 18px rgba(15, 23, 42, .08); }
.help-topic-card i { font-size: 1.3rem; color: var(--brand, #10498A); }
.help-topic-card strong { display: block; }
.help-topic-card span { font-size: .82rem; color: var(--muted, #64748b); }
.help-result { padding: .9rem 0; border-bottom: 1px solid var(--line, #e3e8ef); }
.help-result mark { padding: 0 .1rem; background: rgba(251, 186, 0, .35); color: inherit; }
.help-faq details { border: 1px solid var(--line, #e3e8ef); border-radius: 10px; margin-bottom: .5rem; background: var(--surface, #fff); scroll-margin-top: calc(var(--topbar-h, 60px) + 1rem); }
.help-faq summary { padding: .75rem 1rem; font-weight: 600; cursor: pointer; list-style: none; display: flex; gap: .6rem; }
.help-faq summary::-webkit-details-marker { display: none; }
.help-faq summary::before { content: "+"; font-weight: 700; color: var(--brand, #10498A); width: 1rem; }
.help-faq details[open] summary::before { content: "−"; }
.help-faq details > div { padding: 0 1rem .8rem 2.6rem; }
.help-zoom { position: fixed; inset: 0; z-index: 2200; background: rgba(15, 23, 42, .85); display: flex; align-items: center; justify-content: center; padding: 2rem; cursor: zoom-out; }
.help-zoom img { max-width: 100%; max-height: 100%; border-radius: 8px; }
@media (max-width: 1199.98px) { .help-layout.has-toc { grid-template-columns: 230px minmax(0, 1fr); } .help-toc { display: none; } }
@media (max-width: 991.98px) { .help-layout, .help-layout.has-toc { grid-template-columns: 1fr; } .help-nav-wrap { position: static; order: 2; } .help-nav { max-height: none; } }
@media print { .sidebar, .topbar, .help-nav-wrap, .help-toc, .help-page-actions { display: none !important; } .help-layout { display: block; } }
