/* LAPS Manager (Blazor). Colours, spacing and type come from Fluent's design tokens (CSS variables). */

:root {
  color-scheme: light dark;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

/* Matches Fluent's page background so nothing flashes before the app renders. */
body {
  background: #fafafa;
  color: #242424;
  font-family: var(--fontFamilyBase, 'Segoe UI', 'Segoe UI Web (West European)', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif);
  font-size: var(--fontSizeBase300, 14px);
  line-height: var(--lineHeightBase300, 20px);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) body {
    background: #1f1f1f;
    color: #ffffff;
  }
}

:root[data-theme='dark'] body {
  background: #1f1f1f;
  color: #ffffff;
}

* {
  box-sizing: border-box;
}

p {
  margin: 0;
}

code {
  font-family: var(--fontFamilyMonospace, Consolas, monospace);
}

/* ---------- Loading and errors before the app runs ---------- */

.boot {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  color: inherit;
}

.boot-spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid rgba(128, 128, 128, 0.25);
  border-top-color: #00727a;
  animation: boot-spin 0.9s linear infinite;
}

@keyframes boot-spin {
  to {
    transform: rotate(360deg);
  }
}

#blazor-error-ui {
  display: none;
  position: fixed;
  inset: auto 0 0 0;
  z-index: 1000;
  padding: 12px 16px;
  background: #fde7e9;
  color: #242424;
  box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.2);
}

#blazor-error-ui .dismiss {
  float: right;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 16px;
}

/* ---------- Shared text helpers ---------- */

.page {
  min-height: 100vh;
  background-color: var(--colorNeutralBackground2);
  color: var(--colorNeutralForeground1);
}

.muted {
  color: var(--colorNeutralForeground3);
}

.small {
  font-size: var(--fontSizeBase200);
  line-height: var(--lineHeightBase200);
}

.semibold {
  font-weight: var(--fontWeightSemibold);
}

.mono {
  font-family: var(--fontFamilyMonospace);
  font-size: var(--fontSizeBase200);
}

.truncate {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
  flex-shrink: 0;
}

.stack-l {
  display: flex;
  flex-direction: column;
  row-gap: var(--spacingVerticalL);
}

.stack-m {
  display: flex;
  flex-direction: column;
  row-gap: var(--spacingVerticalM);
}

.spinner-row {
  display: flex;
  align-items: center;
  gap: var(--spacingHorizontalS);
}

/* ---------- Header: company strip, then the LAPS Manager strip ---------- */

.company-strip {
  display: flex;
  align-items: center;
  column-gap: var(--spacingHorizontalS);
  min-height: 44px;
  padding: var(--spacingVerticalXS) var(--spacingHorizontalL);
  background-color: var(--colorNeutralBackground1);
}

.company-strip.minimal {
  border-top: 4px solid var(--colorCompoundBrandStroke);
  border-bottom: 1px solid var(--colorNeutralStroke2);
}

.company-logo {
  height: 28px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.company-logo-placeholder {
  color: var(--colorBrandForeground1);
}

.company-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fontSizeBase400);
  line-height: var(--lineHeightBase400);
  font-weight: var(--fontWeightSemibold);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacingHorizontalM);
  min-height: 52px;
  padding: var(--spacingVerticalXS) var(--spacingHorizontalL);
  background-color: var(--colorNeutralBackground1);
  color: var(--colorNeutralForeground1);
}

.app-header.brand-bar,
.app-header.minimal {
  border-bottom: 1px solid var(--colorNeutralStroke2);
}

/*
  A strip filled with the brand colour. Fluent tokens are CSS variables, so overriding them re-colours the controls
  in the strip (text, subtle buttons, focus ring) for a dark background. The overrides go on the strip's own content,
  not the whole strip: the theme menu and the tooltips are rendered inside it but pop up on the normal surface.
*/
.app-header.app-bar,
.company-strip.brand-bar {
  background-color: var(--colorBrandBackground);
  color: var(--colorNeutralForegroundOnBrand);
}

.app-header.app-bar > .app-header-brand,
.app-header.app-bar .persona,
.app-header.app-bar fluent-button,
.company-strip.brand-bar {
  --colorNeutralForeground1: #ffffff;
  --colorNeutralForeground1Hover: #ffffff;
  --colorNeutralForeground1Pressed: #ffffff;
  --colorNeutralForeground2: #ffffff;
  --colorNeutralForeground2Hover: #ffffff;
  --colorNeutralForeground2Pressed: #ffffff;
  --colorNeutralForeground2BrandHover: #ffffff;
  --colorNeutralForeground2BrandPressed: #ffffff;
  --colorNeutralForeground3: rgba(255, 255, 255, 0.82);
  --colorBrandForeground1: #ffffff;
  --colorSubtleBackgroundHover: rgba(255, 255, 255, 0.14);
  --colorSubtleBackgroundPressed: rgba(255, 255, 255, 0.22);
  --colorStrokeFocus2: #ffffff;
}

