/* API key table shared by /account and /rust (public/api-keys.js).
   Layout after the OpenAI platform key list: a header row with one primary
   action, a hairline table of name, masked key, dates, and icon actions.
   Ink on paper per STYLE.md; the only hue is the revoke confirmation. */

.ak {
  --ak-ink: var(--ink, #111);
  --ak-muted: var(--muted, #666);
  --ak-faint: var(--faint, #999);
  --ak-rule: var(--rule, #ccc);
  --ak-hair: var(--hair, #e6e6e6);
  --ak-wash: var(--wash, #f4f4f4);
  --ak-paper: var(--paper, var(--bg, #fff));
  --ak-bad: var(--bad, #9a2424);
  --ak-radius: var(--radius-control, var(--radius, 8px));
  font-size: 0.8rem;
}

.ak-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.ak-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.ak-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}

.ak-title {
  margin: 0;
}

.ak-full .ak-title {
  font-size: 1.05rem;
}

.ak-compact .ak-title {
  color: var(--ak-muted);
  font-size: 0.75rem;
}

.ak-count {
  color: var(--ak-faint);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.ak-lede {
  max-width: none;
  margin: 0.5rem 0 0;
  color: var(--ak-muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

.ak code {
  font-family: inherit;
}

.ak-lede code,
.ak-hint code {
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  background: var(--ak-wash);
  color: var(--ak-ink);
}

/* Buttons --------------------------------------------------------------- */

.ak-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.1rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--ak-ink);
  border-radius: var(--ak-radius);
  background: var(--ak-paper);
  color: var(--ak-ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, opacity 120ms ease;
}

.ak-button.ak-primary {
  background: var(--ak-ink);
  color: var(--ak-paper);
}

.ak-button.ak-primary:hover:not(:disabled) {
  background: #333;
}

.ak-button.ak-ghost {
  border-color: var(--ak-rule);
}

.ak-button.ak-ghost:hover:not(:disabled) {
  border-color: var(--ak-ink);
}

.ak-button.ak-danger {
  border-color: var(--ak-bad);
  background: var(--ak-bad);
  color: #fff;
}

.ak-button.ak-danger:hover:not(:disabled) {
  opacity: 0.88;
}

.ak-button:disabled {
  opacity: 0.45;
  cursor: progress;
}

.ak-button:focus-visible,
.ak-icon-button:focus-visible,
.ak-input:focus-visible,
.ak-secret:focus-visible,
.ak-manage:focus-visible {
  outline: 2px solid var(--ak-ink);
  outline-offset: 2px;
}

.ak-icon {
  display: inline-flex;
  flex: none;
}

.ak-icon svg {
  display: block;
}

.ak-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--ak-radius);
  background: none;
  color: var(--ak-muted);
  cursor: pointer;
}

.ak-icon-button:hover {
  background: var(--ak-wash);
  color: var(--ak-ink);
}

.ak-icon-button.ak-trash:hover {
  color: var(--ak-bad);
}

.ak-button.ak-icon-button {
  width: 2.1rem;
  min-height: 2.1rem;
  padding: 0;
  border-color: var(--ak-rule);
  color: var(--ak-ink);
}

/* Create form and the shown-once secret -------------------------------- */

.ak-create,
.ak-reveal {
  margin-top: 0.9rem;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--ak-rule);
  border-radius: var(--ak-radius);
}

.ak-label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.ak-optional {
  color: var(--ak-faint);
  font-weight: 400;
}

.ak-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ak-input {
  flex: 1 1 14rem;
  min-width: 0;
  min-height: 2.1rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--ak-rule);
  border-radius: var(--ak-radius);
  background: var(--ak-paper);
  color: var(--ak-ink);
  font: inherit;
  font-size: 0.8rem;
}

.ak-input:focus {
  border-color: var(--ak-ink);
  outline: none;
}

.ak-reveal {
  border-color: var(--ak-ink);
}

.ak-reveal-head {
  margin: 0;
  font-weight: 700;
}

.ak-reveal-note {
  margin: 0.15rem 0 0.7rem;
  color: var(--ak-muted);
}

.ak-secret-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.ak-secret {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.45rem 0.65rem;
  overflow: hidden;
  border-radius: var(--ak-radius);
  background: var(--ak-wash);
  font-size: 0.78rem;
  line-height: 1.2rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  filter: blur(4px);
  cursor: pointer;
  user-select: none;
  transition: filter 0.15s;
}

.ak-secret.is-shown {
  filter: none;
  overflow-x: auto;
  text-overflow: clip;
  user-select: all;
}

.ak-reveal-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 0.7rem;
}

.ak-hint {
  color: var(--ak-muted);
  font-size: 0.75rem;
}

@media print {
  .ak-secret {
    visibility: hidden;
  }
}

.ak-notice {
  margin: 0.7rem 0 0;
  color: var(--ak-muted);
}

.ak-notice[data-tone="error"] {
  color: var(--ak-bad);
}

/* Table ---------------------------------------------------------------- */

.ak-table {
  width: 100%;
  margin-top: 0.9rem;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.ak-table th {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--ak-rule);
  color: var(--ak-muted);
  font-size: 0.72rem;
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
}

.ak-table td {
  height: 3rem;
  padding: 0.35rem 0.75rem;
  vertical-align: middle;
}

.ak-table tbody tr:nth-child(even) {
  background-color: var(--ak-wash);
}

.ak-table tbody tr:not(.ak-confirm):hover td {
  background-color: color-mix(in srgb, var(--ak-ink) 6%, var(--ak-paper));
}

.ak-table th:first-child,
.ak-table td:first-child {
  padding-left: 0.75rem;
}

.ak-col-name {
  width: 34%;
}

.ak-name {
  display: block;
  max-width: 22rem;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ak-name.ak-unnamed {
  color: var(--ak-muted);
  font-weight: 400;
}

.ak .ak-masked {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ak-ink);
  font-size: inherit;
  white-space: nowrap;
}

.ak-col-created,
.ak-col-used {
  color: var(--ak-muted);
  white-space: nowrap;
}

.ak-col-used.ak-never {
  color: var(--ak-faint);
}

.ak-table .ak-col-actions {
  width: 1%;
  padding-right: 0.25rem;
  text-align: right;
  white-space: nowrap;
}

.ak-col-actions .ak-icon-button + .ak-icon-button {
  margin-left: 0.15rem;
}

/* Row actions stay quiet until the row is hovered or focused, like OpenAI's. */
@media (hover: hover) {
  .ak-table tbody tr .ak-edit {
    opacity: 0;
  }
  .ak-table tbody tr:hover .ak-edit,
  .ak-table tbody tr:focus-within .ak-edit {
    opacity: 1;
  }
}

.ak-rename .ak-input {
  width: 100%;
  min-height: 1.9rem;
}

.ak-confirm td {
  height: auto;
  padding: 0.75rem 0.5rem;
  background: #fbf3f3;
}

.ak-confirm-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
}

.ak-confirm-text {
  flex: 1 1 18rem;
  margin: 0;
  color: var(--ak-muted);
  line-height: 1.5;
}

.ak-confirm-text strong {
  color: var(--ak-ink);
}

.ak-confirm-actions {
  display: flex;
  gap: 0.5rem;
}

.ak-empty {
  margin-top: 0.9rem;
  padding: 1.5rem 1rem;
  border: 1px dashed var(--ak-rule);
  border-radius: var(--ak-radius);
  text-align: center;
}

.ak-empty-title {
  margin: 0;
  font-weight: 700;
}

.ak-empty-detail {
  margin: 0.25rem 0 0;
  color: var(--ak-muted);
}

.ak-foot {
  margin: 0.6rem 0 0;
  font-size: 0.75rem;
}

.ak-manage {
  color: var(--ak-ink);
  text-decoration: none;
  border-bottom: 1px solid var(--ak-rule);
}

.ak-manage:hover {
  border-bottom-color: var(--ak-ink);
}

/* Compact (/rust): no created column, a little tighter. */
.ak-compact .ak-table td {
  height: 2.6rem;
}

.ak-compact .ak-col-name {
  width: 38%;
}

/* Narrow screens: each key becomes a stacked block. */
@media (max-width: 640px) {
  .ak-head {
    flex-wrap: wrap;
  }
  .ak-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .ak-table,
  .ak-table tbody,
  .ak-table tr,
  .ak-table td {
    display: block;
    width: auto;
  }
  .ak-table tr {
    position: relative;
    padding: 0.6rem 0.75rem;
  }
  .ak .ak-table td,
  .ak .ak-table td:first-child {
    width: auto;
    height: auto;
    padding: 0.1rem 5rem 0.1rem 0;
    border: 0;
  }
  .ak-table tbody tr:not(.ak-confirm):hover td {
    background: none;
  }
  .ak-table .ak-col-created,
  .ak-table .ak-col-used {
    display: inline-block;
    padding-right: 1rem;
    font-size: 0.75rem;
  }
  .ak-table .ak-col-created::before,
  .ak-table .ak-col-used::before {
    content: attr(data-label) " ";
    color: var(--ak-faint);
  }
  .ak .ak-table .ak-col-actions {
    position: absolute;
    top: 0.5rem;
    right: 0;
    width: auto;
    padding: 0;
  }
  .ak-table .ak-edit {
    opacity: 1;
  }
  .ak .ak-confirm td {
    padding: 0.6rem;
  }
  .ak-secret-row {
    flex-wrap: wrap;
  }
  .ak-secret {
    flex-basis: 100%;
  }
}
