/* Common styles for 0x730 AthBot UI */
:root {
  --bg: #0c121c; /* slightly lighter than #0b0e14 to avoid crushed blacks */
  --card: #151521; /* match Swarms widget surface rgb(21,21,33) across the app */
  --fg: #e8edf3;
  --muted: #9bb0c5;
  --accent: #1e88e5;
  --ok: #43a047;
  --warn: #fdd835;
  --err: #e53935;
  --ring: rgba(30, 136, 229, 0.55);
  --shadow-1: 0 2px 8px rgba(0, 0, 0, 0.35);
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family:
    'JetBrains Mono', 'Fira Code', 'Fira Mono', ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, 'Liberation Mono', monospace;
  margin: 0;
}

header {
  padding: 16px 24px;
  background: #111a2a; /* align header surface with new scheme */
  border-bottom: 1px solid #22324a;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header h1 {
  font-size: 20px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
header .brand img.logo {
  width: 22px;
  height: 22px;
  display: inline-block;
}
header .brand .title {
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* Header nav links */
header .nav a {
  color: #d5e6f7; /* brighter for better visibility */
  font-size: 14px;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    transform 120ms ease;
}
header .nav a:hover {
  background: rgba(30, 136, 229, 0.16);
  color: #f4f9ff;
}
header .nav a.active {
  background: rgba(30, 136, 229, 0.18);
  color: #e6f2ff;
}
header .nav a:active {
  transform: translateY(1px);
}

.container {
  padding: 16px;
  margin: 0 auto;
  max-width: 1600px;
}

.grid {
  display: grid;
  gap: 16px;
  align-items: stretch;
}

.card {
  background: var(--card);
  border: 1px solid #22324a;
  border-radius: 10px;
  padding: 16px;
}
.card h2 {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: #cde1f1;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

label {
  font-size: 12px;
  color: var(--muted);
}

input,
select {
  background: #141e33; /* slightly brighter than card for readability */
  color: var(--fg);
  border: 1px solid #314564;
  border-radius: 8px;
  padding: 8px;
  width: 100%;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}
input::placeholder,
select::placeholder {
  color: var(--muted);
  opacity: 0.95; /* increase legibility */
}
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}
input:disabled,
select:disabled,
input[readonly],
select[readonly] {
  background: #10182a;
  color: #a9bcd2;
  border-color: #2a3a56;
  opacity: 1; /* keep text readable */
}

button,
.button,
.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition:
    background-color 160ms ease,
    box-shadow 160ms ease,
    transform 120ms ease;
}
button:hover:not(:disabled),
.button:hover,
.btn:hover {
  filter: brightness(1.05);
}
button:active:not(:disabled),
.button:active,
.btn:active {
  transform: translateY(1px);
}
button.secondary,
.button.secondary,
.btn.secondary {
  background: #2b3a55;
}
button.ghost,
.button.ghost,
.btn.ghost {
  background: transparent;
  color: #d5e6f7;
  border: 1px solid #2a3a56;
}
button.outline,
.button.outline,
.btn.outline {
  background: transparent;
  color: #eaf3ff;
  border: 1px solid #2a3a56;
}
button.small,
.button.small,
.btn.small {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
}
button:disabled,
.button:disabled,
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.small {
  font-size: 12px;
  color: var(--muted);
}
.mt8 {
  margin-top: 8px;
}
.mt16 {
  margin-top: 16px;
}
.mono {
  font-family:
    'JetBrains Mono', 'Fira Code', 'Fira Mono', ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, 'Liberation Mono', monospace;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
th,
td {
  padding: 8px;
  border-bottom: 1px solid #22324a;
  text-align: left;
}
th {
  color: #bcd3e6;
}
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.mono {
  font-variant-numeric: tabular-nums;
}
/* Smaller, muted unit suffix like % */
.unit {
  margin-left: 1px;
  opacity: 0.85;
  font-size: 90%;
}
.dir span {
  margin-right: 4px;
}
.table-wrap {
  overflow-x: auto;
}
table thead th {
  position: sticky;
  top: 0;
  background: #162034; /* match surfaces for consistency */
  z-index: 1;
}
tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}
/* Attention rows in Trades when from-entry exceeds threshold */
tbody tr.attn-row {
  background: rgba(229, 57, 53, 0.08);
  box-shadow: inset 3px 0 0 rgba(229, 57, 53, 0.9);
}
tbody tr.attn-row:hover {
  background: rgba(229, 57, 53, 0.12);
}
/* Positive attention rows (growth above threshold) */
tbody tr.attn-row-pos {
  background: rgba(20, 227, 155, 0.08);
  box-shadow: inset 3px 0 0 rgba(20, 227, 155, 0.9);
}
tbody tr.attn-row-pos:hover {
  background: rgba(20, 227, 155, 0.12);
}
/* Entry threshold hint rows (entry exceeds strategy threshold) */
tbody tr.entry-threshold-hint {
  background: rgba(255, 193, 7, 0.08);
  box-shadow: inset 3px 0 0 rgba(255, 193, 7, 0.9);
}
tbody tr.entry-threshold-hint:hover {
  background: rgba(255, 193, 7, 0.12);
}

/* Pills and state colors */
.pill {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
}
.pill.ok {
  background: #1b5e20;
  color: #b9f6ca;
}
.pill.warn {
  background: #4e342e;
  color: #ffe082;
}
.pill.err {
  background: #4a1f1f;
  color: #ff8a80;
}
.pill.neutral {
  background: #2a3340;
  color: #9aa8b4;
}
.up {
  color: #14e39b;
}
.down {
  color: #ff5e57;
}
.flat {
  color: #9aa8b4;
}

/* Footer */
footer {
  margin-top: 24px;
  background: #111a2a;
  border-top: 1px solid #22324a;
  color: var(--fg);
  padding: 12px 24px;
  box-shadow: var(--shadow-1);
}
.footer-inner {
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  font-size: 12px;
}
.footer-inner .left {
  color: #bcd3e6;
}
.footer-inner .right {
  color: var(--muted);
}
.footer-inner .right .pill {
  margin-left: 6px;
}

/* Utility spacing and layout helpers for inline-free markup */
.gap-12 {
  gap: 12px;
}
.gap-16 {
  gap: 16px;
}
.align-center {
  align-items: center;
}
.align-end {
  align-items: flex-end;
}
.justify-between {
  justify-content: space-between;
}
.flex-1 {
  flex: 1 1 auto;
}
/* Text utilities */
.nowrap {
  white-space: nowrap;
}
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.w-120 {
  width: 120px;
}
.w-140 {
  width: 140px;
}
.w-160 {
  width: 160px;
}
.w-180 {
  width: 180px;
}
.w-200 {
  width: 200px;
}
.mb8 {
  margin-bottom: 8px;
}
.mt6 {
  margin-top: 6px;
}
.op-85 {
  opacity: 0.85;
}
.op-90 {
  opacity: 0.9;
}

/* Responsive header/nav and enhanced footer */
/* Icons */
.nav .nav-link svg {
  width: 16px;
  height: 16px;
  display: inline-block;
  margin-right: 6px;
  opacity: 0.9;
}
.nav .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #bcd3e6;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 10px;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    transform 120ms ease;
}
.nav .nav-link:hover {
  background: rgba(30, 136, 229, 0.12);
  color: #e6f2ff;
}