.app-header-brand,
.app-header-user,
.persona {
  display: flex;
  align-items: center;
  gap: var(--spacingHorizontalS);
  min-width: 0;
}

.app-header-name {
  font-size: var(--fontSizeBase500);
  line-height: var(--lineHeightBase500);
  font-weight: var(--fontWeightSemibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.persona-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-align: center;
}

.persona-name {
  font-weight: var(--fontWeightRegular);
}

.persona-secondary {
  font-size: var(--fontSizeBase200);
  line-height: var(--lineHeightBase200);
  color: var(--colorNeutralForeground3);
}

@media (max-width: 560px) {
  .company-strip {
    min-height: 40px;
  }

  .company-logo {
    height: 24px;
  }

  .company-name {
    font-size: var(--fontSizeBase300);
  }
}

/* ---------- Status pages (sign-in, configuration, progress) ---------- */

.status-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.status-center {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacingHorizontalL);
}

.status-card {
  width: 100%;
  max-width: 480px;
  padding: var(--spacingHorizontalXXL);
  display: flex;
  flex-direction: column;
  row-gap: var(--spacingVerticalM);
}

.status-title {
  margin: 0;
  font-size: var(--fontSizeBase500);
  line-height: var(--lineHeightBase500);
  font-weight: var(--fontWeightSemibold);
}

.status-body {
  display: flex;
  flex-direction: column;
  gap: var(--spacingVerticalS);
}

/* ---------- Search page ---------- */

.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--spacingVerticalXXL) var(--spacingHorizontalL);
  display: flex;
  flex-direction: column;
  row-gap: var(--spacingVerticalL);
}

.intro {
  display: flex;
  flex-direction: column;
  row-gap: var(--spacingVerticalXS);
}

.page-title {
  margin: 0;
  font-size: var(--fontSizeBase600);
  line-height: var(--lineHeightBase600);
  font-weight: var(--fontWeightSemibold);
}

.search-row {
  display: flex;
  gap: var(--spacingHorizontalS);
  align-items: stretch;
}

.search-box {
  flex-grow: 1;
  min-width: 0;
  width: auto;
  max-width: none;
}

.search-button {
  flex-shrink: 0;
}

.search-hint {
  display: block;
  margin-top: var(--spacingVerticalXS);
}

.results-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: var(--spacingHorizontalM);
}

.results-title {
  margin: 0;
  font-size: var(--fontSizeBase400);
  line-height: var(--lineHeightBase400);
  font-weight: var(--fontWeightSemibold);
}

.results-grid {
  background-color: var(--colorNeutralBackground1);
  border-radius: var(--borderRadiusLarge);
  box-shadow: var(--shadow2);
  overflow: hidden;
}

.clickable-row,
.selected-row {
  cursor: pointer;
}

/* Rows hold two lines (name and UPN, OS and version), so they size to their content. */
.results-grid td.clickable-row,
.results-grid td.selected-row {
  padding-block: var(--spacingVerticalS);
  align-content: center;
}

.selected-row {
  background-color: var(--colorBrandBackground2);
}

.cell-media {
  display: flex;
  align-items: center;
  gap: var(--spacingHorizontalS);
  min-width: 0;
}

.cell-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.results-cards {
  display: none;
  flex-direction: column;
  row-gap: var(--spacingVerticalS);
}

.device-card {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--spacingHorizontalM);
  align-items: start;
  padding: var(--spacingVerticalM) var(--spacingHorizontalM);
  border-radius: var(--borderRadiusMedium);
  background-color: var(--colorNeutralBackground1);
  box-shadow: var(--shadow4);
  cursor: pointer;
}

.device-card:hover {
  background-color: var(--colorNeutralBackground1Hover);
}

.device-card:focus-visible {
  outline: 2px solid var(--colorStrokeFocus2);
  outline-offset: 2px;
}

.device-card.selected {
  background-color: var(--colorBrandBackground2);
}

.device-card-text {
  min-width: 0;
  overflow-wrap: anywhere;
  display: flex;
  flex-direction: column;
  row-gap: 2px;
}

@media (max-width: 760px) {
  .results-grid {
    display: none;
  }

  .results-cards {
    display: flex;
  }
}

/* ---------- Device drawer ---------- */

/* !important: a FluentDialog declared in markup injects "#id::part(dialog) { width: 100% }" next to the drawer. */
.device-drawer::part(dialog) {
  width: 592px !important;
  max-width: 100vw;
}

@media (max-width: 640px) {
  .device-drawer::part(dialog) {
    width: 100vw !important;
  }
}

.drawer-title {
  overflow-wrap: anywhere;
}

