/* Themar Azure — canonical tenant UI foundation. */

@font-face {
  font-family: "Material Symbols Outlined";
  src: url("../fonts/material-symbols-outlined.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: block;
}

.material-symbols-outlined {
  font-family: "Material Symbols Outlined" !important;
  font-weight: 400;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}

:root,
:root[data-accent] {
  color-scheme: light;

  --themar-primary: #0a6cff;
  --themar-primary-rgb: 10, 108, 255;
  --themar-primary-hover: #0057d9;
  --themar-primary-strong: #0057d9;
  --themar-on-primary: #ffffff;
  --themar-primary-soft: rgba(var(--themar-primary-rgb), 0.09);
  --themar-primary-softer: rgba(var(--themar-primary-rgb), 0.05);
  --themar-primary-glow: rgba(var(--themar-primary-rgb), 0.25);
  --themar-secondary: #555f71;

  --themar-surface: #f6f7fb;
  --themar-surface-raised: #ffffff;
  --themar-surface-subtle: #f1f3f9;
  --themar-surface-hover: #eef0f7;
  --themar-text: #141a2e;
  --themar-text-secondary: #4c5570;
  --themar-text-muted: #646e88;
  --themar-border: #e5e8f0;
  --themar-border-strong: #d4d9e6;
  --themar-outline: #68738c;

  --themar-success: #107d58;
  --themar-success-soft: #e3f6ee;
  --themar-warning: #b05308;
  --themar-warning-soft: #fff0e0;
  --themar-danger: #ce281f;
  --themar-danger-soft: #fee9e8;
  --themar-info: #1469d4;
  --themar-info-soft: #e4f0ff;

  --themar-font-body: "themar sans", "IBM Plex Sans Arabic", "Tajawal", sans-serif;
  --themar-font-heading: "Manrope", "themar sans", "IBM Plex Sans Arabic", sans-serif;
  --themar-font-numeral: "Manrope", "IBM Plex Sans Arabic", sans-serif;

  --themar-text-xs: 0.75rem;
  --themar-text-sm: 0.8125rem;
  --themar-text-md: 0.875rem;
  --themar-text-lg: 1rem;
  --themar-text-xl: 1.25rem;
  --themar-text-2xl: 1.5rem;

  --themar-space-1: 0.25rem;
  --themar-space-2: 0.5rem;
  --themar-space-3: 0.75rem;
  --themar-space-4: 1rem;
  --themar-space-5: 1.25rem;
  --themar-space-6: 1.5rem;
  --themar-space-8: 2rem;
  --themar-space-10: 2.5rem;
  --themar-space-12: 3rem;

  --themar-radius-sm: 6px;
  --themar-radius-md: 8px;
  --themar-radius-lg: 12px;
  --themar-radius-pill: 999px;

  --themar-shadow-raised: 0 1px 2px rgba(20, 26, 46, 0.04);
  --themar-shadow-card: 0 1px 2px rgba(20, 26, 46, 0.04);
  --themar-shadow-overlay: 0 6px 8px -3px rgba(20, 26, 46, 0.08);
  --themar-shadow-elevated: 0 6px 8px -3px rgba(20, 26, 46, 0.08);
  --themar-shadow-pop: 0 8px 8px -4px rgba(20, 26, 46, 0.16);

  --themar-z-dropdown: 100;
  --themar-z-sticky: 200;
  --themar-z-backdrop: 300;
  --themar-z-modal: 400;
  --themar-z-toast: 500;
  --themar-z-tooltip: 600;

  --themar-duration-fast: 120ms;
  --themar-duration-state: 180ms;
  --themar-duration-overlay: 220ms;
  --themar-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --themar-content-max: 90rem;
  --themar-control-min: 44px;

  /*
   * Compatibility bridge for the tenant dashboard's established component
   * vocabulary. Keep legacy selectors operational while all visual decisions
   * resolve to the canonical Azure tokens above.
   */
  --c-primary: var(--themar-primary);
  --c-primary-600: var(--themar-primary-hover);
  --c-primary-700: var(--themar-primary-hover);
  --c-primary-50: var(--themar-primary-soft);
  --c-primary-100: var(--themar-primary-softer);
  --c-brand-light: var(--themar-primary-hover);
  --c-brand-dark: var(--themar-primary);
  --c-success: var(--themar-success);
  --c-success-50: var(--themar-success-soft);
  --c-warning: var(--themar-warning);
  --c-warning-50: var(--themar-warning-soft);
  --c-danger: var(--themar-danger);
  --c-danger-50: var(--themar-danger-soft);
  --c-info: var(--themar-info);
  --c-info-50: var(--themar-info-soft);
  --c-bg: var(--themar-surface);
  --c-bg-elevated: var(--themar-surface-raised);
  --c-surface: var(--themar-surface-raised);
  --c-surface-2: var(--themar-surface-subtle);
  --c-surface-highest: var(--themar-surface-hover);
  --c-border: var(--themar-border);
  --c-border-strong: var(--themar-border-strong);
  --c-divider: var(--themar-border);
  --c-text: var(--themar-text);
  --c-text-2: var(--themar-text-secondary);
  --c-text-3: var(--themar-text-muted);
  --c-text-4: var(--themar-text-muted);
  --font-display: var(--themar-font-heading);
  --font-body: var(--themar-font-body);
  --font-number: var(--themar-font-numeral);
  --radius-sm: var(--themar-radius-sm);
  --radius: var(--themar-radius-md);
  --radius-md: var(--themar-radius-md);
  --radius-lg: var(--themar-radius-lg);
  --shadow-xs: var(--themar-shadow-raised);
  --shadow-sm: var(--themar-shadow-raised);
  --shadow-md: var(--themar-shadow-elevated);
  --shadow-lg: var(--themar-shadow-overlay);
  --shadow-pop: var(--themar-shadow-pop);
  --shadow-glow: 0 0 0 3px var(--themar-primary-soft);
}

/*
 * Spinner glyph. Material Symbols has no spinning variant of its own, so the
 * "busy" state is a class on the icon. Shared here because this stylesheet is
 * the one file every shell loads — the 2026 and the legacy layouts alike.
 */
.material-symbols-outlined.is-spinning {
  animation: tu-icon-spin 1s linear infinite;
}

@keyframes tu-icon-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

[data-theme="dark"],
[data-theme="dark"][data-accent],
.dark-layout,
.dark-layout[data-accent] {
  color-scheme: dark;
  --themar-primary: #6aa8ff;
  --themar-primary-rgb: 106, 168, 255;
  --themar-primary-hover: #9cc4ff;
  --themar-primary-strong: #9cc4ff;
  --themar-on-primary: #071b36;
  --themar-primary-soft: rgba(var(--themar-primary-rgb), 0.14);
  --themar-primary-softer: rgba(var(--themar-primary-rgb), 0.08);
  --themar-primary-glow: rgba(var(--themar-primary-rgb), 0.25);
  --themar-secondary: #bdc7dc;
  --themar-surface: #0b1c30;
  --themar-surface-raised: #14263a;
  --themar-surface-subtle: #213145;
  --themar-surface-hover: #2b3d51;
  --themar-text: #eaf1ff;
  --themar-text-secondary: #cbd4e5;
  --themar-text-muted: #b8c2d3;
  --themar-border: #56677a;
  --themar-border-strong: #8798aa;
  --themar-success: #72d79c;
  --themar-success-soft: #123824;
  --themar-warning: #ffb784;
  --themar-warning-soft: #492100;
  --themar-danger: #ffb4ab;
  --themar-danger-soft: #690005;
  --themar-info: #98d1d0;
  --themar-info-soft: #104f4f;
}

.themar-ui {
  box-sizing: border-box;
  min-inline-size: 0;
  color: var(--themar-text);
  background: var(--themar-surface);
  font-family: var(--themar-font-body);
  line-height: 1.5;
  overflow-wrap: break-word;
}

.themar-ui *,
.themar-ui *::before,
.themar-ui *::after {
  box-sizing: inherit;
}

.themar-page {
  inline-size: min(100%, var(--themar-content-max));
  min-inline-size: 0;
  margin-inline: auto;
  padding: var(--themar-space-4);
}

.themar-title {
  margin: 0;
  color: var(--themar-text);
  font-family: var(--themar-font-heading);
  font-size: var(--themar-text-2xl);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.themar-subtitle {
  max-inline-size: 70ch;
  margin: var(--themar-space-1) 0 0;
  color: var(--themar-text-secondary);
  text-wrap: pretty;
}

.themar-surface {
  min-inline-size: 0;
  border: 1px solid var(--themar-border);
  border-radius: var(--themar-radius-lg);
  background: var(--themar-surface-raised);
}

.themar-btn {
  display: inline-flex;
  min-block-size: var(--themar-control-min);
  align-items: center;
  justify-content: center;
  gap: var(--themar-space-2);
  padding: var(--themar-space-2) var(--themar-space-4);
  border: 1px solid transparent;
  border-radius: var(--themar-radius-md);
  font: 600 var(--themar-text-md)/1.2 var(--themar-font-body);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--themar-duration-state) var(--themar-ease-out), border-color var(--themar-duration-state) var(--themar-ease-out), color var(--themar-duration-state) var(--themar-ease-out), transform var(--themar-duration-fast) var(--themar-ease-out);
}

.themar-btn--primary {
  color: var(--themar-on-primary);
  background: var(--themar-primary);
}

.themar-btn--primary:hover {
  background: var(--themar-primary-hover);
}

.themar-btn--secondary {
  color: var(--themar-text);
  border-color: var(--themar-border);
  background: var(--themar-surface-raised);
}

.themar-btn--secondary:hover {
  border-color: var(--themar-border-strong);
  background: var(--themar-surface-hover);
}

.themar-btn:active:not(:disabled, [aria-disabled="true"]) {
  transform: translateY(1px);
}

.themar-btn:disabled,
.themar-btn[aria-disabled="true"] {
  opacity: 0.52;
  cursor: not-allowed;
}

.themar-btn[aria-busy="true"] {
  cursor: progress;
}

.themar-field {
  display: grid;
  gap: var(--themar-space-2);
  min-inline-size: 0;
}

.themar-label {
  color: var(--themar-text);
  font-size: var(--themar-text-md);
  font-weight: 600;
}

.themar-control {
  inline-size: 100%;
  min-block-size: var(--themar-control-min);
  min-inline-size: 0;
  padding: var(--themar-space-2) var(--themar-space-3);
  border: 1px solid var(--themar-border);
  border-radius: var(--themar-radius-md);
  color: var(--themar-text);
  background: var(--themar-surface-raised);
  font: inherit;
  transition: border-color var(--themar-duration-state) var(--themar-ease-out), box-shadow var(--themar-duration-state) var(--themar-ease-out);
}

.themar-control::placeholder {
  color: var(--themar-text-muted);
  opacity: 1;
}

.themar-control[aria-invalid="true"] {
  border-color: var(--themar-danger);
}

.themar-field-error {
  color: var(--themar-danger);
  font-size: var(--themar-text-sm);
}

.themar-btn:focus-visible,
.themar-control:focus-visible,
.themar-focusable:focus-visible {
  outline: 3px solid var(--themar-primary-soft);
  outline-offset: 2px;
  border-color: var(--themar-primary);
}

.themar-ui :is(button, a[href], [role="button"], [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 3px solid var(--themar-primary-glow);
  outline-offset: 2px;
}

.themar-ui :is(button, a[href], [role="button"]):active:not(:disabled, [aria-disabled="true"]) {
  filter: brightness(0.97);
}

.themar-ui .header,
.tu-body .tu-topbar {
  background-color: var(--themar-surface-raised);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .themar-ui .header,
  .tu-body .tu-topbar {
    background-color: color-mix(in srgb, var(--themar-surface-raised) 90%, transparent);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border-color: color-mix(in srgb, var(--themar-border) 78%, transparent);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .themar-ui .header,
  .tu-body .tu-topbar {
    background-color: var(--themar-surface-raised);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-color: var(--themar-border);
  }
}

@media (prefers-contrast: more) {
  :root { --themar-border: #7a8497; }
  .themar-ui :is(button, a[href], [role="button"], [tabindex]:not([tabindex="-1"])):focus-visible {
    outline-color: var(--themar-text);
    outline-width: 3px;
  }
}

.themar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17.5rem), 1fr));
  gap: var(--themar-space-4);
  min-inline-size: 0;
}

