/* SANDF / South African Defence theme extension.
 * Component rules only. The SA-flag palette (--sa-flag-*), defence brand
 * (--sandf-*), flag-edge gradients, and the [data-theme="sandf"] semantic
 * re-points are the single source of truth in /branding/tokens.css.
 */

html[data-theme="sandf"] body {
  background-color: var(--page-bg);
}

html[data-theme="sandf"] ::selection {
  background-color: var(--sandf-gold);
  color: #111111;
}

html[data-theme="sandf"] :focus-visible {
  outline-color: var(--sandf-gold);
}

html[data-theme="sandf"]::before {
  content: "";
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 2800;
  height: var(--sandf-flag-edge-height);
  background: var(--sandf-flag-edge-horizontal);
  pointer-events: none;
}

.defence-ribbon {
  background: var(--sandf-flag-edge-horizontal);
}

.defence-ribbon {
  height: 0.5rem;
}

html[data-theme="sandf"] .operations-portal-shell .shell-sidebar {
  position: relative;
  overflow: hidden;
}

html[data-theme="sandf"] .operations-portal-shell .shell-sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  width: var(--sandf-flag-edge-width);
  background: var(--sandf-flag-edge-vertical);
  pointer-events: none;
}

.sandf-theme-brand,
.dv8-auth-brandmark-image--sandf {
  display: none;
}

.sandf-theme-brand {
  align-items: center;
  min-width: 0;
}

.sandf-theme-brand__img {
  display: block;
  width: auto;
  max-width: min(18rem, 34vw);
  height: clamp(2.35rem, 2vw + 1.45rem, 3.1rem);
  object-fit: contain;
  border-radius: 0.35rem;
  background: transparent;
}

.app-shell-theme-toggle__mark,
.login-theme-toggle__mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 1.35rem;
  height: 1.35rem;
}

.app-shell-theme-toggle__crest,
.login-theme-toggle__crest {
  position: absolute;
  right: -0.32rem;
  bottom: -0.3rem;
  display: none;
  width: 0.82rem;
  height: 0.82rem;
  object-fit: contain;
  padding: 0.05rem;
  border: 1px solid rgba(0, 101, 54, 0.22);
  border-radius: 999px;
  background: transparent;
}

html[data-theme="sandf"] [data-theme-toggle-icon] {
  display: none;
}

html[data-theme="sandf"] [data-theme-toggle-logo] {
  display: block;
  position: static;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

html[data-theme="sandf"] .app-shell-brand .ss-logo-lockup {
  display: none;
}

html[data-theme="sandf"] .sandf-theme-brand {
  display: inline-flex;
}

html[data-theme="sandf"] .app-shell-body {
  background:
    radial-gradient(circle at top left, rgba(255, 202, 5, 0.16), transparent 28rem),
    radial-gradient(circle at top right, rgba(72, 157, 209, 0.1), transparent 24rem),
    linear-gradient(135deg, var(--page-bg), var(--surface-elevated));
}

html[data-theme="sandf"] .app-shell-header {
  background:
    linear-gradient(135deg, rgba(0, 66, 37, 0.98), rgba(0, 101, 54, 0.96));
  border-bottom: 0;
  box-shadow: 0 18px 48px rgba(0, 42, 22, 0.24);
}

html[data-theme="sandf"] .app-shell .side-nav {
  background:
    var(--sandf-flag-edge-vertical) right top / var(--sandf-flag-edge-width) 100% no-repeat,
    linear-gradient(180deg, rgba(4, 16, 8, 0.98), rgba(0, 66, 37, 0.96)),
    radial-gradient(circle at 0% 0%, rgba(255, 202, 5, 0.18), transparent 24%);
  border-right: 0;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08);
}

