/* =========================================================
   Bifrost Customer Portal — Website-aligned theme
   Tokens mirror bifrost-www/src/styles/tokens.css
   ========================================================= */

/* ----- Fonts (self-hosted, matches website) ----- */
@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono.woff2') format('woff2-variations');
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

/* ----- Design tokens ----- */
:root {
  /* Backgrounds */
  --bg-base:      #0b1220;
  --bg-surface:   #0f1829;
  --bg-raised:    #141e33;
  --bg-overlay:   rgba(15, 24, 41, 0.95);

  /* Borders */
  --bg-border:    #1e293b;
  --bg-border-hover: #2a3b5c;
  --border-subtle: var(--bg-border);

  /* Text */
  --fg-primary:   #e8eef7;
  --fg-muted:     #8b9bb4;
  --fg-dim:       #5a6b87;

  /* Accent */
  --accent-blue:      #6ab0ff;
  --accent-blue-dim:  #2a4a7f;

  /* Status */
  --status-success:   #5fd17c;
  --status-success-bg: rgba(95, 209, 124, 0.12);
  --status-success-border: rgba(95, 209, 124, 0.3);
  --status-error:     #ff5f6d;
  --status-error-bg:  rgba(255, 95, 109, 0.12);
  --status-error-border: rgba(255, 95, 109, 0.3);
  --status-warning:   #d9a94e;
  --status-warning-bg: rgba(217, 169, 78, 0.12);
  --status-warning-border: rgba(217, 169, 78, 0.3);

  /* Buttons */
  --btn-secondary-bg:     transparent;
  --btn-secondary-hover:  var(--bg-raised);

  /* Layout */
  --navbar-height: 56px;
  --content-max:   900px;
  --radius-sm:     4px;
  --radius-md:     6px;
  --radius-lg:     10px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
}

/* ----- Reset & base ----- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-base);
  color: var(--fg-primary);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.6;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  color: #fff;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

::selection { background: var(--accent-blue-dim); color: #fff; }

:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ----- Navbar ----- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--navbar-height);
  background: var(--bg-overlay);
  border-bottom: 1px solid var(--bg-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.navbar-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: var(--content-max);
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.navbar-brand:hover { text-decoration: none; }

.brand-logo {
  height: 28px;
  width: auto;
  display: block;
}

/* Tab navigation */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  height: 100%;
}

.nav-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-muted);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  margin-bottom: -1px;
}

.nav-tab:hover { color: var(--fg-primary); }

.nav-tab.active {
  color: #fff;
  border-bottom-color: var(--accent-blue);
}

/* User info area */
.navbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.user-email {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-primary);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sign-out-link {
  font-size: 13px;
  color: var(--fg-muted);
  padding: 4px 10px;
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  transition: color 0.15s, border-color 0.15s;
  font-weight: 500;
}
.sign-out-link:hover {
  color: var(--fg-primary);
  border-color: var(--bg-border-hover);
  text-decoration: none;
}

/* ----- Main content area ----- */
.main-content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 32px 24px;
}

.page-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: page-in 0.2s ease both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----- Card ----- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--bg-border-hover);
}

/* ----- Card typography ----- */
.card-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 6px;
}

.card-title {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.card-title-sm {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}

/* ----- Badges ----- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--bg-border);
  background: var(--bg-raised);
  color: var(--fg-muted);
}

.badge-active   { background: #1c3a24; color: #7be49c; border: 1px solid #2c5437; }
.badge-warn     { background: #3a2f12; color: #ffd27a; border: 1px solid #5e4a1c; }
.badge-danger   { background: #3a1a1a; color: #ffb4b4; border: 1px solid #5a2a2a; }
.badge-neutral  { background: var(--bg-raised); color: var(--fg-muted); border: 1px solid var(--border-subtle); }

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, opacity 0.12s ease, transform 0.12s ease;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.2;
}

.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent-blue);
  color: var(--bg-base);
}
.btn-primary:hover {
  transform: translateY(-1px);
}
.btn-primary:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  border-color: var(--bg-border);
  color: var(--fg-primary);
}
.btn-secondary:hover {
  background: var(--btn-secondary-hover);
  border-color: var(--bg-border-hover);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn-primary:hover { transform: none; }
}

/* Button layout helpers */
.btn-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-flex {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* ----- Info grid (two-column label/value layout) ----- */
.info-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  row-gap: 10px;
  column-gap: 16px;
  align-items: baseline;
}

.info-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  white-space: nowrap;
}

