/* OrNsoft Theme — page-specific styles: dashboard. Loaded after ornsoft-ui.css (the .ons-*
   kit) and ornsoft-perfex.css (the core markup restyling).

   Covers the module copies of admin/dashboard/dashboard.php, its KPI row and every dashboard
   widget, all rebuilt on the design system card catalogue (D00–D28 in dashboard-cards.html).

   The first two blocks hold the page primitives shared with the other page stylesheets (the
   page wrapper, the KPI row, the progress bar tones, link-styled buttons and the tab bars);
   they are used by the projects, customers and sales pages too, which is why they live here
   rather than in a single page's stylesheet. Tokens only - no raw colours, so light and dark
   both follow ornsoft-tokens.css.
   ------------------------------------------------------------------------------------- */

/* --- shared page primitives ----------------------------------------------------------- */

/* Vertical rhythm for a page body inside the platform's #wrapper > .content.
   (.ons-page in the kit is a pagination button - the page wrapper is .ons-screen.) */
body.admin .ons-screen {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}

/* A row of .ons-kpi cards. Four across, two on tablets, one on phones. */
body.admin .ons-kpi-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

body.admin .ons-kpi__label i {
  width: 16px;
  font-size: 15px;
  text-align: center;
  color: var(--fg-muted);
  flex: none;
}

body.admin .ons-kpi__label-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.admin .ons-kpi__value--warning {
  color: var(--warning);
}

body.admin .ons-kpi .ons-progress {
  margin-top: 6px;
}

body.admin .ons-progress--accent > span {
  background: var(--accent);
}

body.admin .ons-progress--info > span {
  background: var(--info);
}

body.admin .ons-progress--warning > span {
  background: var(--warning);
}

body.admin .ons-progress--danger > span {
  background: var(--danger);
}

/* Card variants used by the page copies: padded card without the kit's __body element. */
body.admin .ons-card--pad {
  padding: var(--card-pad);
}

body.admin .ons-card--pad > .ons-card__head {
  padding: 0;
  margin-bottom: 16px;
}

body.admin .ons-card__head--plain .ons-card__title {
  font-size: var(--fs-md);
  font-weight: 600;
}

@media (max-width: 1200px) {
  body.admin .ons-kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  body.admin .ons-kpi-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Links styled as buttons.
   ornsoft-perfex.css colours every admin link (body.admin a { color: var(--accent-text) }),
   which outranks the kit's .ons-btn rules, so an <a class="ons-btn"> would take the link
   colour - on a primary button that leaves pale blue text on the accent fill. These rules
   give the button back its own colour wherever this theme renders an action as a link
   ("New project", "Gantt", "Invoice project", "New task", "View all", ...). */
body.admin a.ons-btn,
body.admin a.ons-btn:hover,
body.admin a.ons-btn:focus {
  color: var(--fg);
  text-decoration: none;
}

body.admin a.ons-btn--primary,
body.admin a.ons-btn--primary:hover,
body.admin a.ons-btn--primary:focus {
  color: var(--accent-fg);
}

body.admin a.ons-btn--dark,
body.admin a.ons-btn--dark:hover,
body.admin a.ons-btn--dark:focus {
  color: var(--fg-inverse);
}

body.admin a.ons-btn--danger,
body.admin a.ons-btn--danger:hover,
body.admin a.ons-btn--danger:focus {
  color: var(--danger);
}

body.admin a.ons-btn--ghost {
  color: var(--fg-secondary);
}

body.admin a.ons-btn--ghost:hover,
body.admin a.ons-btn--ghost:focus {
  color: var(--fg);
}

/* --- tab bars (shared) ----------------------------------------------------------------- */

/* Every tab bar in the theme keeps the platform's ul.nav.nav-tabs > li[.active] > a structure
   - main.js sets .active on the li for the project workspace, Bootstrap does it for the
   dashboard card - so the Bootstrap nav-tabs chrome has to be neutralised here. The rules are
   shared, which is why they sit in this file rather than in a single page stylesheet. */
body.admin ul.ons-tabs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

body.admin ul.ons-tabs::-webkit-scrollbar {
  display: none;
}

body.admin ul.ons-tabs > li {
  float: none;
  margin: 0;
  position: relative;
}

body.admin ul.ons-tabs > li > a.ons-tab,
body.admin ul.ons-tabs > li.active > a.ons-tab {
  height: 44px;
  padding: 0 12px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--fg-muted);
  line-height: 44px;
}

