/* ═══════════════════════════════════════════════
   ALTRADE AI — UNIFIED DESIGN TOKENS v1.0
   ═══════════════════════════════════════════════ */

:root {
  /* ── Brand Colors (Jade Green family — matches logo #4ECDA4) ── */
  --green-50: #eaf8f2;
  --green-100: #c8eddf;
  --green-200: #94dfc2;
  --green-300: #6FD8B8;
  --green-400: #4ECDA4;
  --green-500: #38B88E;
  --green-600: #2A9E78;
  --green-700: #1E8463;

  /* ── Accent (Blue — CTAs, focus, active states) ── */
  --accent-blue: #4A9EFF;
  --accent-blue-dim: #1A3A6B;

  /* ── Semantic ── */
  --profit: #4ECDA4;
  --loss: #F43F5E;
  --loss-bright: #ef4444;
  --warning: #F59E0B;
  --success: #10b981;
  --success-dim: #068060;

  /* ── Trading Semantic ── */
  --color-long: #48BB78;
  --color-long-bright: #10b981;
  --color-long-bg: #1A3B2A;
  --color-short: #FC8181;
  --color-short-bg: #3B1A1A;
  --color-paper: #c084fc;
  --color-paper-bg: rgba(168, 85, 247, 0.15);
  --color-warning-bg: #3B2E0A;
  --color-info: #60A5FA;

  /* ── Surfaces ── */
  --bg-deep: #0A0C10;
  --bg-base: #0F1117;
  --bg-surface: #1A1D27;
  --bg-elevated: #242836;
  --bg-hover: #2A2F3E;
  --bg-overlay: #252838;

  /* ── Additional Surfaces ── */
  --bg-input: #1e2130;
  --bg-pill: #353a4f;
  --bg-panel-alt: #2d3244;
  --bg-code: #131620;
  --bg-navy: #1a2d47;

  /* ── Borders ── */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-active: #4A9EFF;
  --border-green: rgba(78, 205, 164, 0.15);
  --border-green-hover: rgba(78, 205, 164, 0.35);
  --border-panel: #2d3244;
  --border-elevated: #404552;

  /* ── Text ── */
  --text-primary: #F1F5F9;
  --text-bright: #e2e8f0;
  --text-secondary: #94A3B8;
  --text-hint: #a0aec0;
  --text-label: #718096;
  --text-muted: #64748B;
  --text-placeholder: #4a5568;
  --text-green: #4ECDA4;
  --text-green-light: #68d391;
  --text-inverse: #0F1117;

  /* ── Typography ── */
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* ── Type Scale ── */
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 32px;

  /* ── Spacing (4px base) ── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-24: 96px;

  /* ── Border Radius ── */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* ── Shadows ── */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.5);

  /* ── Glows ── */
  --glow-green: 0 0 20px rgba(78, 205, 164, 0.15);
  --glow-green-strong: 0 0 40px rgba(78, 205, 164, 0.25);
  --glow-blue: 0 0 20px rgba(74, 158, 255, 0.15);

  /* ── Z-Index Scale ── */
  --z-base: 1;
  --z-dropdown: 200;
  --z-sticky: 250;
  --z-modal: 300;
  --z-tooltip: 400;
  --z-toast: 500;

  /* ── Transitions ── */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s ease;

  /* ── Exchange Brand ── */
  --binance-yellow: #F0B90B;
}

/* ═══════════════════════════════════════════════
   COMPONENT BASE CLASSES
   ═══════════════════════════════════════════════ */

/* Buttons */
.btn-primary {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--green-500), var(--green-400));
  color: var(--text-inverse);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--glow-green);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary:hover {
  box-shadow: var(--glow-green-strong);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 28px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-base);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-secondary:hover {
  border-color: var(--green-400);
  color: var(--green-400);
}

.btn-danger {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 24px;
  border: 1px solid rgba(244, 63, 94, 0.3);
  border-radius: var(--radius-md);
  background: rgba(244, 63, 94, 0.1);
  color: var(--loss);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-danger:hover {
  background: rgba(244, 63, 94, 0.2);
  border-color: var(--loss);
}

.btn-ghost {
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 500;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Form Inputs */
.input-field {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-md);
  transition: all var(--transition-fast);
  outline: none;
}
.input-field:focus {
  border-color: var(--green-400);
  box-shadow: 0 0 0 3px rgba(62, 189, 123, 0.1);
}
.input-field::placeholder {
  color: var(--text-muted);
}

/* Cards & Panels */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}

.card-elevated {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--transition-base);
}
.card-elevated:hover {
  border-color: var(--border-green);
  box-shadow: var(--glow-green);
}

