/* Adtran brand tokens (Adtran Colors 2026 / "Adtran 2026 PPT template") --
   primary blue, teal accents, and status colors are Adtran's own values,
   not invented here; see the adtran-revealjs skill's adtran-theme.css for
   the same palette applied to slide decks. */
:root {
  color-scheme: light;

  --adtran-lt1: #ffffff;
  --adtran-dk2: #535353;
  --adtran-lt2: #a7a7a7;
  --adtran-accent1: #00c8e6; /* cyan */
  --adtran-accent3: #02434f; /* darkest teal */
  --adtran-accent5: #3264f0; /* blue -- primary brand */
  --adtran-accent5-deep: #103b9e; /* rgb(16, 59, 158) -- top bar surface */
  --adtran-body-text: #262626;
  --adtran-footer-text: #808080;
  --adtran-status-done: #2faa4a; /* active */
  --adtran-status-warn: #d98a00; /* expired / in progress */
  --adtran-status-blocked: #d83b3b; /* revoked / destructive */

  --border: #e0e0e0;
  --surface: #ffffff;
  --page-bg: #f5f6f8;
}

* {
  box-sizing: border-box;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  color: var(--adtran-body-text);
  background: var(--page-bg);
  margin: 0;
}

h1, h2, h3 {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 2rem;
  background: var(--adtran-accent5-deep);
  color: var(--adtran-lt1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.topbar .brand-logo {
  height: 26px;
  width: auto;
}

.topbar h1 {
  font-size: 1.15rem;
  margin: 0;
  color: var(--adtran-lt1);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.auth-status {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.85);
}

.auth-status button {
  background: transparent;
  color: var(--adtran-lt1);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.auth-status button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--adtran-lt1);
}

/* ============================================================
   Layout
   ============================================================ */
main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 2rem 2rem;
}

.login-gate {
  max-width: 28rem;
  margin: 6rem auto;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 2.5rem 2rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.login-gate p {
  color: var(--adtran-dk2);
  line-height: 1.5;
}

/* ============================================================
   Tabs -- underline style, brand blue active indicator
   ============================================================ */
.tabs {
  display: flex;
  gap: 1.75rem;
  margin: 1.75rem 0 0;
  border-bottom: 1px solid var(--border);
}

.tab-button {
  padding: 0.7rem 0.1rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--adtran-dk2);
  cursor: pointer;
  margin-bottom: -1px;
}

.tab-button:hover {
  color: var(--adtran-body-text);
}

.tab-button.active {
  color: var(--adtran-accent5);
  border-bottom-color: var(--adtran-accent5);
}

.tab-view {
  display: none;
  padding-top: 1.5rem;
}

.tab-view.active {
  display: block;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.section-header h2 {
  font-size: 1.05rem;
  color: var(--adtran-body-text);
  margin: 0;
}

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

/* ============================================================
   Filter bar (Keys tab)
   ============================================================ */
.filters-bar {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 0;
}

.filters-bar input[type="search"] {
  flex: 1;
  max-width: 22rem;
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
  font-family: Arial, Helvetica, sans-serif;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
}

.filters-bar select {
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
  font-family: Arial, Helvetica, sans-serif;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--surface);
  color: var(--adtran-body-text);
}

.filters-bar input[type="search"]:focus-visible,
.filters-bar select:focus-visible {
  outline: none;
  border-color: var(--adtran-accent5);
  box-shadow: 0 0 0 3px rgba(50, 100, 240, 0.15);
}

.results-count {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--adtran-dk2);
}

/* ============================================================
   Buttons
   ============================================================ */
button {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 0.375rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--adtran-body-text);
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s;
}

button:hover {
  background: #f2f3f5;
}

button:focus-visible {
  outline: 2px solid var(--adtran-accent5);
  outline-offset: 1px;
}

button.busy {
  cursor: progress;
  opacity: 0.75;
}

/* ============================================================
   Busy spinner (buttons, session check) -- see js/ui-utils.js
   ============================================================ */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 0.4em;
  vertical-align: -0.15em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

#show-create-key,
#create-key-form button[type="submit"],
#refresh-expiring {
  background: var(--adtran-accent5);
  color: var(--adtran-lt1);
  border-color: var(--adtran-accent5);
}

#show-create-key:hover,
#create-key-form button[type="submit"]:hover,
#refresh-expiring:hover {
  background: #2851c9;
  border-color: #2851c9;
}

/* ============================================================
   Kebab actions menu (Keys table row actions)
   ============================================================ */
.actions-menu {
  position: relative;
  display: inline-block;
}

.kebab-button {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.3rem 0.6rem;
  color: var(--adtran-dk2);
  background: transparent;
  border-color: transparent;
}

.kebab-button:hover {
  background: #f2f3f5;
  border-color: var(--border);
}

.actions-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 8rem;
  margin-top: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.actions-dropdown button {
  border: none;
  border-radius: 0;
  text-align: left;
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--adtran-body-text);
  background: var(--surface);
}

.actions-dropdown button:hover {
  background: #f2f3f5;
}

.actions-dropdown button.destructive {
  color: var(--adtran-status-blocked);
}

.actions-dropdown button.destructive:hover {
  background: rgba(216, 59, 59, 0.08);
}