body.admin ul.ons-tabs > li > a.ons-tab:hover,
body.admin ul.ons-tabs > li > a.ons-tab:focus {
  background: transparent;
  border: 0;
  color: var(--fg);
  text-decoration: none;
}

body.admin ul.ons-tabs > li.active > a.ons-tab {
  color: var(--fg);
  font-weight: 600;
}

body.admin ul.ons-tabs > li.active > a.ons-tab::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
}

body.admin ul.ons-tabs > li > a.ons-tab .menu-icon {
  margin-right: 6px;
  color: var(--fg-faint);
  font-size: 14px;
}

body.admin ul.ons-tabs > li.active > a.ons-tab .menu-icon {
  color: var(--accent-text);
}

body.admin ul.ons-tabs > li > a.ons-tab .ons-badge {
  height: 18px;
  padding: 0 6px;
  font-size: 10.5px;
  float: none;
  margin-left: 6px;
  vertical-align: 1px;
}

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

/* One band per widget container row, following the catalogue's layout rules: the KPI row
   first, then the action card and the main breakdown side by side, then the lists, charts
   last (which card starts in which column is set by the get_dashboard_widgets filter). The
   [data-container] attributes stay on the elements the dashboard sortable reads, so drag and
   drop between containers is unchanged. */
body.admin .ons-dash__band {
  display: grid;
  gap: var(--gap);
  min-width: 0;
}

