/* ============================================================
   AKALCG — Premium Dark Trading Dashboard
   Glassmorphism · Gradient accents · Refined typography
   ============================================================ */

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

:root {
  /* Core palette */
  --bg:          #050508;
  --bg-gradient:  linear-gradient(135deg, #050508 0%, #0a0a14 50%, #080812 100%);
  --surface:     rgba(14, 14, 22, 0.85);
  --surface-solid: #0e0e16;
  --surface-2:   rgba(20, 20, 32, 0.9);
  --surface-3:   rgba(28, 28, 42, 0.8);
  --glass:       rgba(16, 16, 28, 0.6);
  --glass-border: rgba(255, 255, 255, 0.06);

  /* Borders */
  --border:      rgba(255, 255, 255, 0.06);
  --border-2:    rgba(255, 255, 255, 0.1);
  --border-glow:  rgba(100, 140, 255, 0.15);

  /* Text */
  --text:        #f0f0f5;
  --text-2:      #9898a8;
  --text-3:      #5c5c6e;
  --text-dim:    #3a3a4a;

  /* Accents */
  --accent:      #6c8cff;
  --accent-2:    #8b5cf6;
  --green:       #22d68a;
  --green-glow:  rgba(34, 214, 138, 0.2);
  --green-dim:   #1aad70;
  --red:         #f04770;
  --red-glow:    rgba(240, 71, 112, 0.2);
  --red-dim:     #c23a5c;
  --yellow:      #f0c040;
  --blue:        #6c8cff;
  --cyan:        #22d6d6;

  /* Gradient accents */
  --grad-accent: linear-gradient(135deg, #6c8cff 0%, #8b5cf6 50%, #d946ef 100%);
  --grad-green:  linear-gradient(135deg, #22d68a 0%, #22d6d6 100%);
  --grad-red:    linear-gradient(135deg, #f04770 0%, #ff6b6b 100%);

  /* Typography */
  --mono:        'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --sans:        'Inter', 'Helvetica Neue', -apple-system, sans-serif;

  /* Spacing & shapes */
  --radius:      8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --transition:  200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 20px rgba(108, 140, 255, 0.08);
}

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

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0.01em;
  overflow-x: hidden;
}

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

/* ---- Layout Shell ---- */
.dashboard-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ---- Header ---- */
.header {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Gradient accent line under header */
.header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--grad-accent);
  opacity: 0.5;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo i { display: none; }

.logo h1 {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  background: var(--grad-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-info {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  font-size: 0.78rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-2);
  background: rgba(34, 214, 138, 0.06);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  border: 1px solid rgba(34, 214, 138, 0.15);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.disconnected {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--green); }
  50% { opacity: 0.5; box-shadow: 0 0 16px var(--green); }
}

.last-update {
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 0.72rem;
}

/* ---- Main Content ---- */
.main-content {
  display: grid;
  grid-template-columns: 280px 1fr;
  flex: 1;
  gap: 0;
}

/* ---- Sidebar ---- */
.sidebar {
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
}

.control-section {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.control-section:first-child { padding-top: 0; }
.control-section:last-child { border-bottom: none; }

.control-section h2 {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-section h2 i {
  color: var(--text-3);
  font-size: 0.7rem;
}

.control-group {
  margin-bottom: 0.75rem;
}

.control-group label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 500;
}

.control-group label i { display: none; }

.control-group select,
.control-group input[type="number"],
.control-group input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.65rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
  transition: all var(--transition);
  outline: none;
}

.control-group select:focus,
.control-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.1);
}

.control-group select option {
  background: var(--surface-solid);
  color: var(--text);
}

.control-group input[type="checkbox"] {
  margin-right: 0.4rem;
  accent-color: var(--green);
}

/* ---- Buttons ---- */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.btn {
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.04) 100%);
  opacity: 0;
  transition: opacity var(--transition);
}

.btn:hover::before { opacity: 1; }

.btn:hover {
  border-color: var(--text-3);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

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

.btn i { font-size: 0.7rem; }

.btn-primary {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 16px rgba(108, 140, 255, 0.3);
}

.btn-success {
  border-color: var(--green-dim);
  color: var(--green);
}
.btn-success:hover {
  background: var(--green);
  color: var(--bg);
  box-shadow: 0 0 16px var(--green-glow);
}

.btn-info {
  border-color: var(--blue);
  color: var(--blue);
}
.btn-info:hover {
  background: var(--blue);
  color: var(--bg);
  box-shadow: 0 0 16px rgba(108, 140, 255, 0.3);
}

.btn-buy {
  border-color: var(--green-dim);
  color: var(--green);
}
.btn-buy:hover {
  background: var(--green);
  color: var(--bg);
  box-shadow: 0 0 16px var(--green-glow);
}

.btn-sell {
  border-color: var(--red-dim);
  color: var(--red);
}
.btn-sell:hover {
  background: var(--red);
  color: var(--bg);
  box-shadow: 0 0 16px var(--red-glow);
}

.btn-danger {
  border-color: var(--red-dim);
  color: var(--red);
}
.btn-danger:hover {
  background: var(--red);
  color: var(--bg);
  box-shadow: 0 0 16px var(--red-glow);
}

/* ---- System Log ---- */
.system-log {
  background: rgba(0, 0, 0, 0.5);
  color: var(--green);
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.68rem;
  max-height: 160px;
  overflow-y: auto;
  line-height: 1.7;
}

.system-log::-webkit-scrollbar { width: 3px; }
.system-log::-webkit-scrollbar-track { background: transparent; }
.system-log::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.log-entry {
  margin-bottom: 0.15rem;
  opacity: 0;
  animation: fadeIn 300ms ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.log-time { color: var(--text-3); }
.log-error { color: var(--red); }

/* ---- Dashboard Main ---- */
.dashboard-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  overflow-y: auto;
  height: calc(100vh - 60px);
}

/* ---- Stats Grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
}

.stat-card {
  background: var(--surface-solid);
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--grad-accent);
  opacity: 0;
  transition: opacity var(--transition);
}

.stat-card:hover {
  background: var(--surface-2);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-icon { display: none; }

.stat-content { width: 100%; }

.stat-content h3 {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.6rem;
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  margin-bottom: 0.3rem;
  line-height: 1.1;
}

.stat-change {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
}

.stat-change.positive { color: var(--green); }
.stat-change.negative { color: var(--red); }

/* ---- Subsystem Status Grid ---- */
.subsystem-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--border);
}

