/*
 * Vault shell — sidebar, top bar, token list rows.
 * Layout is a two-column grid (sidebar ~240px + main stretches).
 * Nothing here references raw hex: all colors / spacing / radii go
 * through the tokens defined in tokens.css.
 */

/* ---- Shell grid ---- */
.vault-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--color-bg);
}

.vault-main {
  display: flex;
  flex-direction: column;
  min-width: 0; /* let children shrink inside the grid column */
}

/* ---- Sidebar ---- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-4);
  border-right: 1px solid var(--color-border);
  background: var(--color-surface-2);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  color: var(--color-accent);
}

.sidebar__brand .language-switcher {
  margin-left: auto;
  min-height: 32px;
}

.sidebar__wordmark {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: var(--text-xl);
  letter-spacing: -0.01em;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 10px var(--space-3);
  color: var(--color-muted);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background var(--motion-fast) var(--easing-out),
              color var(--motion-fast) var(--easing-out);
}
.nav-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.nav-item:hover {
  background: var(--color-surface);
  color: var(--color-fg);
}
.nav-item--active {
  background: var(--color-surface);
  color: var(--color-fg);
  font-weight: var(--weight-semi);
  box-shadow: inset 2px 0 0 var(--color-accent);
}

.sidebar__footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.sidebar__user {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-start;
}

.sidebar__email {
  font-size: var(--text-sm);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn--small {
  padding: 8px var(--space-3);
  min-height: 36px;
  font-size: var(--text-sm);
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 1;
}

.topbar__search {
  position: relative;
  width: 100%;
  max-width: 520px;
}

.topbar__search-stack {
  flex: 1;
  min-width: min(100%, 280px);
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topbar__search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted);
  display: inline-flex;
  pointer-events: none;
}

.topbar__input {
  width: 100%;
  padding: 10px 76px 10px 36px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--color-fg);
  transition: border-color var(--motion-fast) var(--easing-out),
              box-shadow var(--motion-fast) var(--easing-out);
}
.topbar__input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(139, 90, 60, 0.16);
}
.topbar__input::-webkit-search-cancel-button { appearance: none; }

.topbar__clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  min-height: 28px;
  padding: 0 var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-muted);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
}

.topbar__clear:hover,
.topbar__clear:focus-visible {
  color: var(--color-fg);
  border-color: var(--color-border);
  background: var(--color-surface-2);
}

.topbar__search-summary {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-tight);
}

.topbar__billing {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
  color: var(--color-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-tight);
  white-space: nowrap;
}

.topbar__billing strong {
  color: var(--color-accent);
  font-weight: var(--weight-semi);
}

/* ---- Token list ---- */
.vault-list-wrap {
  flex: 1;
  padding: var(--space-5);
  overflow-y: auto;
}

.token-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 760px;
}

/* Row: a pill-shaped button + hover-revealed action buttons. */
.token-row {
  position: relative;
  display: flex;
  align-items: stretch;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--motion-fast) var(--easing-out),
              box-shadow var(--motion-fast) var(--easing-out);
}
.token-row:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-sm);
}

.token-row__body {
  flex: 1;
  display: grid;
  grid-template-columns: 44px 1fr auto 32px;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.token-row__body:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.avatar-chip {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-2);
  color: var(--color-accent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
}

.token-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.token-meta__issuer {
  font-size: var(--text-base);
  font-weight: var(--weight-semi);
  color: var(--color-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.token-meta__account {
  font-size: var(--text-sm);
  color: var(--color-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.token-code {
  font-size: var(--text-xl);
  font-weight: var(--weight-semi);
  letter-spacing: 0.05em;
  color: var(--color-fg);
  min-width: 8ch;
  text-align: right;
}
.token-code__copied {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 7ch;
  padding: 2px var(--space-2);
  border: 1px solid color-mix(in srgb, var(--color-success) 38%, var(--color-border));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--color-success) 10%, transparent);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--color-success);
  letter-spacing: 0;
}

/* ---- Ring timer ---- */
.ring-timer__track {
  stroke: var(--color-border);
}
.ring-timer__arc {
  stroke: var(--color-accent);
  transition: stroke-dashoffset 0.1s linear;
}

/* ---- Row action affordances ---- */
.token-row__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding-right: var(--space-3);
  opacity: 0;
  transform: translateX(4px);
  transition: opacity var(--motion-fast) var(--easing-out),
              transform var(--motion-fast) var(--easing-out);
}
.token-row:hover .token-row__actions,
.token-row:focus-within .token-row__actions {
  opacity: 1;
  transform: translateX(0);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--color-muted);
  cursor: pointer;
  transition: background var(--motion-fast) var(--easing-out),
              color var(--motion-fast) var(--easing-out),
              border-color var(--motion-fast) var(--easing-out);
}
.icon-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.icon-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-fg);
  border-color: var(--color-border);
}
.icon-btn--danger:hover {
  color: var(--color-destructive);
  border-color: var(--color-destructive);
}

