/* ============================================================
   PAGES — Friends / Admin / Settings (Clean Rail aesthetic)
   ============================================================ */

.page-scroll {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

.page-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 32px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 4px;
}
.page-title {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
  margin: 0;
}
.page-subtitle {
  font-size: 13px;
  color: var(--fg-muted);
  margin: 6px 0 0;
}
.page-header-actions { display: flex; gap: 8px; }

/* ------------- Section ------------- */
.page-section {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.page-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.page-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin: 0;
}
.page-section-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ------------- Toggle Row ------------- */
.toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  cursor: pointer;
}
.toggle-row.disabled { opacity: 0.5; cursor: not-allowed; }
.toggle-copy { flex: 1; min-width: 0; }
.toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  line-height: 1.3;
}
.toggle-hint {
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 4px;
  line-height: 1.5;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  flex-shrink: 0;
  transition: all 0.2s;
  cursor: pointer;
}
.toggle-switch.on {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-switch.on .toggle-thumb { transform: translateX(18px); }

/* ------------- Segmented ------------- */
.segmented {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  flex-shrink: 0;
}
.seg-btn {
  background: transparent;
  border: none;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.seg-btn:hover { color: var(--fg); }
.seg-btn.active {
  background: var(--bg-3);
  color: var(--fg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.variant-clean.dark .seg-btn.active { box-shadow: 0 1px 3px rgba(0,0,0,0.3); }

/* ------------- Row KV ------------- */
.row-stack { display: flex; flex-direction: column; gap: 10px; }
.row-kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.row-kv:last-child { border-bottom: none; }
.row-label { font-size: 13px; color: var(--fg-muted); }
.row-value { font-size: 13px; color: var(--fg); font-weight: 500; text-align: right; }
.row-value.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--fg-muted);
}

/* ------------- Buttons ------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--bg-2); }
.btn-danger {
  background: #dc2626;
  color: #fff;
}
.btn-danger:hover { background: #b91c1c; }
.variant-clean.dark .btn-danger { background: #dc2626; }
.variant-clean.dark .btn-danger:hover { background: #ef4444; }
.btn-danger-ghost {
  background: transparent;
  color: #dc2626;
  border-color: rgba(220,38,38,0.3);
}
.btn-danger-ghost:hover { background: rgba(220,38,38,0.08); }
.variant-clean.dark .btn-danger-ghost {
  color: #fb7185;
  border-color: rgba(251,113,133,0.3);
}
.variant-clean.dark .btn-danger-ghost:hover { background: rgba(251,113,133,0.1); }
.btn-xs { padding: 4px 8px; font-size: 11px; }

/* ------------- Search ------------- */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  gap: 10px;
  transition: border-color 0.15s;
}
.search-wrap:focus-within { border-color: var(--accent); }
.search-wrap svg { width: 16px; height: 16px; color: var(--fg-muted); flex-shrink: 0; }
.search-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--fg);
  font-family: inherit;
}
.search-wrap input::placeholder { color: var(--fg-muted); }

/* ------------- Tabs ------------- */
.tab-row {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--fg); }
.tab-btn.active { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.tab-count {
  background: var(--bg-2);
  color: var(--fg-muted);
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}
.tab-btn.active .tab-count { background: var(--accent); color: var(--accent-fg); }
.tab-count.highlight:not(.tab-btn.active .tab-count) {
  background: #dc2626;
  color: #fff;
}

/* ------------- Friend Row ------------- */
.friend-list { display: flex; flex-direction: column; gap: 2px; }
.friend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  transition: background 0.15s;
}
.friend-row:hover { background: var(--bg-2); }
.friend-body { flex: 1; min-width: 0; }
.friend-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.3;
}
.friend-handle {
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 2px;
}
.friend-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.pending-label {
  font-size: 12px;
  color: var(--fg-muted);
  font-style: italic;
  align-self: center;
  padding-right: 4px;
}