/* ============================================================
   Modal dialogs (create/edit key) -- native <dialog>, styled as a
   plain positioning/backdrop shell; the visible box is still .card.
   ============================================================ */
dialog.modal {
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  max-width: none;
  overflow: visible;
}

dialog.modal::backdrop {
  background: rgba(20, 20, 30, 0.45);
}

dialog.modal .card {
  margin: 0;
  border: none;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
  max-height: min(85vh, 640px);
  overflow-y: auto;
}

/* The one-time-key banner keeps its own left accent border even inside a modal --
   restated here since it's more specific than the generic border reset above. */
dialog.modal .card.banner {
  border: none;
  border-left: 6px solid var(--adtran-status-done);
}

/* ============================================================
   Form card (create key)
   ============================================================ */
.card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0.5rem;
  padding: 1.25rem 1.5rem;
  margin: 1rem 0;
  max-width: 32rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.card h3 {
  font-size: 1rem;
  margin: 0 0 1rem;
  color: var(--adtran-body-text);
}

.card label {
  display: block;
  margin-bottom: 0.9rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--adtran-dk2);
}

.card input {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  font-family: Arial, Helvetica, sans-serif;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  box-sizing: border-box;
}

.card input:focus-visible {
  outline: none;
  border-color: var(--adtran-accent5);
  box-shadow: 0 0 0 3px rgba(50, 100, 240, 0.15);
}

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

/* ============================================================
   Tenant-ID hints (create/edit key forms)
   ============================================================ */
.tenant-hint {
  margin: 0.4rem 0 0.9rem;
  font-size: 0.82rem;
  color: var(--adtran-dk2);
}

.tenant-hint .tenant-hint-label {
  display: block;
  margin-bottom: 0.35rem;
}

.tenant-chip {
  display: inline-block;
  margin: 0 0.35rem 0.35rem 0;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 400;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f2f3f5;
  color: var(--adtran-body-text);
}

.tenant-chip:hover {
  border-color: var(--adtran-accent5);
  background: rgba(50, 100, 240, 0.1);
}

/* Selected tenants (rendered above the "type to add" input) -- same chip shape,
   brand-blue tinted to read as "already added" vs. the neutral available-tenant
   chips, with a small round remove button baked into each chip. */
.tenant-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.3rem 0 0.6rem;
}

.tenant-chip.tenant-chip-selected {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-color: var(--adtran-accent5);
  background: rgba(50, 100, 240, 0.1);
  color: var(--adtran-accent5-deep);
}

.tenant-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.tenant-chip-remove:hover {
  background: rgba(216, 59, 59, 0.15);
  color: var(--adtran-status-blocked);
}

/* ============================================================
   One-time key banner -- brand highlight-box treatment
   ============================================================ */
.banner {
  border: none;
  border-left: 6px solid var(--adtran-status-warn);
  background: var(--surface);
  max-width: 40rem;
}

.one-time-key-warning {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: rgba(217, 138, 0, 0.12);
  border: 1px solid var(--adtran-status-warn);
  border-radius: 0.375rem;
}

.one-time-key-warning h3 {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
  color: var(--adtran-status-warn);
}

.one-time-key-warning-icon {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--adtran-status-warn);
}

.one-time-key-warning-text {
  margin: 0;
  font-weight: 700;
  color: var(--adtran-body-text);
}

.one-time-key-created-by {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--adtran-dk2);
}

.one-time-key-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.one-time-key-row code {
  flex: 1;
  padding: 0.6rem 0.7rem;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 0.25rem;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

/* ============================================================
   Tables
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  /* No overflow:hidden here (unlike a plain rounded table) -- the actions dropdown
     needs to be able to overhang the table's edge. Corners are rounded explicitly
     on the header/footer cells below instead. */
}

.data-table thead tr:first-child th:first-child {
  border-top-left-radius: 0.5rem;
}

.data-table thead tr:first-child th:last-child {
  border-top-right-radius: 0.5rem;
}

.data-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 0.5rem;
}

.data-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: 0.5rem;
}

.data-table th {
  text-align: left;
  padding: 0.65rem 0.9rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--adtran-dk2);
  background: #f8f9fa;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  text-align: left;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: #fafbfc;
}

.loading-row td {
  text-align: center;
  padding: 1.5rem 0.9rem;
  color: var(--adtran-dk2);
  font-size: 0.88rem;
}

.loading-row:hover td {
  background: var(--surface);
}

/* Status pill -- dot + label, brand functional colors (traffic-light semantics) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-pill.status-active {
  color: var(--adtran-status-done);
}
.status-pill.status-active::before {
  background: var(--adtran-status-done);
}

.status-pill.status-expired {
  color: var(--adtran-status-warn);
}
.status-pill.status-expired::before {
  background: var(--adtran-status-warn);
}

.status-pill.status-revoked {
  color: var(--adtran-status-blocked);
}
.status-pill.status-revoked::before {
  background: var(--adtran-status-blocked);
}

/* ============================================================
   Misc
   ============================================================ */
.error {
  color: var(--adtran-status-blocked);
  background: rgba(216, 59, 59, 0.08);
  border-radius: 0.375rem;
  padding: 0.6rem 0.85rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--adtran-dk2);
}

.inline-field input {
  width: 5rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-family: Arial, Helvetica, sans-serif;
}