.subsystem-card {
  background: var(--surface-solid);
  padding: 1rem 1.25rem;
  transition: all var(--transition);
}

.subsystem-card:hover {
  background: var(--surface-2);
}

.subsystem-card .sub-name {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.5rem;
}

.subsystem-card .sub-status {
  font-family: var(--mono);
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-2);
}

.sub-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.sub-dot.running {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse-green 2s ease-in-out infinite;
}

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 6px var(--green); }
  50% { box-shadow: 0 0 12px var(--green); }
}

.sub-dot.stopped { background: var(--text-dim); }
.sub-dot.error {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}

.subsystem-card .sub-value {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 0.4rem;
}

/* ---- Charts ---- */
.charts-section {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1px;
  background: var(--border);
}

.chart-container {
  background: var(--surface-solid);
  padding: 1.5rem 1.75rem;
}

.chart-container h2,
.table-container h2,
.predictions-section h2 {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-container h2 i,
.table-container h2 i,
.predictions-section h2 i {
  color: var(--text-3);
  font-size: 0.7rem;
}

/* ---- Tables ---- */
.table-container {
  background: var(--surface-solid);
  padding: 1.5rem 1.75rem;
}

.market-table {
  width: 100%;
  border-collapse: collapse;
}

.market-table thead th {
  background: transparent;
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border-2);
}

.market-table tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-2);
  transition: all var(--transition);
}

.market-table tbody tr {
  transition: all var(--transition);
}

.market-table tbody tr:hover {
  background: var(--surface-2);
}

.market-table tbody tr:hover td {
  color: var(--text);
}

.market-table tbody td strong {
  color: var(--text);
  font-weight: 600;
}

.market-table .loading,
.market-table .empty-state {
  text-align: center;
  color: var(--text-3);
  padding: 2.5rem;
  font-family: var(--sans);
  font-size: 0.8rem;
}

.change-positive { color: var(--green) !important; font-weight: 600; }
.change-negative { color: var(--red) !important; font-weight: 600; }

/* ---- Predictions ---- */
.predictions-section {
  background: var(--surface-solid);
  padding: 1.5rem 1.75rem;
}

.predictions-content .empty-state {
  text-align: center;
  color: var(--text-3);
  padding: 2rem;
  font-size: 0.8rem;
}

.prediction-card {
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid var(--text-3);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  border-radius: var(--radius);
  transition: all var(--transition);
}

.prediction-card:hover {
  background: rgba(0, 0, 0, 0.4);
}

.prediction-card h3 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
  margin-bottom: 0.6rem;
}

.prediction-card p {
  margin-bottom: 0.3rem;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.signal-buy {
  border-left-color: var(--green);
  box-shadow: inset 3px 0 12px -3px var(--green-glow);
}
.signal-sell {
  border-left-color: var(--red);
  box-shadow: inset 3px 0 12px -3px var(--red-glow);
}
.signal-hold {
  border-left-color: var(--yellow);
}

/* ---- Watchlist Section ---- */
#watchlist-section {
  background: var(--surface-solid);
}

#search-results {
  margin-top: 0.5rem;
}

#search-results label {
  font-size: 0.7rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#search-results-select {
  width: 100%;
  margin-top: 0.35rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.3rem;
  border-radius: var(--radius);
}

#search-results-select option {
  background: var(--surface-solid);
  color: var(--text);
  padding: 0.25rem;
}

#select-search-result {
  margin-top: 0.35rem;
  width: 100%;
}

/* ---- Footer ---- */
.footer {
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 1rem 2rem;
  text-align: center;
  position: relative;
}

.footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--grad-accent);
  opacity: 0.3;
}

.footer p {
  color: var(--text-3);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.footer i { color: var(--text-3); margin-right: 0.3rem; }

/* ---- Responsive ---- */
@media (max-width: 1400px) {
  .subsystem-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1200px) {
  .main-content {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0;
  }

  .control-section {
    flex: 1;
    min-width: 200px;
    border-bottom: none;
    border-right: 1px solid var(--border);
    padding: 1rem;
  }

  .dashboard-main { height: auto; }

  .charts-section { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .header { padding: 0 1rem; }
  .header-content { flex-direction: column; gap: 0.5rem; height: auto; padding: 0.75rem 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .subsystem-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { flex-direction: column; }
  .control-section { border-right: none; border-bottom: 1px solid var(--border); }
  .stat-value { font-size: 1.3rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .subsystem-grid { grid-template-columns: 1fr; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ---- Selection ---- */
::selection {
  background: var(--accent);
  color: var(--bg);
}

/* ---- Loading shimmer ---- */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.loading {
  background: linear-gradient(90deg, var(--surface-solid) 25%, var(--surface-3) 50%, var(--surface-solid) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* ---- Number transitions ---- */
.stat-value, .sub-value {
  transition: color 600ms ease;
}

/* ---- Gradient text helper ---- */
.gradient-text {
  background: var(--grad-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
