/* ============================================================
   ForexAI - Main Dark Theme Stylesheet
   ============================================================ */

:root {
  --bg: #0f0f23;
  --bg-2: #14142b;
  --panel: #1a1a2e;
  --panel-2: #16213e;
  --border: #26264a;
  --border-2: #2a2a4a;
  --text: #e8e8f0;
  --text-dim: #9aa0b5;
  --green: #00ff88;
  --green-dim: rgba(0, 255, 136, .12);
  --red: #ff4444;
  --red-dim: rgba(255, 68, 68, .12);
  --blue: #3b82f6;
  --purple: #a855f7;
  --orange: #f59e0b;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.font-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

.text-profit { color: var(--green) !important; }
.text-loss { color: var(--red) !important; }

/* ---------- App layout ---------- */
.app-body { min-height: 100vh; }
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--panel) 0%, #141428 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 1040;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 22px 18px;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: .3px;
}
.brand-link { color: var(--text); text-decoration: none; }
.brand-link:hover { color: var(--green); }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
  display: inline-block;
}
.admin-tag {
  font-size: 9px; font-weight: 700; letter-spacing: 1px;
  background: var(--purple); color: #fff;
  padding: 2px 7px; border-radius: 4px; margin-left: 4px;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

.nav-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin: 16px 10px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 14px;
  transition: all .18s ease;
  position: relative;
}
.nav-link i { width: 18px; text-align: center; font-size: 15px; }
.nav-link:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.nav-link.active {
  color: var(--green);
  background: var(--green-dim);
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: -12px; top: 20%; height: 60%; width: 3px;
  background: var(--green);
  border-radius: 3px;
}
.pill-count {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 0 6px;
}

.sidebar-footer { padding: 16px 18px; border-top: 1px solid var(--border); }

.market-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-2);
}
.market-chip.is-open { color: var(--green); border-color: rgba(0,255,136,.35); }
.market-chip.is-closed { color: var(--red); border-color: rgba(255,68,68,.35); }
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0,255,136,.5); }
  70% { box-shadow: 0 0 0 7px rgba(0,255,136,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,255,136,0); }
}
.market-chip.is-closed .pulse-dot { animation: none; }

/* ---------- Main area ---------- */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 26px;
  background: rgba(15, 15, 35, .8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1030;
}
.topbar-title h1 { font-size: 20px; font-weight: 700; margin: 0; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.icon-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  width: 42px; height: 42px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .15s ease;
}
.icon-btn:hover { background: var(--panel-2); color: var(--green); }

.auto-trade-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 13px;
}
.auto-trade-pill .fa-robot { color: var(--purple); }
.pill-text { color: var(--text-dim); }

.status-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .8px;
  padding: 3px 10px;
  border-radius: 20px;
}
.status-badge.on { background: var(--green-dim); color: var(--green); }
.status-badge.off { background: var(--red-dim); color: var(--red); }

.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 12px;
}
.user-btn:hover { border-color: var(--green); color: var(--text); }
.avatar {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green), #00c26f);
  color: #06140d;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.user-meta small { color: var(--text-dim); font-size: 11px; }

/* Dropdowns / notification menu */
.notif-menu { width: 360px; max-width: 90vw; }
.notif-menu .dropdown-item.unread { background: rgba(59,130,246,.06); }
.notif-menu .dropdown-item { display: flex; gap: 10px; white-space: normal; padding: 10px 14px; }
.notif-menu .notif-dot { font-size: 8px; margin-top: 6px; }
.notif-msg { font-size: 13px; color: var(--text); }
.notif-time { font-size: 11px; color: var(--text-dim); }
.notif-empty { padding: 28px; text-align: center; color: var(--text-dim); }
.notif-dot.t-success, .notif-type-icon.t-success { color: var(--green); }
.notif-dot.t-loss, .notif-type-icon.t-loss { color: var(--red); }
.notif-dot.t-trade, .notif-type-icon.t-trade { color: var(--blue); }
.notif-dot.t-info, .notif-type-icon.t-info { color: var(--purple); }
.notif-menu-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 13px;
}
.notif-menu-head a { color: var(--green); font-size: 12px; text-decoration: none; }