/* Hamburger */
.hamburger {
  display: none;
  background: transparent;
  border: 1px solid #233048;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: #bcd3e6;
  margin: 3px 0;
  transition:
    transform 160ms ease,
    opacity 160ms ease;
}
.hamburger[aria-expanded='true'] span:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
}
.hamburger[aria-expanded='true'] span:nth-child(2) {
  opacity: 0;
}
.hamburger[aria-expanded='true'] span:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
}

/* Nav layout */
header .nav {
  display: flex;
  gap: 12px;
  align-items: center;
}
/* Settings icon at the far right */
header .nav .settings-link {
  margin-left: auto;
}
/* Icon-only nav link text hidden visually */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.nav .nav-link--icon span {
  display: none;
}
@media (max-width: 900px) {
  header {
    flex-wrap: wrap;
    gap: 10px;
  }
  .hamburger {
    display: inline-flex;
  }
  header .nav {
    width: 100%;
    order: 3;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding-top: 8px;
  }
  header .nav.nav--open {
    display: flex;
  }
  .nav .nav-link {
    justify-content: flex-start;
    padding: 10px 12px;
  }
}

/* Accessibility and UX polish */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}
/* Make interactive elements show focus ring */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
.menu-button:focus-visible,
.menu-item:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

/* Smooth but respectful motion */
* {
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Selection color */
::selection {
  background: rgba(30, 136, 229, 0.35);
}

/* Subtle scrollbar theming */
*::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}
*::-webkit-scrollbar-thumb {
  background: #2a3850;
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-track {
  background: transparent;
}

/* Skeleton shimmer */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}
.skeleton {
  display: inline-block;
  width: 100%;
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 0%,
    rgba(255, 255, 255, 0.12) 50%,
    rgba(255, 255, 255, 0.06) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
.skeleton.sm {
  height: 8px;
}
.skeleton.lg {
  height: 14px;
}

/* Danger buttons (destructive actions) */
button.danger {
  background: #7a2c2c;
}
button.danger:hover:not(:disabled) {
  filter: brightness(1.05);
}

/* Back-to-top button */
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid #2a3a56;
  background: rgba(21, 27, 40, 0.9);
  color: #eaf3ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    background-color 160ms ease;
  z-index: 500;
}
.back-to-top:hover {
  background: rgba(30, 136, 229, 0.18);
}
.back-to-top:active {
  transform: translateY(10px);
}
.back-to-top--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
@media (max-width: 600px) {
  .back-to-top {
    right: 14px;
    bottom: 14px;
  }
}