/* ------------- Empty State ------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  text-align: center;
  color: var(--fg-muted);
}
.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--bg-2);
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  color: var(--fg-muted);
}
.empty-icon svg { width: 20px; height: 20px; }
.empty-state p { font-size: 13px; margin: 0; max-width: 320px; }

/* ------------- Banner ------------- */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  border: 1px solid;
}
.banner.error { background: rgba(220,38,38,0.08); border-color: rgba(220,38,38,0.2); color: #dc2626; }
.variant-clean.dark .banner.error { color: #fb7185; }
.banner.success { background: rgba(22,163,74,0.08); border-color: rgba(22,163,74,0.2); color: #16a34a; }
.banner svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

/* ============================================================
   ADMIN PAGE
   ============================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.stat-card {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.stat-card-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  font-weight: 500;
}
.stat-card-value {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--fg);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.stat-card-value.danger { color: #dc2626; }
.variant-clean.dark .stat-card-value.danger { color: #fb7185; }

/* Inline stats (inside sections) */
.stats-inline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.stat-label, .stat .stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  font-weight: 500;
}
.stat-value, .stat .stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--fg);
  margin-top: 2px;
  font-weight: 500;
}

/* ------------- Admin Table ------------- */
.table-wrap { overflow-x: auto; margin: -4px; padding: 4px; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table thead th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  padding: 4px 12px 10px;
  border-bottom: 1px solid var(--line);
}
.admin-table tbody td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--fg);
  vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table td.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
}
.admin-table td.muted { color: var(--fg-muted); font-size: 12px; }

.status-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
}
.status-pill.active { background: rgba(22,163,74,0.08); border-color: rgba(22,163,74,0.25); color: #16a34a; }
.variant-clean.dark .status-pill.active { color: #4ade80; border-color: rgba(74,222,128,0.3); }
.status-pill.expired { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.25); color: #d97706; }
.variant-clean.dark .status-pill.expired { color: #fbbf24; border-color: rgba(251,191,36,0.3); }
.status-pill.disabled { background: rgba(220,38,38,0.08); border-color: rgba(220,38,38,0.25); color: #dc2626; }
.variant-clean.dark .status-pill.disabled { color: #fb7185; border-color: rgba(251,113,133,0.3); }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 13px; height: 13px; }
.icon-btn.sm.danger { color: #dc2626; border-color: rgba(220,38,38,0.2); }
.icon-btn.sm.danger:hover { background: rgba(220,38,38,0.08); }
.variant-clean.dark .icon-btn.sm.danger { color: #fb7185; }

/* ------------- User Admin Row ------------- */
.user-admin-list { display: flex; flex-direction: column; }
.user-admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.user-admin-row:last-child { border-bottom: none; }
.user-admin-body { flex: 1; min-width: 0; }
.user-admin-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-admin-meta {
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 2px;
}
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.admin-badge svg { width: 9px; height: 9px; }
.user-admin-flags { display: flex; gap: 6px; flex-shrink: 0; }

.flag-chip {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--fg-muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.flag-chip:hover { color: var(--fg); background: var(--bg-3); }
.flag-chip.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.flag-chip.active.danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.variant-clean.dark .flag-chip.active.danger { background: #ef4444; border-color: #ef4444; }

/* ============================================================
   SETTINGS PAGE
   ============================================================ */

.avatar-control {
  display: flex;
  align-items: center;
  gap: 14px;
}
.avatar-large {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  display: grid;
  place-items: center;
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.avatar-copy { flex: 1; min-width: 0; }
.avatar-label { font-size: 14px; font-weight: 500; color: var(--fg); }
.avatar-hint { font-size: 12px; color: var(--fg-muted); margin-top: 4px; }

.divider {
  height: 1px;
  background: var(--line);
  margin: 6px -20px;
}

.key-capture {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--fg);
  cursor: pointer;
  min-width: 90px;
  transition: all 0.15s;
}
.key-capture:hover { background: var(--bg-3); }
.key-capture.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  animation: keyPulse 1.2s ease-in-out infinite;
}
@keyframes keyPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.device-card {
  background: rgba(22,163,74,0.06);
  border: 1px solid rgba(22,163,74,0.2);
  border-radius: 12px;
  padding: 14px 16px;
}
.variant-clean.dark .device-card {
  background: rgba(74,222,128,0.08);
  border-color: rgba(74,222,128,0.2);
}
.device-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #16a34a;
}
.variant-clean.dark .device-card-title { color: #4ade80; }
.device-card-title svg { width: 14px; height: 14px; }

.device-backup {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.backup-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.backup-row input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--fg);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.backup-row input:focus { border-color: var(--accent); }

/* ============================================================
   Layout glue — make pages fill the rail's chat-area slot
   ============================================================ */
.rail-layout.page-mode {
  grid-template-columns: 64px 1fr !important;
}
.rail-layout .chat-area.has-page {
  padding: 0;
}
.rail-layout .chat-area.has-page > .page-scroll {
  height: 100%;
}

/* Responsive tweaks */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
