/* Laya Trading Cockpit - Institutional Obsidian Design System
 * Audited for Vercel Web Interface Guidelines & WCAG 2.1 AA Compliance
 */

:root {
  --bg-base: #070A11;
  --bg-surface: #0D131F;
  --bg-card: #121A2B;
  --bg-card-hover: #182238;
  --border-subtle: #1E2B45;
  --border-accent: #2A3D63;
  --primary: #00F2FE;
  --primary-glow: rgba(0, 242, 254, 0.15);
  --accent-emerald: #10B981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.15);
  --accent-crimson: #FF4B72;
  --accent-crimson-glow: rgba(255, 75, 114, 0.15);
  --accent-amber: #F59E0B;
  --accent-amber-glow: rgba(245, 158, 11, 0.15);
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

/* Accessibility: Visible Focus States (Web Interface Guidelines Rule §39) */
*:focus-visible {
  outline: 2px solid var(--primary) !important;
  outline-offset: 2px !important;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow-x: hidden;
  min-height: 100vh;
}

/* Typography Rule §76: Tabular Figures for Stationary Numbers */
.mono, .tabular-nums {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Accessibility: Skip-to-content Link (WCAG 2.4.1) */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--primary);
  color: #070A11;
  padding: 0.5rem 1rem;
  font-weight: 700;
  font-family: var(--font-mono);
  border-radius: 4px;
  z-index: 9999;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 1rem;
}

