/* Staff Portal FAVOURITES - Darren 2026-11-06. The star at the top of every page, the Favourites section at the top of
   the menu, and its Edit panel. Behaviour: js/favourites.js. Colours come from the portal tokens (--sx-* in
   SiteMaster, following Css/themes.css and the operator theme) with the Enigma values as fallbacks; the suite portals
   (Report / Sync / Agent / Accounting / Channex / Integration) have no --sx tokens, so the fallbacks are what they see.
   Gold = "pinned", the same hue as the Switch button's accent. */

/* ---------- the star ---------- */
[data-fav-star][hidden] { display: none !important; }
[data-fav-star] { cursor: pointer; font-family: inherit; }
[data-fav-star] .bi { transition: transform .15s ease; }
[data-fav-star][aria-pressed="true"] .bi { color: var(--sx-gold, #E5A100); }   /* js swaps bi-star <-> bi-star-fill */
[data-fav-star].fav-pop .bi { transform: scale(1.3); }
[data-fav-star]:focus-visible { outline: 2px solid var(--sx-olive, #4B6F0A); outline-offset: 2px; }
.sx-pill.sx-fav-star { border-style: solid; }
.sx-pill.sx-fav-star[aria-pressed="true"] { background: color-mix(in srgb, var(--sx-gold, #E5A100) 12%, transparent);
    border-color: color-mix(in srgb, var(--sx-gold, #E5A100) 35%, transparent); }
.sx-pill.sx-fav-star[aria-pressed="true"]:hover { background: var(--sx-gold, #E5A100); border-color: var(--sx-gold, #E5A100); }
.sx-pill.sx-fav-star[aria-pressed="true"]:hover .bi { color: #fff; }

/* ---------- the menu section ---------- */
.sx-fav-headrow { display: flex; align-items: center; }
.sx-fav-headrow .sx-nav-section-head { flex: 1; min-width: 0; }
.sx-fav-mark { color: var(--sx-gold, #E5A100); font-size: 9px; margin-right: 5px; vertical-align: 1px; }
.sx-fav-edit { flex: none; width: 28px; height: 28px; margin: 4px 2px 0 0; border: 0; border-radius: 7px; background: transparent; cursor: pointer;
    color: var(--sx-text-hint, #64748b); display: grid; place-items: center; font-size: 12px; padding: 0; }
.sx-fav-edit:hover { background: var(--sx-bg-soft, #f1f5f9); color: var(--sx-olive, #4B6F0A); }
.sx-fav-edit:focus-visible { outline: 2px solid var(--sx-olive, #4B6F0A); outline-offset: 1px; }
.sx-fav-item .sx-fav-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-fav-empty { margin: 0 4px 6px; padding: 8px 10px; border: 1px dashed var(--sx-border, #e5e7eb); border-radius: 8px;
    font-size: 11.5px; line-height: 1.5; color: var(--sx-text-hint, #64748b); }
.sx-fav-empty .bi { color: var(--sx-gold, #E5A100); }
.sx-fav-link { border: 0; background: none; padding: 0; font: inherit; color: var(--sx-olive, #4B6F0A); font-weight: 600;
    text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* First 5 only (Darren 2026-11-08: "the fav list will be very long and it will block other menu"). The rest open in place
   under "Show N more"; html.sx-fav-all = open (localStorage sx-fav-all, set before paint by SiteMaster's head script).
   Pure CSS so a long list never flashes open on load. 5 = SHOW in js/favourites.js - change both together.
   Only where the master has the Show more button (#sxFavMore): the suite portals load this file under an older ?v=, so
   Cloudflare can pair it with an older SiteMaster (e.g. after a revert) - then nothing is hidden. .has-more = js fallback. */
html:not(.sx-fav-all) #sxFavSec.has-more #sxFavList > .sx-fav-item:nth-child(n+6) { display: none; }
@supports selector(:has(a)) { html:not(.sx-fav-all) #sxFavSec:has(#sxFavMore) #sxFavList > .sx-fav-item:nth-child(n+6) { display: none; } }
.sx-fav-more { display: none; align-items: center; gap: 11px; width: 100%; min-height: 36px; margin: 0 0 1px; padding: 7px 12px; border: 0; border-radius: 7px;
    background: transparent; cursor: pointer; text-align: left; font-family: inherit; font-size: 12.5px; font-weight: 500;
    color: var(--sx-text-hint, #64748b); }
.sx-fav-more .bi { width: 16px; text-align: center; flex-shrink: 0; font-size: 12px; }
.sx-fav-more:hover { background: var(--sx-bg-soft, #f1f5f9); color: var(--sx-olive, #4B6F0A); }
.sx-fav-more:focus-visible { outline: 2px solid var(--sx-olive, #4B6F0A); outline-offset: -2px; }
/* shown only when there are more than 5: :has() at first paint, .has-more (js) for browsers without :has() */
#sxFavSec.has-more .sx-fav-more { display: flex; }
@supports selector(:has(a)) { #sxFavSec:has(#sxFavList > .sx-fav-item:nth-child(6)) .sx-fav-more { display: flex; } }
/* finger-sized on touch screens (iPad, phones) */
@media (pointer: coarse) {
    .sx-fav-more { min-height: 48px; }
    .sx-fav-edit { width: 40px; height: 40px; margin-top: 0; font-size: 14px; }
}

/* ---------- toast (star added / removed, "You are now working in QKeys") ---------- */
.sx-toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 16px); z-index: 10050; opacity: 0; pointer-events: none;
    display: flex; align-items: center; gap: 9px; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
    background: #1f2a12; color: #f8fafc; font-family: "Inter", -apple-system, "Segoe UI", sans-serif; font-size: 13px; line-height: 1.4;
    box-shadow: 0 10px 30px rgba(15,23,42,.28); transition: opacity .2s ease, transform .2s ease; }
.sx-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.sx-toast .bi { color: var(--sx-gold, #E5A100); font-size: 15px; flex: none; }
.sx-toast b { color: #fff; }
#sxSwitchToast { animation: sx-toast-out .3s ease 5s forwards; }
@keyframes sx-toast-out { to { opacity: 0; transform: translate(-50%, 16px); } }

/* ---------- Edit panel (Staff Portal only) ---------- */
.fav-ov { position: fixed; inset: 0; background: rgba(15,23,42,.42); z-index: 9998; }
.fav-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); z-index: 9999; background: var(--sx-bg, #fff);
    color: var(--sx-text, #0f172a); box-shadow: -6px 0 28px rgba(15,23,42,.18); display: flex; flex-direction: column;
    transform: translateX(105%); transition: transform .22s ease; font-size: 13px; }
.fav-panel.is-open { transform: translateX(0); }
.fav-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px 12px; border-bottom: 1px solid var(--sx-border, #e5e7eb);
    background: var(--sx-bg-soft, #f8fafc); }
.fav-head h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--sx-text, #0f172a); }
.fav-head h2 .bi { color: var(--sx-gold, #E5A100); margin-right: 6px; }
.fav-head p { margin: 2px 0 0; font-size: 11.5px; color: var(--sx-text-hint, #64748b); }
.fav-x { margin-left: auto; flex: none; width: 34px; height: 34px; border: 0; background: none; border-radius: 8px; cursor: pointer;
    color: var(--sx-text-hint, #94a3b8); font-size: 17px; display: grid; place-items: center; }
.fav-x:hover { background: var(--sx-border-soft, #eef0ea); color: var(--sx-text, #0f172a); }
.fav-scroll { flex: 1; overflow-y: auto; padding: 6px 12px 18px; }
.fav-sec { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 14px 4px 6px;
    font-size: 10px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--sx-text-hint, #64748b); }
.fav-sec small { font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 11px; }
.fav-list { display: flex; flex-direction: column; gap: 4px; }
.fav-row { display: flex; align-items: center; gap: 6px; padding: 5px 5px 5px 9px; border: 1px solid var(--sx-border, #e5e7eb); border-radius: 9px;
    background: var(--sx-bg, #fff); }
.fav-row.is-off { opacity: .6; }
.fav-row > .bi { flex: none; width: 18px; text-align: center; color: var(--sx-text-soft, #334155); font-size: 14px; }
.fav-name { flex: 1; min-width: 0; height: 32px; border: 1px solid transparent; border-radius: 6px; background: transparent; padding: 0 7px;
    font-family: inherit; font-size: 13px; font-weight: 500; color: var(--sx-text, #0f172a); }
.fav-name:hover { border-color: var(--sx-border, #e5e7eb); }
.fav-name:focus { outline: none; border-color: var(--sx-olive, #4B6F0A); background: var(--sx-bg, #fff);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--sx-olive, #4B6F0A) 14%, transparent); }
.fav-off { font-size: 10.5px; color: #b45309; white-space: nowrap; }
.fav-btn { flex: none; width: 32px; height: 32px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; padding: 0;
    color: var(--sx-text-hint, #64748b); display: grid; place-items: center; font-size: 13px; }
.fav-btn:hover:not(:disabled) { background: var(--sx-bg-soft, #f1f5f9); color: var(--sx-text, #0f172a); }
.fav-btn:disabled { opacity: .3; cursor: default; }
.fav-btn.is-del:hover { background: rgba(226,75,74,.1); color: var(--sx-danger, #e24b4a); }
.fav-btn:focus-visible, .fav-add:focus-visible { outline: 2px solid var(--sx-olive, #4B6F0A); outline-offset: 1px; }
/* the line after the 5th favourite in the Edit panel: what comes after it is under "Show more" in the menu */
.fav-fold { display: flex; align-items: center; gap: 8px; margin: 4px 2px 0; font-size: 10.5px; font-weight: 600; color: var(--sx-text-hint, #64748b); }
.fav-fold::before, .fav-fold::after { content: ""; flex: 1; border-top: 1px dashed var(--sx-border, #e5e7eb); }
.fav-none { padding: 14px 12px; border: 1px dashed var(--sx-border, #e5e7eb); border-radius: 9px; text-align: center;
    color: var(--sx-text-hint, #64748b); font-size: 12px; line-height: 1.55; }
.fav-find { width: 100%; height: 38px; box-sizing: border-box; border: 1px solid var(--sx-border, #e5e7eb); border-radius: 9px; padding: 0 12px;
    font-family: inherit; font-size: 13.5px; color: var(--sx-text, #0f172a); background: var(--sx-bg, #fff); }
.fav-find:focus { outline: none; border-color: var(--sx-olive, #4B6F0A); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sx-olive, #4B6F0A) 14%, transparent); }
.fav-opts { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.fav-opt { display: flex; align-items: center; gap: 9px; padding: 6px 6px 6px 9px; border-radius: 8px; }
.fav-opt:hover { background: var(--sx-bg-soft, #f8fafc); }
.fav-opt > .bi { flex: none; width: 18px; text-align: center; color: var(--sx-olive, #4B6F0A); font-size: 14px; }
.fav-opt-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fav-opt-t b { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-opt-t small { font-size: 11px; color: var(--sx-text-hint, #64748b); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-add { flex: none; display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 11px; border-radius: 8px; cursor: pointer;
    border: 1px solid color-mix(in srgb, var(--sx-olive, #4B6F0A) 30%, transparent); background: var(--sx-olive-tint, rgba(75,111,10,.06));
    color: var(--sx-olive, #4B6F0A); font-family: inherit; font-size: 12px; font-weight: 600; }
.fav-add:hover { background: var(--sx-olive, #4B6F0A); border-color: var(--sx-olive, #4B6F0A); color: #fff; }
.fav-add:disabled { opacity: .45; cursor: default; background: none; }
.fav-hint { margin: 6px 4px 0; font-size: 11.5px; color: var(--sx-text-hint, #64748b); }
.fav-foot { padding: 10px 16px; border-top: 1px solid var(--sx-border, #e5e7eb); font-size: 11.5px; color: var(--sx-text-hint, #64748b);
    display: flex; align-items: center; gap: 8px; min-height: 40px; box-sizing: border-box; }
.fav-foot.is-err { color: #b91c1c; }
.fav-foot .bi { font-size: 13px; }

@media (max-width: 560px) {
    .fav-name, .fav-find { font-size: 16px; }   /* stops iOS zooming into the box */
}
@media (prefers-reduced-motion: reduce) {
    .fav-panel, .sx-toast, [data-fav-star] .bi { transition: none; }
    #sxSwitchToast { animation-duration: .01s; }
}
@media print { .fav-panel, .fav-ov, .sx-toast { display: none !important; } }

/* suite portals: the star is a <button> wearing the top bar's link style */
button.fav-suite-star { background: transparent; padding: 0; font: inherit; line-height: 1; }