/* ---- Empty state ---- */
.empty-state {
  max-width: 440px;
  margin: var(--space-8) auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
}
.empty-state__icon {
  width: 72px;
  height: 72px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}
.empty-state__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  letter-spacing: -0.01em;
}
.empty-state__body {
  color: var(--color-muted);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
}
.empty-state__body code {
  background: var(--color-surface);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

/* ---- Lock screen ---- */
.lock-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background:
    radial-gradient(60% 60% at 50% 20%, var(--color-surface-2), var(--color-bg));
}
.lock-screen__card {
  width: 100%;
  max-width: 400px;
  padding: var(--space-7) var(--space-5) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}
.lock-screen__logo {
  color: var(--color-accent);
  width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lock-screen__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  letter-spacing: -0.01em;
  text-align: center;
  margin: 0;
}
.lock-screen__subtitle {
  color: var(--color-muted);
  font-size: var(--text-sm);
  margin: 0;
}
.lock-screen__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  margin-top: var(--space-3);
}
.lock-screen__logout {
  margin-top: var(--space-1);
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: var(--text-sm);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.lock-screen__logout:hover { color: var(--color-fg); }

/* ---- Responsive fallback — collapse sidebar on narrow viewports ---- */
@media (max-width: 720px) {
  .vault-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    min-width: 0;
  }
  .sidebar__brand { display: none; }
  .sidebar__nav {
    /* Horizontal nav strip on mobile — hide mode dropped in favour of
       keeping the routes reachable without relying on a burger menu. */
    display: flex;
    flex-direction: row;
    gap: 2px;
    margin-left: 0;
    min-width: 0;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar__nav .nav-item {
    min-height: 36px;
    padding: 6px var(--space-2);
    font-size: var(--text-sm);
    white-space: nowrap;
  }
  .sidebar__footer {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
    margin-left: 0;
    min-width: 0;
    width: 100%;
  }
  .sidebar__user {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: var(--space-2);
  }
  .sidebar__email { display: none; }
  .context-switcher {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    min-width: 0;
    width: 100%;
  }
  .context-switcher__field { min-width: 0; }
  .context-switcher__label { display: none; }
  .context-switcher__select {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    padding: 6px 28px 6px var(--space-2);
    font-size: var(--text-sm);
  }
  .context-switcher__actions {
    grid-template-columns: repeat(3, 36px);
  }
  .sidebar__user > .btn {
    align-self: start;
    white-space: nowrap;
  }

  /* Topbar: allow wrap on narrow screens so search + Add button don't
     squeeze each other. Search stays full-width; button drops below. */
  .topbar {
    flex-wrap: wrap;
    padding: var(--space-3);
  }
  .topbar__search-stack,
  .topbar__search { max-width: none; flex-basis: 100%; }
  .topbar__billing {
    flex-basis: 100%;
    align-items: flex-start;
    white-space: normal;
  }
  .topbar > .btn { flex-basis: 100%; justify-content: center; }

  /* Token row: shrink avatar chip and ring to regain horizontal space
     for the code digits. */
  .token-row__body {
    grid-template-columns: 32px minmax(0, 1fr) auto 28px;
    gap: var(--space-2);
    padding: var(--space-3);
  }
  .avatar-chip { width: 32px; height: 32px; font-size: var(--text-xs); }
  .token-code { font-size: var(--text-lg); min-width: 6ch; }
}