/* Fitts' Law: Minimum 44px Hit Target (Rule §49) */
.touch-target {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* Glassmorphism Card (Layered depth without visual noise) */
.cockpit-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cockpit-card:hover {
  border-color: var(--border-accent);
}

/* Glow Badges */
.badge-cyan {
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid rgba(0, 242, 254, 0.3);
}

.badge-emerald {
  background: var(--accent-emerald-glow);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-crimson {
  background: var(--accent-crimson-glow);
  color: var(--accent-crimson);
  border: 1px solid rgba(255, 75, 114, 0.3);
}

.badge-amber {
  background: var(--accent-amber-glow);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Animation Rule §61 & §63: Hardware Accelerated Pulse */
@keyframes pulse-cyan {
  0% { box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(0, 242, 254, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 242, 254, 0); }
}

.pulse-active {
  animation: pulse-cyan 2s infinite;
}

/* Motion Accessibility: Prefers-Reduced-Motion (Web Interface Guidelines Rule §61) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .pulse-active {
    animation: none !important;
  }
}

/* Kill Switch Glowing Button */
.btn-kill-switch {
  background: linear-gradient(135deg, #FF4B72, #991B1B);
  color: #FFFFFF;
  border: 1px solid #FF4B72;
  box-shadow: 0 0 12px rgba(255, 75, 114, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-kill-switch:hover {
  box-shadow: 0 0 20px rgba(255, 75, 114, 0.6);
  transform: translateY(-1px);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--border-accent);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Active Coin Selection Glow */
.coin-card-active {
  border-color: #00F2FE !important;
  background: rgba(0, 242, 254, 0.08) !important;
  box-shadow: 0 0 16px rgba(0, 242, 254, 0.25) !important;
  position: relative;
}

.coin-card-active::after {
  content: "ACTIVE";
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  background: #00F2FE;
  color: #070A11;
}

/* Depth Bar on Order Book */
.depth-bar-container {
  position: relative;
  overflow: hidden;
}

.depth-bar-bid {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: rgba(16, 185, 129, 0.15);
  pointer-events: none;
  transition: width 0.3s ease;
}

.depth-bar-ask {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 75, 114, 0.15);
  pointer-events: none;
  transition: width 0.3s ease;
}

/* Live Tick Flashes */
@keyframes flash-green-anim {
  0% { background-color: rgba(16, 185, 129, 0.4); }
  100% { background-color: transparent; }
}

@keyframes flash-red-anim {
  0% { background-color: rgba(255, 75, 114, 0.4); }
  100% { background-color: transparent; }
}

.flash-green {
  animation: flash-green-anim 0.8s ease-out;
}

.flash-red {
  animation: flash-red-anim 0.8s ease-out;
}

/* Range slider styling */
input[type="range"] {
  height: 6px;
  border-radius: 4px;
  background: var(--border-subtle);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: #FF4B72;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(255, 75, 114, 0.5);
}

/* Leverage & Matrix chips active state */
.lev-chip.active {
  background: rgba(255, 75, 114, 0.2) !important;
  color: #FF4B72 !important;
  border-color: #FF4B72 !important;
  font-weight: 700 !important;
}

.matrix-coin-chip.active, .matrix-strat-chip.active {
  background: rgba(0, 242, 254, 0.2) !important;
  color: #00F2FE !important;
  border-color: #00F2FE !important;
  font-weight: 700 !important;
}

/* =========================================================
 * OPENTERMINAL + KRONOS COCKPIT FUSION DESIGN SYSTEM
 * ========================================================= */

/* 1. Terminal Widgets & Draggable Layout Engine */
.terminal-widget {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.terminal-widget.drag-over {
  border-color: var(--primary) !important;
  box-shadow: 0 0 20px rgba(0, 242, 254, 0.3) !important;
  transform: translateY(-2px);
}

.terminal-widget.is-dragging {
  opacity: 0.45;
}

.terminal-widget-header {
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.widget-grip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.widget-grip:hover {
  background: rgba(0, 242, 254, 0.1);
}

/* Minimized Widget State: Collapses body, preserves header */
.terminal-widget.is-minimized .terminal-widget-body {
  display: none !important;
}

.terminal-widget.is-minimized {
  height: auto !important;
  min-height: 0 !important;
}

/* Maximized Widget State: Expands to full cockpit overlay */
.terminal-widget.is-maximized {
  position: fixed !important;
  inset: 1.25rem !important;
  z-index: 55 !important;
  height: auto !important;
  max-height: calc(100vh - 2.5rem) !important;
  overflow-y: auto !important;
  box-shadow: 0 0 50px rgba(0, 242, 254, 0.35) !important;
  border: 2px solid var(--primary) !important;
}

.terminal-widget.is-maximized .terminal-widget-body {
  height: calc(100% - 50px);
}

/* 2. Global Command Palette Modal */
#command-palette-modal {
  transition: opacity 0.2s ease;
}

.palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.palette-item:hover,
.palette-item.palette-selected {
  background: rgba(0, 242, 254, 0.12) !important;
  border-color: rgba(0, 242, 254, 0.45) !important;
}

.palette-item.palette-selected .palette-item-title {
  color: #FFFFFF !important;
  font-weight: 700;
}

.palette-quick-chip {
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.palette-quick-chip:hover {
  transform: translateY(-1px);
}

/* 3. Level-2 Orderbook Ladder Rows & Depth Bars */
.l2-row {
  position: relative;
  overflow: hidden;
  padding: 2px 6px;
  border-radius: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  transition: background 0.15s ease;
}

.l2-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.l2-bar-bid {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: rgba(16, 185, 129, 0.2);
  pointer-events: none;
  transition: width 0.25s ease-out;
  border-right: 2px solid rgba(16, 185, 129, 0.5);
}

.l2-bar-ask {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 75, 114, 0.2);
  pointer-events: none;
  transition: width 0.25s ease-out;
  border-left: 2px solid rgba(255, 75, 114, 0.5);
}

/* 4. 741-Coin Treemap / Heatmap Tiles */
.heatmap-tile {
  position: relative;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.18s ease, border-color 0.18s ease;
  user-select: none;
  font-family: var(--font-mono);
}

.heatmap-tile:hover {
  transform: scale(1.05);
  z-index: 20;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6), 0 0 15px rgba(0, 242, 254, 0.4);
  border-color: var(--primary) !important;
}

.heatmap-tile.active-asset {
  border-color: #00F2FE !important;
  box-shadow: 0 0 16px rgba(0, 242, 254, 0.4) !important;
}

.heatmap-tile.active-asset::after {
  content: "●";
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 8px;
  color: #00F2FE;
}

/* Reflex chips active state */
.reflex-lev-chip.active {
  background: rgba(255, 75, 114, 0.25) !important;
  color: #FF4B72 !important;
  border-color: #FF4B72 !important;
  font-weight: 700 !important;
}

/* Mode switch button styles */
.mode-switch-btn {
  touch-action: manipulation;
}

/* WCAG 2.1 AA High-Contrast Focus Rings */
button:focus-visible,
select:focus-visible,
input:focus-visible,
.heatmap-tile:focus-visible {
  outline: 2px solid #00F2FE !important;
  outline-offset: 2px !important;
}