.themar-table-region {
  max-inline-size: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}

.themar-table {
  inline-size: 100%;
  border-collapse: collapse;
  color: var(--themar-text);
}

.themar-table th,
.themar-table td {
  padding: var(--themar-space-3) var(--themar-space-4);
  border-block-end: 1px solid var(--themar-border);
  text-align: start;
  vertical-align: middle;
}

.themar-status {
  display: inline-flex;
  align-items: center;
  gap: var(--themar-space-1);
  min-block-size: 1.75rem;
  padding-inline: var(--themar-space-2);
  border-radius: var(--themar-radius-pill);
  font-size: var(--themar-text-sm);
  font-weight: 700;
}

.themar-status--success { color: var(--themar-success); background: var(--themar-success-soft); }
.themar-status--warning { color: var(--themar-warning); background: var(--themar-warning-soft); }
.themar-status--danger { color: var(--themar-danger); background: var(--themar-danger-soft); }
.themar-status--info { color: var(--themar-info); background: var(--themar-info-soft); }

.themar-stack {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--themar-space-3);
}

[dir="rtl"] .themar-ui {
  direction: rtl;
  text-align: start;
}

@media (min-width: 48rem) {
  .themar-page { padding: var(--themar-space-6); }
}

@media (min-width: 64rem) {
  .themar-page { padding: var(--themar-space-10); }
}

