/* Gope360 Dashboard — Brand tokens + shared shell */

:root {
  --navy: #0B2A4A;
  --navy-deep: #071B31;
  --navy-soft: #123A5E;
  --teal: #14C7A6;
  --teal-dark: #0A8F76;
  --teal-light: #7FF0D6;
  --white: #FFFFFF;
  --offwhite: #F6F9FA;
  --ink: #0B2A4A;
  --slate: #5B6B79;
  --slate-light: #94A6AF;
  --border: rgba(11, 42, 74, 0.10);
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --shadow-sm: 0 2px 10px rgba(11, 42, 74, 0.06);
  --shadow-md: 0 16px 40px rgba(11, 42, 74, 0.12);
  --glow: 0 0 0 1px rgba(20, 199, 166, 0.4), 0 16px 40px rgba(20, 199, 166, 0.18);
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --ease: cubic-bezier(.22, .9, .32, 1);

  /* Light defaults (overridden by dark) */
  --bg: #F6F9FA;
  --bg-alt: #FFFFFF;
  --surface: #FFFFFF;
  --ink-soft: #5B6B79;
  --gain: #3ecf8e;
  --loss: #f07178;
  --warn: #e8a838;
  --info: #4a90e2;
  --sidebar-w: 240px;
  --sidebar-collapsed-w: 72px;
  --topbar-h: 56px;
  --bottom-nav-h: 64px;
}

[data-theme="dark"] {
  --bg: #050D18;
  --bg-alt: #0A1A2C;
  --surface: #0F2338;
  --ink: #F2F7F9;
  --ink-soft: #B9C9D2;
  --slate: #93A6B2;
  --border: rgba(255, 255, 255, 0.09);
  --teal-dark: #4FE0C2;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 16px 40px rgba(0, 0, 0, 0.35);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.mono, .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-light); }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

img { max-width: 100%; display: block; }

/* ── App shell ─────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: var(--sidebar-w);
  height: 100%;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.28s var(--ease), transform 0.28s var(--ease);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-w);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--navy-deep);
  overflow: hidden;
}

/* GOPE360-transparent.png is a full square wordmark (mark + "GOPE360" text
   on a white background), not a small transparent icon — so the sidebar's
   32px mark shows just the top of it, zoomed and cropped to the circular
   mark itself, rather than shrinking the whole wordmark down illegibly. */
.logo-mark img {
  width: 180%;
  height: 180%;
  object-fit: cover;
  object-position: center 30%;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.2s var(--ease);
}

.sidebar.collapsed .logo-text {
  opacity: 0;
  pointer-events: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
  white-space: nowrap;
  text-decoration: none;
  position: relative;
}

.nav-item:hover {
  background: rgba(20, 199, 166, 0.08);
  color: var(--ink);
}

.nav-item.active {
  background: rgba(20, 199, 166, 0.12);
  color: var(--teal);
}

.nav-item.active .icon-badge {
  background: rgba(20, 199, 166, 0.22);
}

.icon-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(20, 199, 166, 0.12);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.2s var(--ease);
}

.icon-badge svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-label {
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 1;
  transition: opacity 0.2s var(--ease);
}

.sidebar.collapsed .nav-label {
  opacity: 0;
  pointer-events: none;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Main column */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.28s var(--ease);
}

.sidebar.collapsed ~ .main {
  margin-left: var(--sidebar-collapsed-w);
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 12px;
  padding: 0 16px;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.btn-icon:hover {
  background: rgba(20, 199, 166, 0.1);
  color: var(--ink);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-width: 0;
  overflow: hidden;
}

.live-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  white-space: nowrap;
  min-width: 0;
}

.live-stat .value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink);
  font-weight: 500;
}

.live-stat .label {
  display: none;
}

.live-stat .value-sub {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--slate);
  font-weight: 400;
  margin-left: 2px;
}

/* SOL market price is secondary/reference info — keep it visually
   subordinate to the wallet balance so the two are never confused. */
.live-stat.sol-stat .value {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--ink-soft);
}

/* Wallet balance is the primary figure in the top bar. */
.live-stat.balance-stat {
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  min-width: 0;
}

.live-stat.balance-stat .value {
  font-size: 0.86rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 170px;
}

.balance-eye-btn {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  flex-shrink: 0;
}

