/**
 * Nobitex Algorithmic Trading Terminal - Pro Cyber Obsidian Theme
 */
:root {
  --bg-deep: #06090f;
  --bg-main: #0a0e17;
  --bg-panel: #0f1523;
  --bg-card: rgba(15, 21, 35, 0.75);
  --bg-card-hover: rgba(22, 30, 49, 0.9);
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(59, 130, 246, 0.4);
  --border-active: #00f2fe;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-dim: #64748b;

  /* Trading Terminal Accents */
  --cyan: #00f2fe;
  --cyan-glow: rgba(0, 242, 254, 0.25);
  --emerald: #00f090;
  --emerald-glow: rgba(0, 240, 144, 0.25);
  --crimson: #ff3366;
  --crimson-glow: rgba(255, 51, 102, 0.3);
  --amber: #ffb703;
  --amber-glow: rgba(255, 183, 3, 0.25);
  --purple: #8b5cf6;
  --purple-glow: rgba(139, 92, 246, 0.25);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(at 0% 0%, rgba(0, 242, 254, 0.05) 0px, transparent 40%),
    radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.06) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(0, 240, 144, 0.04) 0px, transparent 60%);
  color: var(--text-primary);
  min-height: 100vh;
  padding: 12px;
  line-height: 1.5;
  font-size: 14px;
}

/* Glassmorphism Panel */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  transition: all 0.25s ease;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* Live Market Ticker Strip */
.market-ticker-strip {
  display: flex;
  overflow-x: auto;
  gap: 16px;
  padding: 8px 14px;
  margin-bottom: 12px;
  background: rgba(15, 21, 35, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  white-space: nowrap;
  scrollbar-width: none;
}
.market-ticker-strip::-webkit-scrollbar { display: none; }

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background 0.2s;
}
.ticker-item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.ticker-sym { color: var(--cyan); }
.ticker-price { font-family: monospace; }
.ticker-up { color: var(--emerald); }
.ticker-down { color: var(--crimson); }

/* Header & Top Bar */
.header-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  padding: 12px 18px;
  border: 1px solid rgba(0, 242, 254, 0.15);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  color: #06090f;
  box-shadow: 0 0 15px var(--cyan-glow);
}