body.admin .ons-dash__band--halves {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.admin .ons-dash__band--main {
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  align-items: start;
}

body.admin .ons-dash__band--thirds {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.admin .ons-dash__col {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}

@media (max-width: 1200px) {
  body.admin .ons-dash__band--thirds {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* One column below 820px, as the catalogue asks. */
@media (max-width: 820px) {
  body.admin .ons-dash__band--halves,
  body.admin .ons-dash__band--main,
  body.admin .ons-dash__band--thirds {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* 1.0.0 gives every [data-container] the widget-area gutter (and the platform a bottom
   margin); the band grid owns that spacing now, so both are reset here. The selector matches
   the specificity of the 1.0.0 rule it replaces (body.admin.dashboard .content
   [data-container] in ornsoft-perfex.css). */
body.admin.dashboard .content .ons-dash [data-container],
body.admin .ons-dash [data-container] {
  padding: 0;
  margin: 0;
}

/* A band whose containers hold no visible widget must not leave a gap behind. The widget
   area preview (dashboard_js.php) re-shows them by adding .preview-widgets. */
body.admin .ons-dash__band:not(.preview-widgets):not(:has(.preview-widgets)):not(:has(.widget:not(.hide))) {
  display: none;
}

/* --- widgets are cards ----------------------------------------------------------------- */

body.admin .ons-dash .widget {
  min-width: 0;
  margin: 0;
}

/* The drag handle lives in the card head now (D00), not floating outside the widget; the
   platform's sortable still binds to .widget-dragger, and its grip glyph comes from core. */
body.admin .ons-dash .widget-dragger {
  position: static;
  display: inline-flex;
  align-items: center;
  padding: 0 2px;
  color: var(--fg-faint);
  cursor: grab;
}

body.admin .ons-dash .widget-dragger:hover {
  color: var(--fg-muted);
}

/* Font Awesome is the admin icon set, so the icon sizes the kit gives its own [data-lucide]
   elements are restated here for the <i> elements the views render. */
body.admin .ons-dash .ons-card__actions .ons-btn i,
body.admin .ons-dash .ons-quickadd i,
body.admin .ons-dash .ons-money span i {
  font-size: 13px;
  color: inherit;
}

body.admin .ons-dash .ons-due i,
body.admin .ons-dash .ons-prio i,
body.admin .ons-dash .ons-pill i {
  font-size: 11px;
}

body.admin .ons-dash .ons-chk i {
  font-size: 9px;
}

body.admin .ons-dash .ons-widget-empty i {
  font-size: 24px;
  color: var(--fg-faint);
}

body.admin .ons-dash .ons-watch__ic i {
  font-size: 17px;
}

body.admin .ons-dash .ons-act__verb i {
  font-size: 8px;
}

body.admin .ons-dash .ons-avatar i {
  font-size: 11px;
}

/* The kit paints a ranked bar with the accent; a card that carries its own series colour
   passes it as --c. */
body.admin .ons-dash .ons-bar__track > span {
  background: var(--c, var(--accent));
}

/* The single full-width portfolio bar (D28) reads as one object, not as a thin meter. */
body.admin .ons-dash .ons-splitbar--lg {
  height: 12px;
  gap: 2px;
  background: transparent;
}

body.admin .ons-dash .ons-splitbar--lg > i {
  border-radius: 4px;
}

/* Every card keeps its own link colour inside lists (the admin link colour would repaint
   half of a row). */
body.admin .ons-dash .ons-wk__t a,
body.admin .ons-dash .ons-todo__item a,
body.admin .ons-dash .ons-ev a,
body.admin .ons-dash .ons-next a,
body.admin .ons-dash .ons-doc__list a,
body.admin .ons-dash .ons-person a,
body.admin .ons-dash .ons-act__line a,
body.admin .ons-dash .ons-feed__item > div > a {
  color: inherit;
}

body.admin .ons-dash .ons-wk__t a:hover,
body.admin .ons-dash .ons-todo__item a:hover,
body.admin .ons-dash .ons-ev a:hover,
body.admin .ons-dash .ons-next a:hover,
body.admin .ons-dash .ons-doc__list a:hover,
body.admin .ons-dash .ons-person a:hover,
body.admin .ons-dash .ons-act__line a:hover,
body.admin .ons-dash .ons-feed__item > div > a:hover {
  color: var(--accent-text);
  text-decoration: none;
}

/* --- KPI row --------------------------------------------------------------------------- */

body.admin .ons-dash .ons-kpi-row .ons-kpi {
  box-shadow: var(--shadow-sm);
}

body.admin .ons-dash .ons-kpi__value {
  line-height: 1.1;
}

body.admin .ons-dash .ons-kpi__ico i {
  font-size: 14px;
  color: inherit;
}

/* The hero's split legend sits between the figure and its meta line. */
body.admin .ons-dash .ons-kpi__legend {
  margin-top: 8px;
  flex-direction: column;
  gap: 4px;
}

body.admin .ons-dash .ons-kpi--hero .ons-kpi__legend {
  color: #c9ced8;
}

/* The figures in the legend follow the tile they sit on - on the hero that is the light text
   of the night surface, not the page foreground the other legends use. */
body.admin .ons-dash .ons-kpi .ons-kpi__legend b {
  font-weight: 600;
  color: inherit;
}

/* --- D19 My work ----------------------------------------------------------------------- */

body.admin .ons-dash .ons-wkcard .ons-card__head {
  padding-bottom: 0;
}

body.admin .ons-dash .ons-wkcard ul.ons-tabs {
  padding: 4px var(--card-pad) 0;
  border-bottom: 1px solid var(--border);
}

body.admin .ons-dash .ons-wkcard .tab-content {
  min-width: 0;
}

/* A dot instead of the round complete control on rows that cannot be completed from here
   (a project, a reminder, a ticket); it keeps the row grid and carries the status tone. */
body.admin .ons-dash .ons-wk__dot {
  width: 10px;
  height: 10px;
  margin: 0 4px;
  border-radius: 50%;
  background: var(--tone, var(--fg-faint));
}

body.admin .ons-dash .ons-wk.is-done {
  opacity: 0.45;
}

body.admin .ons-dash .ons-wk.is-done .ons-wk__t b {
  text-decoration: line-through;
}

body.admin .ons-dash .ons-wk__more {
  display: block;
  padding: 10px var(--card-pad);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--accent-text);
}

body.admin .ons-dash .ons-wkcard__scroll {
  max-height: 460px;
  overflow: auto;
}

/* One "View all" link per tab is in the card head, each with its own destination and its own
   permission check; only the one belonging to the open tab is shown. Bootstrap marks the open
   tab by putting .active on its list item. Where :has() is unavailable the link of the tab the
   card opens on is shown, which is the tab the person sees first. */
body.admin .ons-dash .ons-viewall {
  display: none;
}

body.admin .ons-dash .ons-viewall--tasks {
  display: inline-flex;
}

@supports selector(:has(*)) {
  body.admin .ons-dash .ons-wkcard .ons-viewall {
    display: none;
  }

  body.admin .ons-dash .ons-wkcard:has(.ons-tabcard__tab--tasks.active) .ons-viewall--tasks,
  body.admin .ons-dash .ons-wkcard:has(.ons-tabcard__tab--projects.active) .ons-viewall--projects,
  body.admin .ons-dash .ons-wkcard:has(.ons-tabcard__tab--reminders.active) .ons-viewall--reminders,
  body.admin .ons-dash .ons-wkcard:has(.ons-tabcard__tab--tickets.active) .ons-viewall--tickets,
  body.admin .ons-dash .ons-wkcard:has(.ons-tabcard__tab--announcements.active) .ons-viewall--announcements,
  body.admin .ons-dash .ons-wkcard:has(.ons-tabcard__tab--activity.active) .ons-viewall--activity {
    display: inline-flex;
  }
}

/* --- D20 Agenda ------------------------------------------------------------------------ */

body.admin .ons-dash .ons-agenda {
  border-top: 1px solid var(--border);
}

body.admin .ons-dash .ons-agenda__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

body.admin .ons-dash .ons-agenda__nav .ons-row {
  gap: 2px;
}

body.admin .ons-dash .ons-mini button {
  line-height: 1;
}

/* Name collision inside the kit: .ons-ev is both the calendar chip of the planning page
   (accent-soft pill, bold, 11px) and the agenda row of this card. The agenda block comes
   later and only restates the layout, so the chip's fill, weight and clipping leak into every
   row; they are reset here rather than in the kit, which stays the handoff file as delivered.
   Reported to the design system owner. */
body.admin .ons-dash .ons-agenda .ons-ev {
  background: transparent;
  color: inherit;
  font-size: var(--fs-sm);
  font-weight: 400;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  grid-template-columns: 52px 8px minmax(0, 1fr) auto;
}

body.admin .ons-dash .ons-agenda .ons-ev:hover {
  background: var(--bg-hover);
}

/* --- D21 Queue health ------------------------------------------------------------------ */

body.admin .ons-dash .ons-queue {
  gap: 20px;
}

body.admin .ons-dash .ons-queue__oldest {
  font-size: inherit;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--danger);
}

body.admin .ons-dash .ons-dotlegend b {
  font-weight: 600;
  color: var(--fg);
}

/* --- D23 To-dos ------------------------------------------------------------------------ */

body.admin .ons-dash .ons-todos {
  gap: 6px;
}

body.admin .ons-dash .ons-quickadd-form {
  margin: 0;
}

body.admin .ons-dash .ons-todo__item .ons-chk {
  text-decoration: none;
}

body.admin .ons-dash .ons-todo__item .ons-chk.is-on {
  color: #fff;
}

body.admin .ons-dash .ons-disclose.is-open i {
  transform: rotate(90deg);
}

body.admin .ons-dash .is-hidden {
  display: none;
}

/* --- D24 Period comparison -------------------------------------------------------------- */

body.admin .ons-dash .ons-cmpcard__head {
  flex-wrap: wrap;
  gap: 10px;
}

/* The kit's pill is the positive one; a week that lost ground takes the danger tone. */
body.admin .ons-dash .ons-pill--down {
  background: var(--danger-soft);
  color: var(--danger);
}

body.admin .ons-dash .ons-cmp__key {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--c, var(--accent));
}

body.admin .ons-dash .ons-cmp__key--ghost {
  background: transparent;
  border: 1.5px dashed var(--border-strong);
}

/* --- D26 Team load ---------------------------------------------------------------------- */

body.admin .ons-dash #tickets-report-table-wrapper.is-loading {
  opacity: 0.5;
  pointer-events: none;
}

/* The period picker: the kit ships the menu panel, the trigger wrapper positions it. */
body.admin .ons-dash .ons-dropdown {
  position: relative;
}

body.admin .ons-dash .ons-dropdown .ons-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
}

body.admin .ons-dash .ons-menu__item {
  text-align: left;
}

/* --- D27 Activity ----------------------------------------------------------------------- */

body.admin .ons-dash .ons-act {
  max-height: 460px;
  overflow: auto;
  border-top: 1px solid var(--border);
}

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

/* In the side column a work row has no space for the priority flag and the avatar; the kit's
   container queries already fold the money and document blocks. */
@container (max-width: 480px) {
  body.admin .ons-dash .ons-wk {
    grid-template-columns: 18px minmax(0, 1fr) auto;
  }

  body.admin .ons-dash .ons-wk .ons-prio,
  body.admin .ons-dash .ons-wk .ons-avatar {
    display: none;
  }

  body.admin .ons-dash .ons-lb__row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    row-gap: 8px;
  }

  body.admin .ons-dash .ons-lb__row .r {
    text-align: left;
  }

  body.admin .ons-dash .ons-lb__head {
    display: none;
  }
}