.content-area { padding: 24px 26px; flex: 1; }

/* ---------- Panels & cards ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-head h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel-head h3 i { color: var(--green); font-size: 15px; }

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-2); }
.stat-card small { color: var(--text-dim); font-size: 12px; }
.stat-card strong { font-size: 19px; font-weight: 700; display: block; margin-top: 2px; }
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.bg-blue { background: rgba(59,130,246,.15); color: var(--blue); }
.bg-green { background: var(--green-dim); color: var(--green); }
.bg-red { background: var(--red-dim); color: var(--red); }
.bg-purple { background: rgba(168,85,247,.15); color: var(--purple); }
.bg-orange { background: rgba(245,158,11,.15); color: var(--orange); }
.stat-sub { display: block; font-size: 11px; }
.stat-card-simple { display: block; }
.stat-card-simple strong { font-size: 22px; }

.mini-stat {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.mini-stat small { display: block; color: var(--text-dim); font-size: 11px; margin-bottom: 4px; }
.mini-stat strong { font-size: 16px; }

/* ---------- Toggle switch ---------- */
.toggle-xl .form-check-input {
  width: 74px;
  height: 38px;
  cursor: pointer;
  background-color: var(--red);
  border-color: var(--red);
  transition: background-color .25s ease, border-color .25s ease;
}
.toggle-xl .form-check-input:checked { background-color: var(--green); border-color: var(--green); }
.toggle-xl .form-check-input:focus { box-shadow: 0 0 0 .25rem rgba(0,255,136,.25); }
.toggle-desc { color: var(--text-dim); font-size: 13px; max-width: 320px; margin-inline: auto; }

/* ---------- Tables ---------- */
.table-dark {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: rgba(255,255,255,.03);
  color: var(--text);
}
.table-dark thead th {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  border-bottom: 1px solid var(--border-2);
  white-space: nowrap;
}
.table-dark td { border-color: var(--border); }

/* ---------- Buttons / forms ---------- */
.btn-primary {
  background: var(--green);
  border: none;
  color: #06140d;
  font-weight: 700;
}
.btn-primary:hover, .btn-primary:focus { background: #00d977; color: #06140d; }
.btn-primary:disabled { background: rgba(0,255,136,.4); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text);
  font-weight: 600;
}
.btn-ghost:hover { border-color: var(--green); color: var(--green); }

