/* DeFi Tracker Design System */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Roboto+Mono:wght@400;500;600&display=swap');

:root {
  /* Colors - Aave-style dark blue theme */
  --color-bg-primary: #0D0E12;
  --color-bg-secondary: #181A20;
  --color-bg-elevated: #23262F;
  --color-bg-surface: #13151A;
  --color-accent-primary: #10B981;
  --color-accent-secondary: #14F195;
  --color-accent-glow: rgba(16, 185, 129, 0.15);
  --color-positive: #10B981;
  --color-negative: #EF4444;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-bg-tertiary: #2A2D36;
  --color-text-primary: #FAFAFA;
  --color-text-secondary: #A1A1AA;
  --color-text-tertiary: #71717A;
  --color-text-muted: #52525B;
  --color-border: rgba(255, 255, 255, 0.06);
  --color-border-hover: rgba(255, 255, 255, 0.12);
  --color-border-accent: rgba(16, 185, 129, 0.3);

  /* Typography */
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Roboto Mono', 'SF Mono', 'Fira Code', monospace;

  /* Spacing */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 40px var(--color-accent-glow);

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
  background: var(--color-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle noise texture */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  opacity: 0.5;
  z-index: 1;
}

/* Ambient glow */
body::after {
  content: '';
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 400px;
  background: radial-gradient(ellipse, var(--color-accent-glow) 0%, transparent 70%);
  filter: blur(100px);
  pointer-events: none;
  opacity: 0.6;
  z-index: 0;
}

/* Page Container */
.page-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 24px;
  position: relative;
  z-index: 2;
  min-height: 100vh;
}

/* Header */
.page-header {
  margin-bottom: 48px;
}

/* Top Row: Navigation */
.header-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding-bottom: 16px;
}

.page-logo {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-accent-secondary);
  text-decoration: none;
  letter-spacing: -0.03em;
  transition: all 0.2s ease;
}

.page-logo:hover {
  color: var(--color-accent-primary);
  text-shadow: 0 0 20px var(--color-accent-glow);
}

.page-nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

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

/* Secondary Row: Status/Actions */
.header-secondary-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-top: 12px;
  min-height: 40px;
}

.header-status-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-text {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  font-weight: 400;
  letter-spacing: 0;
}

.status-text.status-syncing {
  color: var(--color-accent-primary);
}

.status-text.status-error {
  color: #EF4444;
}

.nav-link {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
}

.nav-link:hover {
  color: var(--color-text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: var(--color-accent-primary);
  background: rgba(16, 185, 129, 0.1);
}

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.875rem;
  letter-spacing: -0.01em;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--color-accent-primary);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-primary:hover {
  background: #0D9668;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  border-color: var(--color-border-hover);
  background: var(--color-bg-surface);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  padding: 8px 12px;
}

.btn-ghost:hover {
  color: var(--color-text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
}

.btn-outline:hover {
  border-color: var(--color-accent-primary);
  background: rgba(16, 185, 129, 0.08);
  color: var(--color-accent-primary);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

/* Cards */
.card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.card:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-md);
}

.card-elevated {
  background: var(--color-bg-elevated);
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: var(--spacing-lg);
  right: var(--spacing-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-slide-in 0.3s ease, toast-fade-out 0.3s ease 2.7s forwards;
  max-width: 320px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.toast:hover {
  transform: scale(1.02);
}

.toast-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  font-size: 0.625rem;
  font-weight: 700;
  flex-shrink: 0;
}

.toast-text {
  line-height: 1.4;
}

.toast-success {
  background: var(--color-bg-elevated);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--color-text-primary);
}

.toast-success .toast-icon {
  background: var(--color-accent-primary);
  color: white;
}

.toast-error {
  background: var(--color-bg-elevated);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--color-text-primary);
}

.toast-error .toast-icon {
  background: #EF4444;
  color: white;
}

@keyframes toast-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Legacy flash messages (kept for auth pages) */
.flash {
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 24px;
  text-align: center;
  font-weight: 500;
  font-size: 0.875rem;
}

.flash-notice {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--color-accent-primary);
}