@media (max-width: 23.4375rem) {
  .themar-page { padding-inline: var(--themar-space-3); }
  .themar-stack > .themar-btn { flex: 1 1 100%; }
}

@media (max-width: 20rem) {
  .themar-page { padding-inline: var(--themar-space-2); }
}

@media (prefers-reduced-motion: reduce) {
  .themar-ui *,
  .themar-ui *::before,
  .themar-ui *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Accessible labels shared by dashboard screens. */
.sr-only { position: absolute !important; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Shared settings primitives: switch, labelled section and form save bar. */
.themar-switch { position: relative; display: inline-block; flex: 0 0 auto; inline-size: 44px; block-size: 24px; margin: 0; cursor: pointer; }
.themar-switch::after { content: ""; position: absolute; inset: -10px; }
.themar-switch input { position: absolute; inline-size: 0; block-size: 0; opacity: 0; }
.themar-switch__slider { position: absolute; inset: 0; border-radius: var(--themar-radius-full, 999px); background: var(--themar-border-strong); transition: background-color 160ms ease-out; }
.themar-switch__slider::before { content: ""; position: absolute; inset-block-start: 3px; inset-inline-start: 3px; inline-size: 18px; block-size: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: transform 160ms ease-out; }
.themar-switch input:checked + .themar-switch__slider { background: var(--themar-primary); }
.themar-switch input:checked + .themar-switch__slider::before { transform: translateX(20px); }
[dir="rtl"] .themar-switch input:checked + .themar-switch__slider::before { transform: translateX(-20px); }
.themar-switch input:focus-visible + .themar-switch__slider { outline: 3px solid var(--themar-outline); outline-offset: 3px; }
.themar-switch input:disabled + .themar-switch__slider { cursor: not-allowed; opacity: 0.55; }

.themar-switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--themar-space-4); min-block-size: 56px; margin: 0; padding: 10px 14px; border-radius: 10px; background: var(--themar-surface-subtle); color: var(--themar-text); font-size: 14px; }
label.themar-switch-row { cursor: pointer; transition: background-color 160ms ease-out; }
label.themar-switch-row:hover { background: var(--themar-surface-hover); }
.themar-switch-row:has(input:disabled) { cursor: not-allowed; }
.themar-switch-row + .themar-switch-row { margin-block-start: var(--themar-space-2); }
.themar-switch-row input[type="checkbox"]:not(.themar-switch input) { flex: 0 0 auto; inline-size: 18px; block-size: 18px; accent-color: var(--themar-primary); }
.themar-switch-row__text { display: flex; flex-direction: column; gap: 2px; min-inline-size: 0; }
.themar-switch-row__label { margin: 0; color: var(--themar-text); font-size: 14px; font-weight: 600; }
.themar-switch-row__hint { margin: 0; color: var(--themar-text-secondary); font-size: 12px; line-height: 1.5; text-wrap: pretty; }
.themar-switch-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--themar-space-2); margin-block-start: var(--themar-space-4); }
.themar-switch-list > .themar-switch-row + .themar-switch-row { margin-block-start: 0; }