/* Footer socials */
.footer-inner .socials {
  display: flex;
  gap: 10px;
  align-items: center;
}
.footer-inner .socials a {
  display: inline-flex;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid #233048;
  color: #bcd3e6;
}
.footer-inner .socials a:hover {
  background: rgba(30, 136, 229, 0.12);
  color: #e6f2ff;
}
.footer-inner .socials svg {
  width: 16px;
  height: 16px;
}

/* Enhanced, stunning header visuals */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: linear-gradient(180deg, rgba(20, 28, 44, 0.92) 0%, rgba(20, 28, 44, 0.82) 100%);
  border-bottom: 1px solid #22324a;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}
.site-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #e6f2ff;
  font-weight: 600;
  letter-spacing: 0.2px;
  font-size: 18px;
  text-decoration: none;
}
.site-header .brand .logo {
  width: 22px;
  height: 22px;
}
.site-header .brand .title {
  font-weight: 700;
}
.header-inner {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
/* Engine status pill */
.pill--engine {
  border: 1px solid #233048;
  background: rgba(30, 136, 229, 0.08);
  color: #bcd3e6;
}
.pill--engine.ok {
  background: #1b5e20;
  color: #b9f6ca;
  border-color: rgba(27, 94, 32, 0.7);
}
.pill--engine.warn {
  background: #4e342e;
  color: #ffe082;
  border-color: rgba(78, 52, 46, 0.6);
}
/* Subtle active glow for nav */
.nav .nav-link.active {
  background: rgba(30, 136, 229, 0.18);
  color: #e6f2ff;
  box-shadow:
    0 0 0 1px #233048 inset,
    0 0 12px rgba(30, 136, 229, 0.25);
}
@media (max-width: 900px) {
  .header-inner {
    flex-wrap: wrap;
  }
  .header-actions {
    margin-left: auto;
  }
}

/* Simple dropdown menus */
.menu-group {
  position: relative;
}
/* Hover bridge to prevent flicker when moving from button to submenu */
.menu-group::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 8px; /* transparent strip under button */
}
.menu-button {
  background: transparent;
  color: #eaf3ff; /* brighter */
  border: 1px solid #2a3a56; /* slightly brighter border */
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
}
.menu-button.profile {
  color: #bcd3e6;
}
.menu-list {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: var(--card);
  border: 1px solid #22324a; /* align borders */
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  padding: 6px;
  display: none;
  z-index: 200;
}
.menu-list.right {
  right: 0;
  left: auto;
}
.menu-group.open > .menu-list {
  display: block;
}
.menu-item {
  display: block;
  color: #cfe2f5; /* softened */
  padding: 8px 10px;
  border-radius: 8px;
}
.menu-item:hover {
  background: rgba(30, 136, 229, 0.12); /* further toned down */
  color: #e6f2ff;
}
.menu-item.active {
  background: rgba(30, 136, 229, 0.18);
  color: #e6f2ff;
}

/* Show dropdown on hover or keyboard focus as well */
.menu-group:hover > .menu-list,
.menu-group:focus-within > .menu-list {
  display: block;
}

@media (max-width: 900px) {
  /* Mobile-friendly dropdown navigation: stacked, no floating popovers */
  #primary-nav .menu-button {
    display: none;
  }
  #primary-nav .menu-group {
    width: 100%;
  }
  #primary-nav .menu-list {
    position: static;
    display: block;
    min-width: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }
  #primary-nav .menu-item {
    padding: 10px 12px;
  }
}

/* Swarm detail: muted text and inline spinner utilities */
.muted {
  color: var(--muted);
}
.spinner-inline {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  vertical-align: -2px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