html[data-theme="sandf"] .app-shell-global-nav,
html[data-theme="sandf"] .app-shell-theme-toggle,
html[data-theme="sandf"] .app-shell-user {
  border-color: rgba(255, 202, 5, 0.42);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

html[data-theme="sandf"] .app-shell-nav__link:hover,
html[data-theme="sandf"] .app-shell-nav__link.is-active,
html[data-theme="sandf"] .app-shell-menu__trigger:hover,
html[data-theme="sandf"] .app-shell-menu__trigger.is-active,
html[data-theme="sandf"] .app-shell-menu.is-open .app-shell-menu__trigger,
html[data-theme="sandf"] .app-shell-menu__link:hover,
html[data-theme="sandf"] .app-shell-menu__link:focus-visible,
html[data-theme="sandf"] .app-shell-user__menu .dropdown-item:hover,
html[data-theme="sandf"] .app-shell-user__menu .dropdown-item:focus-visible {
  color: #102017;
  background: rgba(255, 202, 5, 0.18);
  border-color: rgba(0, 101, 54, 0.18);
}

html[data-theme="sandf"] .app-shell-theme-toggle:hover,
html[data-theme="sandf"] .app-shell-user:hover {
  border-color: rgba(255, 202, 5, 0.72);
}

html[data-theme="sandf"] .app-shell-menu__trigger:focus-visible,
html[data-theme="sandf"] .app-shell-navbar__toggle:focus-visible,
html[data-theme="sandf"] .app-shell-theme-toggle:focus-visible,
html[data-theme="sandf"] .app-shell-user:focus-visible {
  outline-color: var(--sandf-gold);
  box-shadow: 0 0 0 3px rgba(255, 202, 5, 0.28);
}

html[data-theme="sandf"] .app-shell-header .btn-primary {
  background-color: var(--sandf-gold);
  border-color: var(--sandf-gold);
  color: #111111;
}

html[data-theme="sandf"] .app-shell-user__avatar {
  background: rgba(255, 202, 5, 0.28);
  color: var(--sandf-green-deep);
}

html[data-theme="sandf"] .btn-primary {
  background-color: var(--sandf-green);
  border-color: var(--sandf-green);
  color: #ffffff;
}

html[data-theme="sandf"] .btn-primary:hover {
  background-color: var(--sandf-green-deep);
  border-color: var(--sandf-green-deep);
}

html[data-theme="sandf"] .btn-outline-primary {
  color: var(--sandf-green);
  border-color: var(--sandf-green);
}

html[data-theme="sandf"] .btn-outline-primary:hover {
  background-color: var(--sandf-green);
  border-color: var(--sandf-green);
}

html[data-theme="sandf"] .btn:focus,
html[data-theme="sandf"] .btn:focus-visible {
  outline-color: var(--sandf-gold);
  box-shadow: var(--shadow-focus);
}

html[data-theme="sandf"] .dv8-auth-body,
html[data-theme="sandf"] .dv8-login-container,
html[data-theme="sandf"] .dv8-auth-body--minimal {
  background:
    radial-gradient(circle at top right, rgba(255, 202, 5, 0.16), transparent 28%),
    linear-gradient(180deg, #f7f9f6 0%, #eaf3ee 100%);
}

html[data-theme="sandf"] .dv8-auth-shell {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(0, 101, 54, 0.2);
  box-shadow: 0 32px 88px rgba(0, 42, 22, 0.16);
}

html[data-theme="sandf"] .dv8-auth-aside {
  background:
    linear-gradient(165deg, rgba(0, 66, 37, 0.98) 0%, rgba(0, 101, 54, 0.96) 60%, rgba(0, 57, 116, 0.92) 100%);
}

html[data-theme="sandf"] .dv8-auth-aside::before {
  background:
    radial-gradient(circle at top right, rgba(255, 202, 5, 0.2), transparent 30%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.07) 0, rgba(255, 255, 255, 0.07) 1px, transparent 1px, transparent 20px);
}

html[data-theme="sandf"] .dv8-auth-brandmark-image--default {
  display: none;
}

html[data-theme="sandf"] .dv8-auth-brandmark-image--sandf {
  display: block;
  border-radius: 0.55rem;
  background: transparent;
}

html[data-theme="sandf"] .dv8-auth-eyebrow,
html[data-theme="sandf"] .login-workflow-progress__eyebrow {
  color: var(--sandf-gold);
}

html[data-theme="sandf"] .login-theme-toggle {
  border-color: rgba(0, 101, 54, 0.18);
  background: rgba(255, 255, 255, 0.72);
  color: var(--sandf-green);
}

html[data-theme="sandf"] .login-theme-toggle:hover,
html[data-theme="sandf"] .login-theme-toggle:focus-visible {
  border-color: rgba(255, 202, 5, 0.72);
  color: var(--sandf-green-deep);
}

html[data-theme="sandf"] .qs-auth-primary-button,
html[data-theme="sandf"] .dv8-btn-primary {
  background: linear-gradient(135deg, var(--sandf-green) 0%, var(--sandf-green-deep) 100%);
  color: #ffffff;
  box-shadow: 0 14px 28px rgba(0, 101, 54, 0.18);
}

html[data-theme="sandf"] .qs-auth-primary-button:hover,
html[data-theme="sandf"] .dv8-btn-primary:hover {
  box-shadow: 0 18px 32px rgba(0, 101, 54, 0.22);
}

html[data-theme="sandf"] .qs-auth-input-shell:focus-within,
html[data-theme="sandf"] .dv8-input-group:focus-within {
  border-color: var(--sandf-gold);
  box-shadow: 0 0 0 4px rgba(255, 202, 5, 0.16);
}

html[data-theme="sandf"] .qs-auth-password-toggle:hover,
html[data-theme="sandf"] .qs-auth-password-toggle:focus-visible,
html[data-theme="sandf"] .dv8-input-toggle:hover,
html[data-theme="sandf"] .dv8-input-toggle:focus-visible,
html[data-theme="sandf"] .qs-auth-link:hover,
html[data-theme="sandf"] .qs-auth-link:focus-visible,
html[data-theme="sandf"] .dv8-forgot-password:hover,
html[data-theme="sandf"] .dv8-forgot-password:focus-visible,
html[data-theme="sandf"] .dv8-btn-secondary:hover,
html[data-theme="sandf"] .dv8-channel-button:hover,
html[data-theme="sandf"] .dv8-resend-toggle:hover,
html[data-theme="sandf"] .dv8-channel-button.is-selected {
  border-color: rgba(0, 101, 54, 0.25);
  background: rgba(0, 101, 54, 0.08);
  color: var(--sandf-green);
}

html[data-theme="sandf"] .qs-auth-check input,
html[data-theme="sandf"] .dv8-remember-me input,
html[data-theme="sandf"] .qs-biometric-check input,
html[data-theme="sandf"] .qs-consent-choice input[type="checkbox"] {
  accent-color: var(--sandf-green);
}

html[data-theme="sandf"] .qs-auth-alt-card__icon,
html[data-theme="sandf"] .qs-auth-pill {
  background: rgba(0, 101, 54, 0.1);
  color: var(--sandf-green);
}

html[data-theme="sandf"] .login-workflow-progress {
  border-color: rgba(0, 101, 54, 0.16);
  background: linear-gradient(135deg, rgba(0, 101, 54, 0.06) 0%, rgba(255, 202, 5, 0.08) 100%);
}

html[data-theme="sandf"] .dv8-utility-card {
  --dv8-utility-accent: var(--sandf-green);
}

html[data-theme="sandf"] body.dv8-has-utility-cluster {
  --dv8-utility-surface-border: rgba(0, 101, 54, 0.18);
  --dv8-utility-surface-background: rgba(255, 255, 255, 0.96);
  --dv8-utility-surface-shadow: 0 18px 48px rgba(0, 42, 22, 0.14);
  --dv8-utility-surface-shadow-hover: 0 22px 58px rgba(0, 42, 22, 0.18);
}

html[data-theme="sandf"] .dev-access-title i {
  color: var(--sandf-green);
}

html[data-theme="sandf"] .dev-account-row:hover,
html[data-theme="sandf"] .dev-account-row:focus-visible {
  border-color: rgba(0, 101, 54, 0.35);
  background: rgba(0, 101, 54, 0.04);
  box-shadow: 0 10px 24px rgba(0, 101, 54, 0.1);
}

html[data-theme="sandf"] .operations-portal-shell {
  --shell-bg:
    radial-gradient(circle at 0% 0%, rgba(255, 202, 5, 0.16), transparent 25%),
    radial-gradient(circle at 100% 0%, rgba(0, 35, 149, 0.08), transparent 24%),
    linear-gradient(180deg, #eef6f1 0, #f7f9f6 42%, #ffffff 100%);
  --shell-panel: rgba(255, 255, 255, 0.92);
  --shell-panel-strong: rgba(255, 255, 255, 0.98);
  --shell-border: rgba(0, 101, 54, 0.16);
  --shell-border-strong: rgba(0, 101, 54, 0.28);
  --shell-shadow: 0 28px 60px rgba(0, 42, 22, 0.1);
  --shell-shadow-soft: 0 12px 28px rgba(0, 42, 22, 0.08);
  --shell-shadow-flat: 0 8px 18px rgba(0, 42, 22, 0.05);
  --shell-dark: #041008;
  --shell-dark-border: rgba(255, 202, 5, 0.22);
  --shell-dark-muted: rgba(232, 246, 238, 0.78);
  --shell-dark-strong: #ffffff;
}

html[data-theme="sandf"] .operations-portal-shell .shell-header {
  position: relative;
  background:
    linear-gradient(180deg, rgba(4, 16, 8, 0.98), rgba(0, 66, 37, 0.96)),
    radial-gradient(circle at 0% 0%, rgba(255, 202, 5, 0.18), transparent 24%);
  border-color: rgba(255, 202, 5, 0.22);
}

html[data-theme="sandf"] .operations-portal-shell .eyebrow,
html[data-theme="sandf"] .operations-portal-shell .workspace-profile-avatar {
  color: var(--sandf-green);
}

html[data-theme="sandf"] .operations-portal-shell .module-menu-card[data-active="true"],
html[data-theme="sandf"] .operations-portal-shell .nav-dropdown-toggle:hover,
html[data-theme="sandf"] .operations-portal-shell .nav-dropdown-toggle[aria-expanded="true"],
html[data-theme="sandf"] .operations-portal-shell .module-menu-link:hover,
html[data-theme="sandf"] .operations-portal-shell .module-menu-link.is-active {
  background:
    linear-gradient(90deg, rgba(255, 202, 5, 0.18), transparent 82%),
    rgba(255, 255, 255, 0.06);
  box-shadow: inset 4px 0 0 var(--sandf-gold);
}

html[data-theme="sandf"] .operations-portal-shell .action-button[data-intent="primary"],
html[data-theme="sandf"] .operations-portal-shell .primary-button {
  background: var(--sandf-green);
  border-color: var(--sandf-green);
  box-shadow: 0 14px 28px rgba(0, 101, 54, 0.18);
}

html[data-theme="sandf"] .operations-portal-shell .action-button[data-intent="primary"]:hover,
html[data-theme="sandf"] .operations-portal-shell .primary-button:hover {
  background: var(--sandf-green-deep);
}

html[data-theme="sandf"] .operations-portal-shell .action-button:hover,
html[data-theme="sandf"] .operations-portal-shell .top-bar-button:hover,
html[data-theme="sandf"] .operations-portal-shell .primary-button:hover,
html[data-theme="sandf"] .operations-portal-shell .secondary-button:hover,
html[data-theme="sandf"] .operations-portal-shell .summary-card--link:hover,
html[data-theme="sandf"] .operations-portal-shell .summary-card--link:focus-visible {
  border-color: rgba(255, 202, 5, 0.72);
}

html[data-theme="sandf"] .operations-portal-shell .module-menu-link:focus-visible,
html[data-theme="sandf"] .operations-portal-shell .action-button:focus-visible,
html[data-theme="sandf"] .operations-portal-shell .top-bar-button:focus-visible,
html[data-theme="sandf"] .operations-portal-shell .primary-button:focus-visible,
html[data-theme="sandf"] .operations-portal-shell .secondary-button:focus-visible,
html[data-theme="sandf"] .operations-portal-shell .summary-card--link:focus-visible,
html[data-theme="sandf"] .operations-portal-shell .operations-route-link:focus-visible,
html[data-theme="sandf"] .operations-portal-shell .shell-header a:focus-visible {
  box-shadow: var(--shadow-focus);
}

html[data-theme="sandf"] .status-chip {
  border: 1px solid currentColor;
}

html[data-theme="sandf"] .status-chip--active {
  color: var(--success);
  background: rgba(0, 122, 77, 0.12);
}

html[data-theme="sandf"] .status-chip--watch {
  color: #8a6500;
  background: rgba(255, 182, 18, 0.18);
}

html[data-theme="sandf"] .status-chip--critical {
  color: var(--danger);
  background: rgba(222, 56, 49, 0.14);
}

html[data-theme="sandf"] .status-chip--secure {
  color: var(--info);
  background: rgba(0, 35, 149, 0.12);
}

@media (max-width: 767px) {
  .sandf-theme-brand__img {
    max-width: min(12rem, 56vw);
    height: 2.45rem;
  }

  html[data-theme="sandf"] .app-shell-theme-toggle {
    width: 2.8rem;
  }
}