.themar-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr)); gap: var(--themar-space-4); min-inline-size: 0; }
.themar-form-grid > * { min-inline-size: 0; }

.themar-section { min-inline-size: 0; margin: var(--themar-space-4) 0 0; padding: var(--themar-space-4); border: 1px solid var(--themar-border); border-radius: var(--themar-radius-lg); }
.themar-section > legend { float: none; inline-size: auto; margin: 0; padding: 0 4px; font-size: 0.8125rem; font-weight: 700; color: var(--themar-text-secondary); }

.themar-save-bar { display: flex; justify-content: flex-end; gap: var(--themar-space-2); margin-block-start: var(--themar-space-4); }
.themar-save-bar > button { inline-size: auto; margin: 0; padding-inline: var(--themar-space-6, 24px); }

@media (max-width: 575px) {
  .themar-switch-list { grid-template-columns: minmax(0, 1fr); }
  .themar-section { padding: var(--themar-space-3); }
}

@media (prefers-reduced-motion: reduce) {
  .themar-switch__slider, .themar-switch__slider::before, label.themar-switch-row { transition: none; }
}

/* One control and button size across every dashboard page. Older per-page stylesheets
   set 38-42px heights and 0-6px radii, so this sits on the shell scope to outrank them. */
:is(.tu-col, .tu-modal) :is(input:not([type="hidden"], [type="checkbox"], [type="radio"], [type="color"], [type="file"], [type="range"], [type="button"], [type="submit"], [type="reset"]), select:not(.select2-hidden-accessible), .select2-selection--multiple):not(td *, .flatpickr-calendar *, .tu-search *, .tu-topbar *, .select2-search__field) {
  min-block-size: var(--themar-control-min);
  border-radius: var(--themar-radius-md);
}