/* --- D00 header controls (1.2.1) -------------------------------------------------------- */

/* The period / scope pickers sit in the card head next to the refresh and drag actions, one
   size down from a form control so the head stays a header. */
body.admin .ons-dash .ons-card__actions .ons-select--sm {
  height: 32px;
  width: auto;
  min-width: 0;
  padding: 0 30px 0 10px;
  font-size: var(--fs-xs);
  background-position: right 8px center;
}

body.admin .ons-dash .ons-card__actions .ons-seg {
  padding: 2px;
}

body.admin .ons-dash .ons-card__actions .ons-seg button {
  height: 28px;
  padding: 0 10px;
  font-size: var(--fs-xs);
}

/* The year picker is the platform's own multi-select (bootstrap-select), kept as it is so the
   platform's init_invoices_total() can read it; only its trigger is brought down to the
   header size. */
body.admin .ons-dash .ons-yearpicker {
  display: inline-flex;
}

body.admin .ons-dash .ons-yearpicker .bootstrap-select > .dropdown-toggle,
body.admin .ons-dash .ons-yearpicker .btn {
  height: 32px;
  min-width: 78px;
  padding: 0 10px;
  font-size: var(--fs-xs);
  line-height: 30px;
  margin: 0;
}

body.admin .ons-dash .ons-yearpicker .bootstrap-select .filter-option {
  font-size: var(--fs-xs);
}

body.admin .ons-dash .ons-yearpicker .caret {
  top: 14px;
}

/* While a card reloads its figures from the platform, it dims instead of jumping. */
body.admin .ons-dash [data-ons-payments].is-loading,
body.admin .ons-dash #invoices_total.is-loading {
  opacity: 0.5;
  pointer-events: none;
}