.drawer-body {
  display: flex;
  flex-direction: column;
  row-gap: var(--spacingVerticalXL);
  padding-bottom: var(--spacingVerticalXXL);
}

.drawer-header-extra {
  display: flex;
  flex-direction: column;
  gap: var(--spacingVerticalS);
}

.badges,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacingHorizontalXS);
}

.section-title {
  margin: 0;
  font-size: var(--fontSizeBase400);
  line-height: var(--lineHeightBase400);
  font-weight: var(--fontWeightSemibold);
}

.device-info {
  display: flex;
  flex-direction: column;
  row-gap: var(--spacingVerticalS);
}

.info-grid {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr;
  column-gap: var(--spacingHorizontalL);
  row-gap: var(--spacingVerticalS);
  margin: 0;
}

.info-grid dt {
  color: var(--colorNeutralForeground3);
}

.info-grid dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  display: flex;
  align-items: center;
  gap: var(--spacingHorizontalXS);
}

/* ---------- Password and recovery key cards ---------- */

/* flex-shrink 0: the drawer body is a flex column, and a card would otherwise shrink and clip. */
.panel-card {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  row-gap: var(--spacingVerticalM);
  padding: var(--spacingHorizontalL);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: var(--spacingHorizontalM);
}

.panel-body {
  display: flex;
  flex-direction: column;
  row-gap: var(--spacingVerticalM);
}

.panel-idle {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  row-gap: var(--spacingVerticalS);
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--spacingHorizontalS);
  row-gap: var(--spacingVerticalS);
}

.credential {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--spacingHorizontalL);
  row-gap: var(--spacingVerticalS);
  align-items: center;
  padding: var(--spacingHorizontalM);
  border-radius: var(--borderRadiusMedium);
  background-color: var(--colorNeutralBackground3);
}

.field-label {
  color: var(--colorNeutralForeground3);
  font-size: var(--fontSizeBase200);
  line-height: var(--lineHeightBase200);
}

/* Buttons stay beside the value; a long value wraps within its own space. */
.value-row {
  display: flex;
  align-items: center;
  column-gap: var(--spacingHorizontalXS);
  min-width: 0;
}

.full-row {
  grid-column: 1 / -1;
}

.password {
  font-family: var(--fontFamilyMonospace);
  font-size: var(--fontSizeBase500);
  line-height: var(--lineHeightBase500);
  letter-spacing: 0.06em;
  word-break: break-all;
  min-width: 0;
  color: var(--colorNeutralForeground1);
}

.password.masked {
  color: var(--colorNeutralForeground3);
  letter-spacing: 0.12em;
}

.ch-digit {
  color: var(--colorPaletteBlueForeground2, #0f6cbd);
}

.ch-symbol {
  color: var(--colorPaletteDarkOrangeForeground2, #c43501);
}

.ch-space {
  background-color: var(--colorNeutralBackground5);
}

.recovery-key {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  font-family: var(--fontFamilyMonospace);
  font-size: var(--fontSizeBase400);
  line-height: var(--lineHeightBase500);
  letter-spacing: 0.04em;
  color: var(--colorNeutralForeground1);
}

.recovery-key.masked {
  color: var(--colorNeutralForeground3);
}

/* Lines break only between the two halves, so a block is never split while it is read out. */
.key-line {
  white-space: nowrap;
}

.key-separator {
  color: var(--colorNeutralForeground3);
}

.key-id {
  font-family: var(--fontFamilyMonospace);
  font-size: var(--fontSizeBase300);
  word-break: break-all;
  min-width: 0;
}

.key-id-start {
  font-weight: var(--fontWeightBold);
  color: var(--colorNeutralForeground1);
}

.key-id-rest {
  color: var(--colorNeutralForeground3);
}

.key-filter {
  display: flex;
  flex-direction: column;
  gap: var(--spacingVerticalXXS);
}

.timer {
  display: flex;
  align-items: center;
  column-gap: var(--spacingHorizontalM);
}

.timer-progress {
  flex-grow: 1;
  min-width: 0;
}

.error-bar {
  min-width: 0;
  overflow-wrap: anywhere;
}

.error-details {
  display: block;
  margin-top: var(--spacingVerticalXS);
  color: var(--colorNeutralForeground3);
  font-size: var(--fontSizeBase200);
}

/* Phones: label above value, so the value gets the full width. */
@media (max-width: 640px) {
  .credential {
    grid-template-columns: minmax(0, 1fr);
    row-gap: var(--spacingVerticalXXS);
  }

  .credential .field-label:not(:first-child) {
    margin-top: var(--spacingVerticalS);
  }

  .password {
    font-size: var(--fontSizeBase400);
    line-height: var(--lineHeightBase400);
    letter-spacing: 0.04em;
  }

  .recovery-key {
    font-size: var(--fontSizeBase300);
    line-height: var(--lineHeightBase400);
  }
}
