/* Passkeys (accu_keys) UI. Self-contained, scoped to .accu_keys-* so it is safe on
   both the admin login/profile pages and the client portal. Colours come from a1-design-tokens.css
   (gold accent, purple ink), with the same values as fallbacks where the tokens are not loaded. */

/* The angle the light sits at as it travels the button's edge. A custom
   property has to be registered before it can be animated; where that is not
   supported the ring simply holds still. */
@property --ak-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

.accu_keys-login,
.accu_keys-manage,
.accu_keys-notice {
  --ak-accent: var(--a1-purple-soft, #7c5ccf);
  --ak-accent-2: var(--a1-purple-ink, #551a7d);
  --ak-ink: var(--a1-purple-ink, #551a7d);
  --ak-gold: var(--a1-gold, #d4af57);
  --ak-gold-deep: var(--a1-gold-deep, #b98919);
  --ak-radius: var(--a1-button-radius, 11px 4px);
}

.accu_keys-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 18px;
}

.accu_keys-login > .accu_keys-or,
.accu_keys-login > .accu_keys-msg {
  width: 100%;
}

.accu_keys-manage {
  margin-top: 8px;
}

/* "or" divider on the login page: a line on each side of the word, so no line runs through it. */
.accu_keys-or {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 6px 0 16px;
  color: var(--a1-muted, #5d5574);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.accu_keys-or::before,
.accu_keys-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--a1-border-strong, #cbbfec));
}
.accu_keys-or::after { transform: scaleX(-1); }

/* Buttons: the house face (white into lavender), a crisp purple edge, the house bevel, no cast glow. */
.accu_keys-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 20px;
  border: 1px solid var(--ak-accent);
  border-radius: var(--ak-radius);
  background: var(--a1-button-face, linear-gradient(180deg, #ffffff 0%, #e2dafa 130%));
  color: var(--ak-ink);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: var(--a1-button-bevel, inset 0 1px 0 #ffffff, inset 0 -2px 0 rgba(85, 26, 125, 0.07));
  transition: transform .18s ease, box-shadow .25s ease, border-color .25s ease, opacity .2s ease;
  position: relative;
  overflow: hidden;
}
.accu_keys-btn-login {
  height: 48px;
  padding: 0 24px;
  font-size: 16px;
  overflow: visible; /* the travelling light sits on the border, outside the padding box */
}
.accu_keys-btn:hover {
  transform: translateY(-1px);
  border-color: var(--ak-accent-2);
  box-shadow: var(--a1-button-bevel, inset 0 1px 0 #ffffff, inset 0 -2px 0 rgba(85, 26, 125, 0.07)), 0 0 0 3px var(--a1-button-ring, rgba(183, 166, 236, 0.4));
}
.accu_keys-btn:active {
  transform: translateY(0);
}
.accu_keys-btn:focus-visible {
  outline: 2px solid var(--ak-gold-deep);
  outline-offset: 2px;
}
.accu_keys-btn[disabled] {
  opacity: .6;
  cursor: default;
  transform: none;
}

/* A gold light travelling along the login button's border. It is drawn as a ring exactly as thick as the border
   (inset -1px over the 1px border, a 1px ring kept by the mask), so the light runs inside the border line and never
   spills inside or outside; it is short along its length (the last 60 degrees of the turn) and soft, with no glow. */
.accu_keys-btn-login::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(from var(--ak-angle),
      rgba(212, 175, 87, 0) 0deg,
      rgba(212, 175, 87, 0) 300deg,
      rgba(185, 137, 25, .6) 332deg,
      rgba(246, 222, 150, .95) 352deg,
      rgba(212, 175, 87, 0) 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: accu_keys-border-travel 6s linear infinite;
  z-index: 0;
  pointer-events: none;
}
.accu_keys-btn-login > * {
  position: relative;
  z-index: 1;
}
@keyframes accu_keys-border-travel {
  to { --ak-angle: 360deg; }
}

.accu_keys-btn-key {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  background: var(--a1-gold-metallic, linear-gradient(180deg, #f4dc93 0%, #c9a13a 46%, #8a6510 100%));
  -webkit-mask: var(--ak-key) center / contain no-repeat;
  mask: var(--ak-key) center / contain no-repeat;
  --ak-key: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M14 2a8 8 0 0 0-7.75 10.02L2 16.27V22h5.73l.7-.7v-2.12h2.12l1.42-1.42v-2.12h1.32A8 8 0 1 0 14 2Zm4 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3Z'/%3E%3C/svg%3E");
}

/* Management panel */
.accu_keys-sep {
  margin: 22px 0 14px;
  border: 0;
  border-top: 1px solid var(--a1-border, #e6e0f1);
}
.accu_keys-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.accu_keys-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ak-ink);
}
.accu_keys-count-label {
  font-weight: 500;
  font-size: 13px;
}
.accu_keys-btn-add {
  padding: 8px 15px;
  font-size: 13px;
}

/* The list is one grid, and every row takes its columns from it with subgrid, so a long name or an empty
   cell never moves the columns of another row. */
.accu_keys-list {
  display: grid;
  grid-template-columns: 28px minmax(150px, 1.5fr) minmax(110px, 1fr) minmax(100px, .9fr) minmax(100px, .9fr) 40px;
  column-gap: 16px;
}
.accu_keys-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: start;
  padding: 11px 4px;
  border-bottom: 1px solid var(--a1-border, #e6e0f1);
  transition: background .2s ease;
}
.accu_keys-row:last-child {
  border-bottom: 0;
}
.accu_keys-row:not(.accu_keys-row-head):hover {
  background: rgba(124, 92, 207, .05);
}
.accu_keys-row-head {
  padding-top: 6px;
  padding-bottom: 8px;
}
.accu_keys-cell {
  min-width: 0;
  color: var(--a1-muted, #5d5574);
  font-size: 13px;
  line-height: 24px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.accu_keys-cell-name {
  color: var(--ak-ink);
  font-weight: 600;
  font-size: 14px;
}
.accu_keys-cell-action {
  text-align: right;
  overflow: visible;
}
.accu_keys-check {
  margin: 3px 0 0;
  vertical-align: top;
}
.accu_keys-name {
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
  border-bottom: 1px solid transparent;
  transition: background .2s ease, border-color .2s ease;
}
/* A name that edits in place shows it on hover and focus with a tint and an underline, never with a pencil. */
.accu_keys-name[role="button"] {
  cursor: text;
}
.accu_keys-name[role="button"]:hover,
.accu_keys-name[role="button"]:focus-visible {
  outline: none;
  background: rgba(124, 92, 207, .08);
  border-bottom-color: var(--ak-accent);
}
.accu_keys-name-input {
  width: 100%;
  height: 24px;
  padding: 0 6px;
  margin: 0;
  border: 1px solid var(--ak-accent);
  border-radius: 6px 2px;
  background: #fff;
  color: var(--ak-ink);
  font: inherit;
  box-shadow: 0 0 0 3px var(--a1-button-ring, rgba(183, 166, 236, 0.4));
}
.accu_keys-name-input:focus {
  outline: none;
}
.accu_keys-sort {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--a1-muted, #5d5574);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  cursor: pointer;
  transition: color .2s ease;
}
.accu_keys-sort:hover,
.accu_keys-sort:focus-visible {
  outline: none;
  color: var(--ak-accent);
}
.accu_keys-icon {
  border: 0;
  background: transparent;
  color: var(--a1-muted, #5d5574);
  width: 30px;
  height: 24px;
  border-radius: 8px 3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .18s ease, color .18s ease;
}
.accu_keys-icon svg {
  width: 16px;
  height: 16px;
}
.accu_keys-delete:hover {
  background: rgba(179, 54, 77, .12);
  color: var(--a1-negative, #b3364d);
}
.accu_keys-icon:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--a1-button-ring, rgba(183, 166, 236, 0.4));
}

/* Bulk bar: appears once a passkey is selected. */
.accu_keys-bulk {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 4px;
  padding: 8px 12px;
  border-left: 3px solid var(--ak-gold);
  background: color-mix(in srgb, var(--a1-lavender, #e2dafa) 50%, #fff);
  border-radius: 4px 10px;
  animation: accu_keys-fade .25s ease both;
}
.accu_keys-bulk-count {
  margin-right: auto;
  font-weight: 600;
  color: var(--ak-ink);
  font-variant-numeric: tabular-nums;
}
.accu_keys-btn-small {
  padding: 6px 13px;
  font-size: 13px;
}
.accu_keys-btn-quiet {
  background: transparent;
  border-color: var(--a1-border-strong, #cbbfec);
  box-shadow: none;
}
.accu_keys-btn-danger {
  border-color: var(--a1-button-rose-edge, #d99aae);
  background: var(--a1-button-rose-face, linear-gradient(180deg, #ffffff 0%, #fbe4ea 60%, #f2c3d1 100%));
  color: var(--a1-button-rose-ink, #6f3550);
}
@keyframes accu_keys-fade {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: none; }
}

/* Confirmation box: the page's shared stylesheet blurs whatever sits behind a dialog. */
.accu_keys-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 22px 24px 18px;
  border: 1px solid var(--a1-border-strong, #cbbfec);
  border-radius: 16px 6px;
  background: #fff;
  color: var(--a1-purple-ink, #551a7d);
  box-shadow: 0 24px 60px rgba(46, 27, 68, .25);
}
.accu_keys-dialog::backdrop {
  background: rgba(46, 27, 68, .28);
}
.accu_keys-dialog-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
}
.accu_keys-dialog-body {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--a1-muted, #5d5574);
}
.accu_keys-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.accu_keys-empty {
  padding: 16px 4px;
  color: var(--a1-muted, #5d5574);
  font-size: 13px;
}

/* messages: soft tinted surfaces, restrained corners, no pills */
.accu_keys-msg {
  margin-top: 12px;
  padding: 10px 13px;
  border-radius: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  border: 1px solid transparent;
}
.accu_keys-msg-info {
  background: color-mix(in srgb, var(--a1-lavender, #e2dafa) 50%, #fff);
  border-color: var(--ak-accent);
  color: var(--ak-ink);
}
.accu_keys-msg-success {
  background: color-mix(in srgb, var(--a1-mint, #cdeee2) 60%, #fff);
  border-color: var(--a1-positive, #1f7a5c);
  color: var(--a1-positive, #1f7a5c);
}
.accu_keys-msg-error {
  background: color-mix(in srgb, var(--a1-rose, #ffd9e3) 55%, #fff);
  border-color: var(--a1-negative, #b3364d);
  color: var(--a1-negative, #b3364d);
}

@media (prefers-reduced-motion: reduce) {
  .accu_keys-btn,
  .accu_keys-row,
  .accu_keys-name {
    transition: none;
  }
  .accu_keys-bulk {
    animation: none;
  }
  .accu_keys-btn-login::after {
    animation: none;
    display: none;
  }
}

/* Reminder notice: one slim line under the page header, with room for three actions. It has no height cap, so on a
   phone the actions wrap inside it rather than over the page title; the script sets the cap only as it closes. */
.accu_keys-notice {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  padding: 9px 14px;
  border-left: 3px solid var(--ak-gold);
  border-radius: 4px 12px;
  background: linear-gradient(90deg, rgba(249, 230, 168, .35), rgba(226, 218, 250, .55));
  color: var(--ak-ink);
  font-size: 13px;
  transition: opacity .6s ease, max-height .6s ease, margin .6s ease, padding .6s ease;
}
.accu_keys-notice-text { flex: 1 1 320px; font-weight: 600; }
.accu_keys-notice-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.accu_keys-notice-ok { border-color: var(--a1-positive, #1f7a5c); }
.accu_keys-notice-gone { opacity: 0; max-height: 0; margin: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; }

/* Staff list: filter and bulk reminder above the table, tick box beside each count. */
.accu_keys-staffbar { margin: 0 0 10px; flex-wrap: wrap; }
.accu_keys-filter { width: auto; min-width: 180px; height: 34px; }
.accu_keys-staffcell { display: inline-flex; align-items: center; gap: 12px; }
.accu_keys-staffcell .num { min-width: 1.5em; font-variant-numeric: tabular-nums; }
.accu_keys-pickall { margin-right: 8px; vertical-align: middle; }

/* Sign-in page: a passkey known in this browser leads, and the button is the clearest control. */
.accu_keys-first { margin: 0 0 22px; }
.accu_keys-first .accu_keys-or { margin: 18px 0 0; }

/* Arriving from the onboarding step or the reminder: the add button glows once. */
.accu_keys-focus .accu_keys-btn-add { animation: accu_keys-glow 2.4s ease-in-out 2; }
@keyframes accu_keys-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 87, 0); }
  50% { box-shadow: 0 0 0 8px rgba(212, 175, 87, .35); }
}
@media (prefers-reduced-motion: reduce) {
  .accu_keys-notice, .accu_keys-focus .accu_keys-btn-add { transition: none; animation: none; }
}