.balance-eye-btn svg {
  width: 15px;
  height: 15px;
  /* .btn-icon is a bare `display:grid` with no template, so two children
     land in separate auto-generated rows (stacked) instead of overlapping.
     Pin both icons to the same cell so only the CSS `display` toggle
     below controls which one is visible. */
  grid-column: 1;
  grid-row: 1;
}

/* Icon state is fully class-driven — only one icon is ever in the DOM's
   visible flow at a time, regardless of attribute state. */
.balance-eye-btn .icon-eye-off {
  display: none;
}

.balance-eye-btn.is-masked .icon-eye {
  display: none;
}

.balance-eye-btn.is-masked .icon-eye-off {
  display: block;
}

/* Masked state — the real figure is swapped out for a dot placeholder
   (not blurred) so it reads cleanly as "hidden" rather than "broken". */
.live-stat.balance-stat .value.balance-masked {
  letter-spacing: 1px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gain);
  box-shadow: 0 0 6px var(--gain);
  flex-shrink: 0;
}

.status-dot.offline {
  background: var(--loss);
  box-shadow: 0 0 6px var(--loss);
}

.status-dot.degraded {
  background: var(--warn);
  box-shadow: 0 0 6px var(--warn);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  position: relative;
}

/* Desktop: theme + logout sit inline exactly as before; the account
   menu trigger is unused and hidden. */
.account-menu-toggle {
  display: none;
}

.account-menu-panel {
  display: flex;
  align-items: center;
  gap: 4px;
}

.notif-btn {
  position: relative;
}

.notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--teal);
  color: var(--navy-deep);
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  line-height: 1;
  border: 2px solid var(--bg-alt);
  box-sizing: content-box;
  pointer-events: none;
}

.notif-badge:empty,
.notif-badge[data-count="0"] {
  display: none;
}

/* Content area */
.content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Bottom tab bar (mobile) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  height: var(--bottom-nav-h);
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  color: var(--ink-soft);
  font-size: 0.65rem;
  font-weight: 500;
  transition: color 0.2s var(--ease);
  text-decoration: none;
  max-width: 80px;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-nav-item.active {
  color: var(--teal);
}

/* ── Shared components ─────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

.card.glow {
  box-shadow: var(--glow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.15s var(--ease);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--teal);
  color: var(--navy-deep);
}

.btn-primary:hover {
  background: var(--teal-light);
  box-shadow: var(--glow);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
}

.btn-ghost:hover {
  background: rgba(20, 199, 166, 0.08);
  border-color: rgba(20, 199, 166, 0.3);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--loss);
  color: var(--loss);
}

.btn-danger:hover {
  background: rgba(240, 113, 120, 0.1);
}

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.pill-safe { background: rgba(62, 207, 142, 0.15); color: var(--gain); }
.pill-warn { background: rgba(232, 168, 56, 0.15); color: var(--warn); }
.pill-danger { background: rgba(240, 113, 120, 0.15); color: var(--loss); }

.gain { color: var(--gain); }
.loss { color: var(--loss); }
.warn { color: var(--warn); }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-soft);
  white-space: nowrap;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.tab:hover { color: var(--ink); }
.tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Loading / empty / error */
.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-soft);
}

.state-block svg {
  width: 40px;
  height: 40px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  opacity: 0.5;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: min(360px, calc(100% - 32px));
}

.toast {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-md);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.3s var(--ease);
}

.toast.success { border-left: 3px solid var(--gain); }
.toast.error { border-left: 3px solid var(--loss); }
.toast.info { border-left: 3px solid var(--teal); }

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

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(5, 13, 24, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s var(--ease), visibility 0.25s var(--ease);
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  width: min(400px, 100%);
  padding: 24px;
  transform: scale(0.95);
  transition: transform 0.25s var(--ease);
}

.modal-backdrop.open .modal {
  transform: scale(1);
}

.modal.danger {
  border-color: var(--loss);
}