.flash-alert {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #EF4444;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

h1 {
  font-size: 2.25rem;
  font-weight: 700;
  margin-bottom: 16px;
}

h2 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 12px;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

/* Monospace values - for numbers, data, crypto values */
.mono, .value, [data-mono] {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1, 'ss01' 1;
  letter-spacing: -0.02em;
}

/* ========================================
   APP LAYOUT WITH SIDEBAR
   ======================================== */

/* Override auth page body centering when app layout is present */
body:has(.app-layout) {
  display: block;
  align-items: initial;
  justify-content: initial;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 2;
}

/* ========================================
   SIDEBAR
   ======================================== */

.sidebar {
  width: 260px;
  min-width: 260px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  padding: 24px 16px;
  z-index: 100;
}

.sidebar-header {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--color-accent-secondary);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  transition: all 0.2s ease;
  margin-bottom: 16px;
}

.sidebar-logo:hover {
  color: var(--color-accent-primary);
}

.sidebar-logo svg {
  flex-shrink: 0;
}

.sidebar-portfolio-total {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.portfolio-label {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.portfolio-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;           /* Firefox */
  -ms-overflow-style: none;        /* IE/Edge */
}
.sidebar-nav::-webkit-scrollbar {
  display: none;                   /* Chrome/Safari */
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-label {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 12px 4px;
  margin-top: 8px;
}

.nav-divider {
  height: 1px;
  background: var(--color-border);
  margin: 12px 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.sidebar-link:hover:not(.disabled) {
  color: var(--color-text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-link.active {
  color: var(--color-accent-primary);
  background: rgba(16, 185, 129, 0.1);
}

.sidebar-link.active svg {
  color: var(--color-accent-primary);
}

.sidebar-link.disabled {
  color: var(--color-text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}

.sidebar-link svg {
  flex-shrink: 0;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-text-secondary);
  min-width: 0;
}

.user-email {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--color-text-tertiary);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-logout:hover {
  color: #EF4444;
  background: rgba(239, 68, 68, 0.1);
}

/* ========================================
   MAIN CONTENT
   ======================================== */

.main-content {
  flex: 1;
  width: calc(100% - 260px);
  margin-left: 260px;
  padding: 32px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content > * {
  width: 100%;
  max-width: 1200px;
  align-self: stretch;
  margin-left: auto;
  margin-right: auto;
}

/* ========================================
   MOBILE HEADER
   ======================================== */

.mobile-header {
  display: none;
}

.sidebar-toggle-checkbox {
  display: none;
}

/* ========================================
   RESPONSIVE - TABLET & MOBILE
   ======================================== */

@media (max-width: 1024px) {
  .main-content {
    padding: 24px;
  }
}

@media (max-width: 768px) {
  /* Hide sidebar by default on mobile */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
  }

  /* Show mobile header */
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    padding: 0 16px;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    z-index: 90;
  }

  .mobile-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--color-accent-secondary);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 600;
  }

  .mobile-portfolio {
    margin-left: auto;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-primary);
  }

  /* Hamburger button */
  .hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    z-index: 110;
  }

  .hamburger-line {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--color-text-primary);
    border-radius: 1px;
    transition: all 0.3s ease;
  }

  /* Hamburger animation when open */
  .sidebar-toggle-checkbox:checked ~ .hamburger-btn .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .sidebar-toggle-checkbox:checked ~ .hamburger-btn .hamburger-line:nth-child(2) {
    opacity: 0;
  }

  .sidebar-toggle-checkbox:checked ~ .hamburger-btn .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
  }

  /* Overlay */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 95;
  }

  .sidebar-toggle-checkbox:checked ~ .sidebar-overlay {
    opacity: 1;
    visibility: visible;
  }

  /* Show sidebar when checkbox is checked */
  .sidebar-toggle-checkbox:checked ~ .sidebar {
    transform: translateX(0);
  }

  /* Main content adjustments */
  .main-content {
    margin-left: 0;
    padding: 76px 16px 24px;
  }

  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.375rem;
  }
}

/* Legacy support - keep old page-container for non-sidebar pages */
.page-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 24px;
  position: relative;
  z-index: 2;
  min-height: 100vh;
}

@media (max-width: 768px) {
  .page-container {
    padding: 24px 16px;
  }
}

/* ========================================
   COMING SOON PAGE
   ======================================== */

.coming-soon-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  text-align: center;
}

.coming-soon-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 400px;
}

.coming-soon-icon {
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.coming-soon-page h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0;
  color: var(--color-text-primary);
}

.coming-soon-description {
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  line-height: 1.5;
  margin: 0;
}

.coming-soon-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-full);
  color: var(--color-accent-primary);
  font-size: 0.8125rem;
  font-weight: 500;
  margin-top: 8px;
}