/* Badges */
.badge-long {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--color-long-bg);
  color: var(--color-long);
  border: 1px solid rgba(72, 187, 120, 0.25);
}
.badge-short {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--color-short-bg);
  color: var(--color-short);
  border: 1px solid rgba(252, 129, 129, 0.25);
}
.badge-paper {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--color-paper-bg);
  color: var(--color-paper);
  border: 1px solid rgba(168, 85, 247, 0.3);
}

/* Consolidated Tab Navigation */
.tab-nav {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  gap: 0;
}
.tab-nav-item {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-3) var(--space-4);
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.tab-nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}
.tab-nav-item.active {
  color: var(--green-400);
  border-bottom-color: var(--green-400);
}

/* Consolidated Small Button */
.btn-sm {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 6px 12px;
  min-height: 32px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-sm:hover {
  color: var(--text-primary);
  border-color: var(--green-400);
  background: rgba(62, 189, 123, 0.05);
}

/* Consolidated Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-switch-track {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  transition: background var(--transition-base);
}
.toggle-switch-track::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: var(--text-label);
  border-radius: 50%;
  transition: transform var(--transition-base), background var(--transition-base);
}
.toggle-switch input:checked + .toggle-switch-track {
  background: var(--green-500);
}
.toggle-switch input:checked + .toggle-switch-track::before {
  transform: translateX(18px);
  background: white;
}

/* Status Dots */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.status-dot.live {
  background: var(--green-400);
  box-shadow: 0 0 8px rgba(62, 189, 123, 0.5);
  animation: status-pulse 2s infinite;
}
.status-dot.error {
  background: var(--loss);
  box-shadow: 0 0 8px rgba(244, 63, 94, 0.5);
}
.status-dot.warning {
  background: var(--warning);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ═══════════════════════════════════════════════
   FOCUS & ACCESSIBILITY
   ═══════════════════════════════════════════════ */

/* Focus Visible — enhanced per-component */
*:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}
button:focus-visible,
[role="button"]:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--green-400);
  box-shadow: 0 0 0 3px rgba(62, 189, 123, 0.15);
}
[role="tab"]:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: -2px;
}

/* Skip to content (screen readers) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Minimum touch target helper */
.touch-target {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ═══════════════════════════════════════════════
   LOADING SKELETONS
   ═══════════════════════════════════════════════ */

@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 25%,
    var(--bg-hover) 50%,
    var(--bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-text {
  height: 14px;
  width: 100%;
  margin-bottom: 8px;
}
.skeleton-text.short { width: 60%; }
.skeleton-text.tiny { width: 30%; }
.skeleton-card {
  height: 80px;
  width: 100%;
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
}
.skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

/* ═══════════════════════════════════════════════
   EMPTY STATES
   ═══════════════════════════════════════════════ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  gap: var(--space-4);
}
.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 28px;
  border: 1px solid var(--border-subtle);
}
.empty-state-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}
.empty-state-desc {
  font-size: var(--text-base);
  color: var(--text-secondary);
  max-width: 360px;
  line-height: 1.5;
}
.empty-state-action {
  margin-top: var(--space-2);
}

/* ═══════════════════════════════════════════════
   TAB TRANSITION ANIMATIONS
   ═══════════════════════════════════════════════ */

@keyframes tab-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.tab-content-animated {
  animation: tab-fade-in var(--transition-base) ease-out;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════ */

/* Tablet */
@media (max-width: 1024px) {
  :root {
    --text-xs: 11px;
    --text-sm: 12px;
    --text-base: 13px;
  }
}

/* Mobile landscape */
@media (max-width: 768px) {
  .left-sidebar {
    width: 56px !important;
  }
  .order-panel {
    position: fixed !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    z-index: var(--z-modal) !important;
    transform: translateX(100%);
    transition: transform var(--transition-base);
    box-shadow: var(--shadow-xl);
  }
  .order-panel.visible {
    transform: translateX(0);
  }
  .main-area {
    width: 100% !important;
  }
  .bottom-section {
    height: auto !important;
    max-height: 40vh !important;
  }
}

/* Mobile portrait */
@media (max-width: 480px) {
  .left-sidebar {
    width: 48px !important;
  }
  .sidebar-nav-label {
    display: none !important;
  }
  .bottom-tabs {
    font-size: var(--text-xs) !important;
  }
  .stat-card {
    padding: var(--space-3) !important;
  }
}

/* Monospace for data */
.font-mono { font-family: var(--font-mono); }
.font-display { font-family: var(--font-display); }