.modal h3 {
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.modal p {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: var(--sidebar-w);
  }

  .main {
    margin-left: 0 !important;
  }

  .bottom-nav {
    display: flex;
  }

  .content {
    padding-bottom: calc(var(--bottom-nav-h) + 16px + env(safe-area-inset-bottom, 0));
  }

  .live-stat .label {
    display: none;
  }

  .live-stat.balance-stat .value {
    max-width: 110px;
  }

  .live-stat.balance-stat {
    padding: 4px 4px 4px 8px;
    gap: 4px;
  }

  /* Only one figure fits comfortably on a narrow header — show the USD
     equivalent (what most people actually glance at) and hide the raw
     SOL amount, rather than clipping either. */
  .live-stat.balance-stat .value-main {
    display: none;
  }

  .live-stat.balance-stat .value-sub {
    display: inline;
    margin-left: 0;
    font-size: inherit;
    color: inherit;
    font-weight: 600;
  }

  /* On a narrow header the USD figure IS the primary balance shown (SOL is
     hidden above), so the parentheses that make sense around it as a
     secondary/reference value on desktop would just read oddly here —
     drop them. */
  .live-stat.balance-stat .value-sub .paren {
    display: none;
  }

  .live-stat.balance-stat .value {
    max-width: 130px;
  }

  /* Collapse Theme + Log out behind a single account icon so the top
     bar doesn't run out of room next to the balance chip. */
  .account-menu-toggle {
    display: grid;
  }

  .account-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
    z-index: 60;
    display: none;
  }

  .account-menu-panel.open {
    display: flex;
  }

  .account-menu-panel .btn-icon {
    width: 100%;
    justify-content: flex-start;
    padding: 0 10px;
    gap: 10px;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 99;
    background: rgba(5, 13, 24, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s var(--ease), visibility 0.25s var(--ease);
  }

  .sidebar-overlay.open {
    opacity: 1;
    visibility: visible;
  }
}

@media (min-width: 901px) {
  .sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px;
    gap: 0;
  }

  .sidebar.collapsed .icon-badge {
    margin: 0;
  }

  /* Collapse the label out of flow instead of just fading it — opacity alone
     left its full-width ghost text in the flex row, which pushed the
     centering off and could clip the icon against the 72px rail. */
  .sidebar.collapsed .nav-label {
    width: 0;
    margin: 0;
    overflow: hidden;
  }

  .sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
  }

  .sidebar.collapsed .logo {
    gap: 0;
  }

  .sidebar.collapsed .logo-text {
    width: 0;
    margin: 0;
    overflow: hidden;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 0 10px;
    gap: 6px;
  }

  .topbar-center {
    gap: 6px;
  }

  .live-stat {
    font-size: 0.75rem;
  }

  .live-stat.sol-stat .value {
    font-size: 0.68rem;
  }

  .live-stat.balance-stat .value {
    max-width: 88px;
    font-size: 0.8rem;
  }

  .live-stat[title="Network status"] .status-dot {
    width: 6px;
    height: 6px;
  }

  .content {
    padding: 12px;
    /* The 900px query above sets padding-bottom to clear the fixed
       bottom-nav; the shorthand above resets all four sides, which was
       wiping that clearance back down to 12px on phones ≤480px wide —
       exactly where the bottom-nav is actually visible. Re-apply it. */
    padding-bottom: calc(var(--bottom-nav-h) + 16px + env(safe-area-inset-bottom, 0));
  }
}

/* ── Footer ─────────────────────────────────────────── */
/* Structurally mirrors .topbar: a sibling of .content inside .main
   (flex column), not a child of .content. .topbar sits above the
   scrollable area and never moves; .app-footer now sits below it the
   same way — both outside the part of the page that actually scrolls,
   so .content (flex: 1; overflow-y: auto) is simply the space left
   between them and its own content flows/scrolls underneath both. No
   position: sticky trickery needed, same as .topbar doesn't need any
   either — being outside the scroll container is what does it. */
.app-footer {
  flex-shrink: 0;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
}

.app-footer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.app-footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-footer-brand .logo-mark {
  width: 22px;
  height: 22px;
  font-size: 10px;
  border-radius: 6px;
}

.app-footer-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
}

.app-footer-links {
  display: flex;
  gap: 14px;
}

.app-footer-links a {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.app-footer-links a:hover {
  color: var(--teal);
}

.app-footer-disclaimer {
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--ink-soft);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  /*margin-bottom: 10px;*/
}

.app-footer-disclaimer strong {
  color: var(--ink);
}

.app-footer-bottom {
  font-size: 0.7rem;
  color: var(--slate);
  padding-bottom: 4px;
}

/* On small screens the footer disclaimer is hidden — the bottom-nav
   already claims that screen edge on mobile, and there isn't room for
   both. The same disclaimer text lives in Settings so it's never
   actually unreachable, just relocated on mobile. */
@media (max-width: 900px) {
  .app-footer { display: none; }
}