:is(.tu-col, .tu-modal) :is(.btn-sm, .tu-btn-sm):not(td *) {
  min-block-size: 40px;
}

:is(.tu-col, .tu-modal) :is([class*="-btn-reset"], [class*="-btn-search"], [class*="-btn-export"]):not(td *) {
  min-block-size: var(--themar-control-min);
  border-radius: var(--themar-radius-md);
}

/* The filter form is the bar's only child: lay its fields out in one wrapping row. */
.tu-col .filters-bar:has(> .filters-form) { display: block; }
.tu-col .filters-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--themar-space-3); inline-size: 100%; }
.tu-col .filters-form > .filter-field { flex: 1 1 12rem; min-inline-size: 0; }
.tu-col .filters-form > .filter-field :is(input, select) { inline-size: 100%; }
.tu-col .filters-form > :is(button, a) { flex: 0 0 auto; min-block-size: var(--themar-control-min); }

/* PRODUCT.md rules out coloured side stripes on cards, and long totals must stay on one line. */
.tu-col .kpi::before { display: none; }
.tu-col .kpi-value { font-size: clamp(1.25rem, 1.6vw, 1.75rem); }
.tu-col .kpi-value .num { white-space: nowrap; }

/* Select2 draws its arrow from a zero-size element; inherited padding turned it into a grey bar. */
.select2-container--default .select2-selection--single .select2-selection__arrow { inset-block-start: 50%; transform: translateY(-50%); }
.select2-container--default .select2-selection--single .select2-selection__arrow b { inline-size: 0 !important; block-size: 0 !important; padding: 0 !important; }

/* List search: the submit icon sits inside the field, not on its own line above it. */
.tu-col .fb-search:has(> button) { position: relative; display: block; min-block-size: var(--themar-control-min); }
.tu-col .fb-search:has(> button) > button { position: absolute; inset-block: 0; inset-inline-start: 0; z-index: 1; inline-size: 40px; justify-content: center; align-items: center; }
.tu-col .fb-search:has(> button) .material-symbols-outlined { position: static; transform: none; }
.tu-col .fb-search:has(> button) > input { inline-size: 100%; padding-inline: 40px 12px; }

/* Keep the KPI summary to a short block on phones so the data stays near the top. */
@media (max-width: 760px) {
  .tu-col .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: var(--themar-space-2); }
  .tu-col .kpi-grid .kpi { padding: var(--themar-space-3); }
  .tu-col .kpi-value { font-size: 1.0625rem; }
}

@media (max-width: 360px) {
  .tu-col .kpi-grid { grid-template-columns: minmax(0, 1fr) !important; }
}

/* Date inputs share the select class but have their own picker icon. */
.tu-col input[type="date"].fb-select { background-image: none; }

/* Document numbers and dates read as one token; the table region scrolls instead of wrapping them. */
.tu-col .data-table td > :is(a, .num) { white-space: nowrap; }
.tu-col .btn-primary .material-symbols-outlined { color: inherit; }
.tu-col .data-table :is(th, td) { padding-block: 0.75rem; padding-inline: 1rem; }
.tu-col .filters-form > .filter-field:has(.fb-date-range) { flex: 1 1 18rem; }

/* Keep page and card headings on the palette when a legacy stylesheet is loaded */
.tu-col :is(.tu-pg-title, .tu-card-title) { color: var(--themar-text); }
.tu-col .tu-btn[aria-selected="true"] { border-color: var(--themar-primary); background: var(--themar-primary-soft); color: var(--themar-primary); }
.tu-col input[type="file"]::file-selector-button { min-block-size: 2.25rem; margin-inline-end: 0.75rem; padding: 0 0.875rem; border: 1px solid var(--themar-border-strong); border-radius: 8px; background: var(--themar-surface-raised); color: var(--themar-text); font: inherit; font-weight: 600; cursor: pointer; }