.form-control, .form-select {
  background-color: var(--bg-2);
  border: 1px solid var(--border-2);
  color: var(--text);
}
.form-control:focus, .form-select:focus {
  background-color: var(--bg-2);
  color: var(--text);
  border-color: var(--green);
  box-shadow: 0 0 0 .2rem rgba(0,255,136,.12);
}
.form-control::placeholder { color: #5c6180; }
.form-select option { background: var(--panel); }
.form-label { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.form-check-input {
  background-color: var(--bg-2);
  border-color: var(--border-2);
}
.form-check-input:checked { background-color: var(--green); border-color: var(--green); }
.input-group-text {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  color: var(--text-dim);
}
.form-text { color: var(--text-dim); }

.link-accent { color: var(--green); text-decoration: none; }
.link-accent:hover { text-decoration: underline; }

/* ---------- Alerts ---------- */
.alert {
  border-radius: 12px;
  border: 1px solid transparent;
}
.alert-success { background: var(--green-dim); color: var(--green); border-color: rgba(0,255,136,.2); }
.alert-danger { background: var(--red-dim); color: var(--red); border-color: rgba(255,68,68,.2); }
.alert-warning { background: rgba(245,158,11,.12); color: var(--orange); border-color: rgba(245,158,11,.25); }
.alert-info { background: rgba(59,130,246,.12); color: #7fb2ff; border-color: rgba(59,130,246,.25); }

/* ---------- Activity list ---------- */
.activity-list { list-style: none; padding: 0; margin: 0; max-height: 380px; overflow-y: auto; }
.activity-list li {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.activity-list li:last-child { border-bottom: none; }
.activity-list strong { font-size: 13px; }
.activity-list p { font-size: 12px; color: var(--text-dim); }
.activity-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green);
  margin-top: 6px;
  flex-shrink: 0;
}

/* ---------- Info box ---------- */
.info-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.info-box h4 { font-size: 13px; font-weight: 700; margin: 0 0 10px; }
.info-box h4 i { color: var(--green); }
.info-list { list-style: none; padding: 0; margin: 0; }
.info-list li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.55;
}
.info-list li::before {
  content: '•';
  color: var(--green);
  position: absolute;
  left: 4px;
  font-weight: 700;
}

/* ---------- Wallet ---------- */
.wallet-panel .wallet-head { display: flex; gap: 14px; align-items: center; }
.wallet-panel h3 { font-size: 17px; font-weight: 700; margin: 0; }
.wallet-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.wallet-balance { font-size: 30px; font-weight: 800; margin: 18px 0; font-family: 'JetBrains Mono', monospace; }
.wallet-panel.funding { border-left: 3px solid var(--blue); }
.wallet-panel.trading { border-left: 3px solid var(--purple); }

/* ---------- Chart ---------- */
.chart-panel { padding: 14px; }
.chart-toolbar { margin-bottom: 10px; }
.chart-wrap {
  position: relative;
  height: 460px;
  width: 100%;
}
.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-dim);
  background: rgba(15,15,35,.6);
  z-index: 5;
  border-radius: 10px;
}
.chart-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-dim);
  font-size: 12px;
  padding: 10px 4px 0;
  flex-wrap: wrap;
}
.live-price { font-size: 18px; font-weight: 700; color: var(--green); }
.sr-line-toggle {
  cursor: pointer;
  color: var(--text-dim);
  padding: 8px;
  border-radius: 8px;
}
.sr-line-toggle.active { color: var(--orange); background: rgba(245,158,11,.15); }

.pagination-wrap { padding: 14px 0 2px; }
.page-link {
  background: var(--bg-2);
  border-color: var(--border-2);
  color: var(--text);
}
.page-item.active .page-link { background: var(--green); border-color: var(--green); color: #06140d; }

/* ---------- Notifications page ---------- */
.notification-list { max-height: 600px; overflow-y: auto; }
.notif-item {
  display: flex;
  align-items: flex-start;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  border-radius: 10px;
}
.notif-item.unread { background: rgba(59,130,246,.05); }
.notif-item:last-child { border-bottom: none; }
.notif-type-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-2); flex-shrink: 0;
}
.notif-item p { margin: 0; font-size: 14px; }

/* ---------- Support thread ---------- */
.ticket-thread { display: flex; flex-direction: column; gap: 12px; max-height: 480px; overflow-y: auto; }
.ticket-msg {
  border-radius: 12px;
  padding: 14px 16px;
  max-width: 85%;
}
.ticket-msg.user { background: var(--bg-2); border: 1px solid var(--border); }
.ticket-msg.admin { background: var(--green-dim); border: 1px solid rgba(0,255,136,.2); margin-left: auto; }
.ticket-msg-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; font-size: 13px;
}
.ticket-msg.admin .ticket-msg-head strong { color: var(--green); }

/* ---------- Cron box ---------- */
.cron-box {
  background: #0b0b1d;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 12px;
  line-height: 2;
  overflow-x: auto;
  white-space: nowrap;
}
.cron-schedule { color: var(--green); }

.log-pre {
  background: #0b0b1d;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 12px;
  max-height: 320px;
  overflow-y: auto;
  color: #f87171;
  white-space: pre-wrap;
}

/* ---------- Responsive ---------- */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1035;
}

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .content-area { padding: 16px; }
  .topbar { padding: 12px 16px; }
}

@media (max-width: 575.98px) {
  .chart-wrap { height: 340px; }
  .wallet-balance { font-size: 24px; }
  .auto-trade-pill .pill-text { display: none; }
}