.brand-title h1 {
  font-size: 1.15rem;
  font-weight: 800;
  background: linear-gradient(90deg, #fff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-title p {
  font-size: 0.73rem;
  color: var(--text-dim);
}

/* Controls Group */
.controls-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Cyber Terminal Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #1d4ed8);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
  background: linear-gradient(135deg, #047857, #059669);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, var(--crimson));
  color: #fff;
  box-shadow: 0 0 15px var(--crimson-glow);
  border: 1px solid rgba(255, 51, 102, 0.4);
}
.btn-danger:hover {
  background: linear-gradient(135deg, #b91c1c, #e11d48);
  transform: translateY(-1px);
  box-shadow: 0 0 22px rgba(255, 51, 102, 0.5);
}

.btn-warning {
  background: linear-gradient(135deg, #d97706, var(--amber));
  color: #06090f;
  font-weight: 700;
}

.btn-outline {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Interactive Mode Switcher Pill */
.mode-switch-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: 20px;
  background: #090d16;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  gap: 4px;
}
.mode-switch-pill .pill-opt {
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 700;
  transition: all 0.2s;
  color: var(--text-dim);
}
.mode-switch-pill .pill-opt.active-paper {
  background: rgba(0, 240, 144, 0.15);
  color: var(--emerald);
  border: 1px solid rgba(0, 240, 144, 0.35);
  box-shadow: 0 0 10px var(--emerald-glow);
}
.mode-switch-pill .pill-opt.active-live {
  background: rgba(255, 51, 102, 0.2);
  color: var(--crimson);
  border: 1px solid rgba(255, 51, 102, 0.4);
  box-shadow: 0 0 12px var(--crimson-glow);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-paper {
  background: rgba(0, 240, 144, 0.12);
  color: var(--emerald);
  border: 1px solid rgba(0, 240, 144, 0.25);
}
.badge-live {
  background: rgba(255, 51, 102, 0.15);
  color: var(--crimson);
  border: 1px solid rgba(255, 51, 102, 0.3);
}
.badge-cyan {
  background: rgba(0, 242, 254, 0.1);
  color: var(--cyan);
  border: 1px solid rgba(0, 242, 254, 0.25);
}
.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.badge-dot.green { background: var(--emerald); box-shadow: 0 0 6px var(--emerald); }
.badge-dot.red { background: var(--crimson); box-shadow: 0 0 6px var(--crimson); }
.badge-dot.yellow { background: var(--amber); box-shadow: 0 0 6px var(--amber); }

/* Metrics Row (KPI Tiles) */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric-card {
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(15, 21, 35, 0.85);
  border: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
}
.metric-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0; left: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.4;
}

.metric-label {
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-value {
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.metric-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  overflow-x: auto;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  background: rgba(15, 21, 35, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  scrollbar-width: none;
}
.tabs-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  color: #06090f;
  background: linear-gradient(135deg, var(--cyan), #38bdf8);
  font-weight: 700;
  box-shadow: 0 0 14px var(--cyan-glow);
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Chart Controls & Container */
.chart-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.chart-box {
  width: 100%;
  height: 500px;
  position: relative;
  background: #090d16;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
}

.rsi-box {
  width: 100%;
  height: 160px;
  margin-top: 8px;
  background: #090d16;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.82rem;
}

th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

tr:hover td {
  background: rgba(0, 242, 254, 0.02);
}

/* Progress / Confirmation Dots */
.criteria-dots {
  display: inline-flex;
  gap: 3px;
}
.dot-check {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-check.pass {
  background: var(--emerald);
  box-shadow: 0 0 5px var(--emerald);
}
.dot-check.fail {
  background: #334155;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 15, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #0f1523;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  width: 90%;
  max-width: 520px;
  padding: 22px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

/* Forms */
.form-group { margin-bottom: 12px; }
.form-label { display: block; font-size: 0.77rem; color: var(--text-secondary); margin-bottom: 5px; }
.form-input {
  width: 100%;
  background: #090d16;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 7px 11px;
  color: #fff;
  font-size: 0.85rem;
  transition: border-color 0.2s;
}
.form-input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-glow);
}

/* 25-Level Grid Ladder */
.grid-ladder {
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  margin-top: 10px;
  background: #090d16;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  max-height: 420px;
  overflow-y: auto;
}

.grid-level-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  font-size: 0.74rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.015);
  font-family: monospace;
}

.grid-level-row.current {
  background: rgba(0, 242, 254, 0.15);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-weight: 800;
  box-shadow: 0 0 10px var(--cyan-glow);
}

/* Log Terminal */
.log-terminal {
  background: #04070d;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  font-family: monospace;
  font-size: 0.76rem;
  height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-entry { display: flex; gap: 8px; }
.log-time { color: var(--text-dim); }
.log-info { color: #38bdf8; }
.log-trade { color: var(--emerald); font-weight: 700; }
.log-warn { color: var(--amber); }
.log-error { color: var(--crimson); font-weight: 700; }
.log-safety { color: #e879f9; font-weight: 700; }

/* Login Screen */
.login-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 15, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.login-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.login-card {
  width: 90%;
  max-width: 400px;
  padding: 30px 26px;
  background: #0f1523;
  border: 1px solid rgba(0, 242, 254, 0.2);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8),
              0 0 30px var(--cyan-glow);
}

@media (max-width: 768px) {
  body { padding: 8px; }
  .header-container { flex-direction: column; align-items: stretch; }
  .controls-group { justify-content: flex-start; }
  .chart-box { height: 360px; }
  .metrics-row { grid-template-columns: 1fr; }
  .system-status-banner { flex-direction: column; align-items: flex-start; }
  .tabs-nav { gap: 2px; }
  .tab-btn { padding: 6px 10px; font-size: 0.78rem; }
}

/* ==========================================
   Light Theme System (Professional Daylight Palette)
   ========================================== */
body.light-theme {
  --bg-deep: #f1f5f9;
  --bg-main: #f8fafc;
  --bg-panel: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: #f1f5f9;
  --border-subtle: #cbd5e1;
  --border-hover: #3b82f6;
  --border-active: #0284c7;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-dim: #64748b;

  --cyan: #0284c7;
  --cyan-glow: rgba(2, 132, 199, 0.15);
  --emerald: #059669;
  --emerald-glow: rgba(5, 150, 105, 0.15);
  --crimson: #dc2626;
  --crimson-glow: rgba(220, 38, 38, 0.15);
  --amber: #d97706;
  --amber-glow: rgba(217, 119, 6, 0.15);
  --purple: #7c3aed;
  --purple-glow: rgba(124, 58, 237, 0.15);

  background-color: var(--bg-deep);
  background-image:
    radial-gradient(at 0% 0%, rgba(2, 132, 199, 0.05) 0px, transparent 40%),
    radial-gradient(at 100% 0%, rgba(124, 58, 237, 0.05) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(5, 150, 105, 0.04) 0px, transparent 60%);
  color: var(--text-primary);
}

body.light-theme .glass-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

body.light-theme .market-ticker-strip {
  background: #ffffff;
  border-color: #e2e8f0;
}

body.light-theme .header-container {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

body.light-theme .brand-title h1 {
  background: linear-gradient(90deg, #0f172a, #334155);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

body.light-theme .tabs-nav {
  background: #ffffff;
  border-color: #e2e8f0;
}

body.light-theme .tab-btn {
  color: #475569;
}

body.light-theme .tab-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

body.light-theme .tab-btn.active {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

body.light-theme .metric-card {
  background: #ffffff;
  border-color: #e2e8f0;
}

body.light-theme .chart-box,
body.light-theme .rsi-box,
body.light-theme .log-terminal,
body.light-theme .grid-ladder,
body.light-theme #equityCurveChartBox {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.light-theme .form-input {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

body.light-theme .modal-content {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

body.light-theme th {
  background: #f8fafc;
  color: #475569;
  border-bottom-color: #e2e8f0;
}

body.light-theme td {
  border-bottom-color: #f1f5f9;
}

body.light-theme tr:hover td {
  background: #f8fafc;
}

body.light-theme .mode-switch-pill {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

body.light-theme .btn-outline {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

body.light-theme .btn-outline:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

body.light-theme .login-card {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

body.light-theme .system-status-banner {
  background: #ffffff;
  border-color: #e2e8f0;
}

/* ==========================================
   Comprehensive System Status Banner
   ========================================== */
.system-status-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  margin-bottom: 14px;
  background: rgba(15, 21, 35, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  font-size: 0.8rem;
}

.system-status-banner .banner-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.system-status-banner .banner-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.system-status-banner .banner-label {
  color: var(--text-dim);
  font-size: 0.74rem;
}

.system-status-banner .banner-val {
  font-weight: 700;
}

/* Warning & Recovery Alert Box */
.status-alert-box {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 8px;
  padding: 8px 14px;
  color: #fca5a5;
  font-size: 0.78rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* CVE State Badges */
.badge-cve {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: monospace;
}

.badge-cve-protected {
  background: rgba(0, 240, 144, 0.15);
  color: var(--emerald);
  border: 1px solid rgba(0, 240, 144, 0.35);
}

.badge-cve-recovery {
  background: rgba(255, 51, 102, 0.2);
  color: var(--crimson);
  border: 1px solid rgba(255, 51, 102, 0.45);
  animation: pulse-danger 2s infinite;
}

.badge-cve-transition {
  background: rgba(0, 242, 254, 0.15);
  color: var(--cyan);
  border: 1px solid rgba(0, 242, 254, 0.35);
}

@keyframes pulse-danger {
  0% { box-shadow: 0 0 0 0 rgba(255, 51, 102, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(255, 51, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 51, 102, 0); }
}

/* Per-symbol Pause Control */
.badge-symbol-paused {
  background: rgba(255, 183, 3, 0.15);
  color: var(--amber);
  border: 1px solid rgba(255, 183, 3, 0.35);
}

/* Notifications Status Card */
.notif-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: 10px;
  background: rgba(15, 21, 35, 0.7);
  border: 1px solid var(--border-subtle);
  margin-top: 14px;
}

.notif-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
}

.badge-not-configured {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
}