.info-value {
  font-size: 13px;
  color: var(--fg-primary);
  word-break: break-word;
}

/* ----- Hash display ----- */
.hash-display {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-blue);
  background: var(--bg-base);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  word-break: break-all;
  letter-spacing: 0.04em;
  line-height: 1.7;
  user-select: all;
}

/* ----- Device list ----- */
.device {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--bg-border);
}
.device:last-child { border-bottom: none; }

.device-info {
  flex: 1;
  min-width: 0;
}

.device-name {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-serial {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.device-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ----- Helper text ----- */
.muted {
  color: var(--fg-muted);
}

.text-sm {
  font-size: 12px;
}

/* ----- Inline code ----- */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--accent-blue);
  background: rgba(106, 176, 255, 0.08);
  border: 1px solid rgba(106, 176, 255, 0.2);
  border-radius: 3px;
  padding: 1px 5px;
}

/* ----- Divider ----- */
.divider {
  height: 1px;
  background: var(--bg-border);
  border: none;
  margin: 4px 0;
}

/* ----- Page section header ----- */
.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

/* ----- Footer ----- */
.site-footer {
  border-top: 1px solid var(--bg-border);
  padding: 16px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-sep {
  opacity: 0.4;
}

.footer-link {
  color: var(--fg-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer-link:hover {
  color: var(--fg-primary);
}

/* ----- Responsive ----- */
@media (max-width: 640px) {
  .navbar-user .muted { display: none; }
  .user-email { max-width: 120px; }
  .info-grid { grid-template-columns: 110px 1fr; }
  .main-content { padding: 20px 16px; }
  .card { padding: 16px 18px; }
}

@media (max-width: 480px) {
  .navbar-inner { padding: 0 12px; gap: 12px; }
  .nav-tab { padding: 0 10px; font-size: 13px; }
  .brand-logo { height: 24px; }
}

/* ---------- Phase 13b: toasts ---------- */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  max-width: 360px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  pointer-events: auto;
  font-family: var(--font-sans);
  word-wrap: break-word;
}

.toast-error {
  background: #3a1a1a;
  color: #ffb4b4;
  border: 1px solid #5a2a2a;
}

.toast-info {
  background: var(--bg-base);
  color: var(--fg-primary);
  border: 1px solid var(--border-subtle);
}

/* ---------- Phase 13b: tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.tab-btn {
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.tab-btn:hover { color: var(--fg-primary); }

.tab-btn.tab-active {
  color: var(--fg-primary);
  border-bottom-color: var(--accent-blue);
}

.tab-panel-hidden { display: none; }

.instructions {
  margin: 0;
  padding-left: 20px;
  line-height: 1.6;
}

.instructions li {
  margin-bottom: 8px;
  color: var(--fg-primary);
  font-size: 14px;
}

.instructions code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-raised);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ---------- Phase 13b: signatures grid ---------- */
.sig-grid {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  column-gap: 24px;
  row-gap: 8px;
  margin-top: 8px;
}

.sig-header {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.sig-source {
  font-weight: 600;
  color: var(--fg-primary);
  font-size: 14px;
}

.sig-value {
  color: var(--fg-primary);
  font-size: 14px;
}

/* ---------- Phase 13b: modal dialog ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--fg-primary);
  margin-bottom: 8px;
}

.modal-message {
  font-size: 14px;
  color: var(--fg-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.modal-textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  background: var(--bg-base);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  color: var(--fg-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  resize: vertical;
  outline: none;
}

.modal-textarea:focus {
  border-color: var(--accent-blue);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
