/* =========================================================
   Bastion Customer Portal — Dark Theme
   GitHub-dark inspired, security-tool aesthetic
   ========================================================= */

/* ----- Fonts ----- */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

/* ----- Design tokens ----- */
:root {
  /* Backgrounds */
  --bg-base:        #0d1117;
  --bg-card:        #161b22;
  --bg-card-hover:  #1c2230;
  --bg-input:       #0d1117;
  --bg-overlay:     rgba(22, 27, 34, 0.95);

  /* Borders */
  --border:         #30363d;
  --border-subtle:  #21262d;
  --border-focus:   #58a6ff;

  /* Text */
  --text-body:      #c9d1d9;
  --text-heading:   #f0f6fc;
  --text-muted:     #8b949e;
  --text-footer:    #484f58;
  --text-code:      #79c0ff;

  /* Accent / interactive */
  --accent:         #58a6ff;
  --accent-hover:   #79c0ff;

  /* Status colours */
  --green:          #3fb950;
  --green-bg:       rgba(63, 185, 80, 0.12);
  --green-border:   rgba(63, 185, 80, 0.3);
  --red:            #f85149;
  --red-bg:         rgba(248, 81, 73, 0.12);
  --red-border:     rgba(248, 81, 73, 0.3);
  --yellow:         #d29922;
  --yellow-bg:      rgba(210, 153, 34, 0.12);
  --yellow-border:  rgba(210, 153, 34, 0.3);

  /* Buttons */
  --btn-primary-bg:     #238636;
  --btn-primary-hover:  #2ea043;
  --btn-primary-border: #2ea04366;
  --btn-secondary-bg:   #21262d;
  --btn-secondary-hover:#30363d;
  --btn-secondary-border:#30363d;

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

  /* Typography */
  --font-sans:  'IBM Plex Sans', ui-sans-serif, system-ui, sans-serif;
  --font-mono:  'IBM Plex Mono', ui-monospace, 'Cascadia Code', monospace;
}

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

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

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-base);
  background-image:
    /* Subtle circuit-board grid overlay */
    linear-gradient(rgba(48, 54, 61, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(48, 54, 61, 0.07) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--text-body);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.6;
}

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

h1, h2, h3, h4 {
  color: var(--text-heading);
  font-weight: 600;
  line-height: 1.3;
}

/* ----- Navbar ----- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--navbar-height);
  background: var(--bg-overlay);
  border-bottom: 1px solid var(--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;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}
.navbar-brand:hover { text-decoration: none; }

.brand-icon {
  font-size: 20px;
  line-height: 1;
  /* Very slight drop shadow for depth */
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.brand-text {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-heading);
  letter-spacing: 0.03em;
}

/* 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(--text-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  margin-bottom: -1px; /* overlap navbar border */
}

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

.nav-tab.active {
  color: var(--text-heading);
  border-bottom-color: var(--accent);
}

/* 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: 12px;
  color: var(--text-body);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sign-out-link {
  font-size: 12px;
  color: var(--text-muted);
  padding: 3px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: color 0.15s, border-color 0.15s;
}
.sign-out-link:hover {
  color: var(--text-body);
  border-color: var(--border);
  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: 20px;
  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-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: #444c56;
}

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

.card-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-heading);
  line-height: 1.2;
}

.card-title-sm {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-heading);
  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(--border);
  background: var(--bg-card);
  color: var(--text-muted);
}

.badge-green {
  color: var(--green);
  background: var(--green-bg);
  border-color: var(--green-border);
}

.badge-red {
  color: var(--red);
  background: var(--red-bg);
  border-color: var(--red-border);
}

.badge-yellow {
  color: var(--yellow);
  background: var(--yellow-bg);
  border-color: var(--yellow-border);
}

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

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

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

.btn-secondary {
  background: var(--btn-secondary-bg);
  border-color: var(--btn-secondary-border);
  color: var(--text-body);
}
.btn-secondary:hover {
  background: var(--btn-secondary-hover);
  border-color: #444c56;
  color: var(--text-heading);
}

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

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

.btn-flex {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  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(--text-muted);
  white-space: nowrap;
}

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

/* ----- Hash display ----- */
.hash-display {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-code);
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  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(--border-subtle);
}
.device:last-child { border-bottom: none; }

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

.device-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-name-edit {
  display: inline-block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-heading);
  background: var(--bg-input);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  outline: none;
  width: 100%;
  font-family: var(--font-sans);
}

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

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

/* ----- Numbered instructions ----- */
.instructions {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.step-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(88, 166, 255, 0.12);
  border: 1px solid rgba(88, 166, 255, 0.3);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.step p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-body);
  margin: 0;
}

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

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

/* ----- Inline code ----- */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--text-code);
  background: rgba(121, 192, 255, 0.08);
  border: 1px solid rgba(121, 192, 255, 0.15);
  border-radius: 3px;
  padding: 1px 5px;
}

/* ----- Divider ----- */
.divider {
  height: 1px;
  background: var(--border-subtle);
  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: 600;
  color: var(--text-heading);
}

/* ----- Footer ----- */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 16px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-footer);
  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(--text-footer);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer-link:hover {
  color: var(--text-muted);
}

/* ----- 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; }
}

@media (max-width: 480px) {
  .navbar-inner { padding: 0 12px; gap: 12px; }
  .nav-tab { padding: 0 10px; font-size: 12px; }
  .brand-text { display: none; }
}
