/* ═══════════════════════════════════════════════════════════
   NEXT 1 Platform — Design System
   Aligned with next1-landing.pages.dev aesthetic
   Andy Phan · next1.vn
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@300;400;500;600;700&family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

/* ── Design tokens — matching landing page ────────────────── */
:root {
  /* Backgrounds — landing uses near-black */
  --bg:      #07080f;   /* main bg — almost black like landing */
  --bg2:     #0c0e18;   /* sidebar, cards */
  --bg3:     #111422;   /* inputs, inner cards */
  --bg4:     #171b2e;   /* hover states */
  --bg5:     #1d2238;   /* active/selected */

  /* Gold — landing's primary accent */
  --gold:    #c9a84c;
  --gold2:   #e2b85a;
  --gold3:   #f0cc7a;
  --gold-dim: rgba(201,168,76,.08);
  --gold-dim2:rgba(201,168,76,.15);

  /* Semantic colors */
  --teal:    #1a9e7a;
  --teal2:   #22c99b;
  --red:     #c03030;
  --red2:    #e85555;
  --blue:    #3a8fd4;
  --blue2:   #60b0f0;
  --amber:   #c07820;
  --amber2:  #e09030;

  /* Text hierarchy */
  --text:    #b0c4d8;   /* body text */
  --text2:   #ccdaee;   /* secondary headings */
  --text3:   #e4eef8;   /* primary text */
  --text4:   #f4f8ff;   /* headings */
  --muted:   #566080;
  --muted2:  #8898b8;

  /* Borders — landing is very minimal */
  --border:  rgba(255,255,255,.05);
  --border2: rgba(255,255,255,.08);
  --border3: rgba(201,168,76,.25);
  --border4: rgba(201,168,76,.5);

  /* Radius */
  --r:  4px;
  --r2: 2px;

  /* Layout */
  --sidebar-w: 224px;

  /* Fonts — matching landing */
  --font-body: 'IBM Plex Sans', 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100%;
}

/* ── Layout ──────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border2);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

/* ── Sidebar logo area ───────────────────────────────── */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border3);
}

/* ── Logo image ──────────────────────────────────────── */
.sidebar-logo-img {
  height: 28px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 3px;
}


.logo-text .name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--gold2);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.logo-text .sub {
  font-size: 10px;
  color: var(--muted2);
  letter-spacing: .04em;
  margin-top: 1px;
}

/* ── Nav ─────────────────────────────────────────────────── */
.nav { padding: 10px 8px; flex: 1; }
.nav-section { margin-bottom: 18px; }
.nav-section-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .18em;
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r);
  color: var(--muted2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  transition: all .12s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  position: relative;
}
.nav-item:hover {
  background: var(--bg4);
  color: var(--text3);
}
.nav-item.active {
  background: var(--gold-dim2);
  color: var(--gold2);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
}
.nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

/* Sidebar footer */
.sidebar-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.sync-status {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.sync-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--teal2);
  animation: pulse 2.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.25;} }

/* ── Main ────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 24px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border2);
  flex-shrink: 0;
}
.topbar-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .14em;
}
.topbar-title::before {
  content: '// ';
  color: var(--muted);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 14px 16px;
}

.card-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: .14em;
  margin-bottom: 12px;
}
/* Landing-style section prefix */
.card-title::before {
  content: '◆  ';
  color: var(--gold);
  font-size: 8px;
}

/* ── Stat cards ──────────────────────────────────────────── */
.stat-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  transition: border-color .15s;
}
.stat-card:hover { border-color: var(--border3); }
.stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 6px;
}
.stat-val {
  font-size: 20px;
  font-weight: 600;
  color: var(--text4);
  font-family: var(--font-mono);
  letter-spacing: -.01em;
}
.stat-sub { font-size: 10px; color: var(--muted2); margin-top: 3px; }

/* ── Grids ───────────────────────────────────────────────── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.g4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; }
.g5 { display: grid; grid-template-columns: repeat(5,1fr); gap: 8px; }

/* ── Buttons — matching landing CTAs ────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .04em;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
  text-transform: uppercase;
}
.btn:hover {
  border-color: var(--gold);
  color: var(--gold2);
}
.btn-gold {
  border-color: var(--gold);
  color: var(--gold);
}
.btn-gold:hover { background: var(--gold-dim2); }
.btn-teal { border-color: var(--teal); color: var(--teal2); }
.btn-teal:hover { background: rgba(26,158,122,.08); }
.btn-red { border-color: var(--red); color: var(--red2); }
.btn-sm { padding: 5px 10px; font-size: 10px; }

/* Primary CTA — matching landing "Tham gia ngay" style */
.btn-primary {
  background: var(--gold);
  color: #07080f;
  border-color: var(--gold);
  font-weight: 700;
}
.btn-primary:hover {
  background: var(--gold3);
  border-color: var(--gold3);
  color: #07080f;
}

/* ── Forms ───────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: .1em;
}
.field input,
.field select,
.field textarea {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--r);
  outline: none;
  width: 100%;
  transition: border-color .12s, background .12s;
  -webkit-appearance: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--gold);
  background: var(--bg4);
}
.field input::placeholder,
.field textarea::placeholder { color: var(--muted); }
.field textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
select option { background: var(--bg2); }

/* ── Table ───────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th {
  text-align: left;
  padding: 7px 10px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: .1em;
  border-bottom: 1px solid var(--border2);
  background: var(--bg3);
}
td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--bg4); }
tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.b-buy   { background: rgba(26,158,122,.12); color: var(--teal2); border:1px solid rgba(26,158,122,.2); }
.b-sell  { background: rgba(200,60,60,.12);  color: var(--red2);  border:1px solid rgba(200,60,60,.2); }
.b-win   { background: rgba(26,158,122,.12); color: var(--teal2); border:1px solid rgba(26,158,122,.2); }
.b-loss  { background: rgba(200,60,60,.12);  color: var(--red2);  border:1px solid rgba(200,60,60,.2); }
.b-be    { background: rgba(201,168,76,.1);  color: var(--gold2); border:1px solid rgba(201,168,76,.2); }
.b-open  { background: rgba(80,120,200,.1);  color: var(--blue2); border:1px solid rgba(80,120,200,.2); }

/* ── Progress bar ────────────────────────────────────────── */
.progress { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; transition: width .6s cubic-bezier(.4,0,.2,1); }

/* ── Color utilities ─────────────────────────────────────── */
.green  { color: var(--teal2); }
.red    { color: var(--red2); }
.gold   { color: var(--gold2); }
.amber  { color: var(--amber2); }
.blue   { color: var(--blue2); }
.muted  { color: var(--muted2); }
.mono   { font-family: var(--font-mono); }

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

/* ── Emotion track ───────────────────────────────────────── */
.emotion-track { display: flex; gap: 5px; }
.emo-btn {
  flex: 1;
  padding: 7px 4px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  text-align: center;
  cursor: pointer;
  transition: all .12s;
  border-radius: var(--r);
  font-size: 16px;
}
.emo-btn:hover { border-color: var(--gold); background: var(--bg4); }
.emo-btn.active { border-color: var(--gold); background: var(--gold-dim2); }
.emo-label { font-size: 8px; color: var(--muted2); text-align: center; margin-top: 2px;
             font-family: var(--font-mono); letter-spacing: .04em; }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px; right: 20px;
  padding: 9px 16px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--gold);
  border-radius: var(--r);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text2);
  z-index: 9999;
  transition: all .25s;
  opacity: 0;
  transform: translateY(6px);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-left-color: var(--teal); color: var(--teal2); }
.toast.error   { border-left-color: var(--red);  color: var(--red2); }

/* ── Divider ─────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty { text-align: center; padding: 36px 20px; color: var(--muted2); }
.empty-icon { font-size: 28px; margin-bottom: 8px; }

/* ── Landing-style section separator (// 01 —) ──────────── */
.section-marker {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: .16em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.section-marker::before { content: '// '; color: var(--gold); }

/* ── Modal overlays ──────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.8);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-top: 2px solid var(--gold);
  border-radius: var(--r);
  width: 100%; max-width: 700px; max-height: 92vh;
  overflow-y: auto; padding: 20px;
}

/* ── Section label in modal (① ② ③) ─────────────────────── */
.section-label {
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 600;
  color: var(--gold);
  text-transform: uppercase; letter-spacing: .12em;
  margin: 14px 0 8px;
  display: flex; align-items: center; gap: 8px;
}
.section-label::after {
  content: '';
  flex: 1; height: 1px;
  background: rgba(201,168,76,.12);
}

/* ── FTMO objectives ─────────────────────────────────────── */
.ftmo-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.ftmo-row:last-child { border-bottom: none; }
.ftmo-key { font-size: 11px; color: var(--muted2); }
.ftmo-val { font-family: var(--font-mono); font-size: 11px; font-weight: 600; }

/* ── Equity canvas ───────────────────────────────────────── */
.equity-wrap { position: relative; width: 100%; }
.equity-canvas { width: 100% !important; display: block; }

/* ════════════════════════════════════════════════════════════
   MOBILE — Responsive (max 768px)
   ════════════════════════════════════════════════════════════ */

/* ── Hamburger button (injected by mobile.js) ─────────────── */
.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border2);
  color: var(--text2);
  font-size: 17px;
  width: 34px; height: 34px;
  border-radius: var(--r);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color .12s;
}
.mobile-menu-btn:hover { border-color: var(--gold); color: var(--gold2); }

/* ── Sidebar backdrop (injected by mobile.js) ─────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 299;
  backdrop-filter: blur(1px);
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 768px) {

  /* ── Hamburger visible on mobile ─── */
  .mobile-menu-btn { display: inline-flex; }

  /* ── Sidebar: slide-over panel ──── */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 300;
    width: 240px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }
  .sidebar.open { transform: translateX(0); }

  /* ── Main fills full width ───────── */
  .main { width: 100%; }

  /* ── Topbar: smaller padding ─────── */
  .topbar {
    padding: 10px 14px;
    gap: 8px;
  }
  .topbar-title { font-size: 10px; }

  /* ── Page content: tighter padding, no overflow ─ */
  .page-content {
    padding: 12px 14px;
    overflow-x: hidden;
    max-width: 100%;
  }

  /* ── Grids collapse to 1 column ──── */
  .g2, .g3, .g4 {
    grid-template-columns: 1fr;
  }

  /* ── Stat grids: 2×N on mobile ───── */
  .g5, .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  /* ── Stat cards: slightly smaller ── */
  .stat-val { font-size: 16px; }
  .stat-card { padding: 10px 12px; }

  /* ── Cards: full width ───────────── */
  .card { padding: 12px 14px; }

  /* ── Tables: responsive, no horizontal scroll ── */
  .table-wrap, [style*="overflow-x:auto"], [style*="overflow-x: auto"] {
    overflow-x: hidden;
    width: 100%;
  }
  table {
    width: 100%;
    min-width: unset;
    table-layout: fixed;
    word-break: break-word;
  }
  table thead th,
  table tbody td {
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
    padding: 6px 5px;
  }
  /* Hide less-important columns on mobile */
  .col-hide-mobile { display: none !important; }

  /* ── Buttons: don't overflow ─────── */
  .btn { font-size: 10px; padding: 6px 10px; }
  .btn-sm { font-size: 9px; padding: 4px 8px; }

  /* ── Topbar right: wrap on small ─── */
  .topbar-right { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

  /* ── Tab bars: scrollable ────────── */
  .tab-bar, .cat-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }

  /* ── Modals: full screen on mobile ─ */
  .modal, .modal-box, .read-box, .edit-box {
    max-width: 100%;
    max-height: 96vh;
    margin: 0;
    border-radius: var(--r) var(--r) 0 0;
  }
  .modal-overlay, .modal-bg, .read-modal, .edit-modal {
    padding: 0;
    align-items: flex-end;
  }

  /* ── Dashboard specific ──────────── */
  .equity-wrap { min-height: 160px; }

  /* ── Admin member stats grid ─────── */
  .mstats { grid-template-columns: repeat(3, 1fr); }
  .mrow { flex-wrap: wrap; }
  .mactions { width: 100%; justify-content: flex-end; margin-top: 6px; }

  /* ── Analytics: metric cards ─────── */
  #metrics-row {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px;
  }

  /* ── Journal trade rows: hide less-critical columns ── */
  .trade-row td { font-size: 11px; padding: 5px 4px; }
  /* Hide: Entry(5), Session(7), Setup(9), Emo(10) */
  .trade-row td:nth-child(5),
  .trade-row td:nth-child(7),
  .trade-row td:nth-child(9),
  .trade-row td:nth-child(10),
  table thead tr th:nth-child(5),
  table thead tr th:nth-child(7),
  table thead tr th:nth-child(9),
  table thead tr th:nth-child(10) {
    display: none;
  }

  /* ── Settings: max-width reset ───── */
  .card[style*="max-width"] { max-width: 100% !important; }

  /* ── Library grid: 1 col ─────────── */
  .lesson-grid { grid-template-columns: 1fr; }

  /* ── Hide lang toggle in sidebar on mobile (clone in topbar) */
  .sidebar #lang-toggle { display: none; }

  /* ── Summary grid in admin ───────── */
  .sum { grid-template-columns: repeat(2, 1fr); }

  /* ── Toast: full width at bottom ─── */
  .toast {
    left: 14px; right: 14px;
    bottom: 14px;
    text-align: center;
  }
}

/* ── Tablet (769–1024px): mild adjustments ────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  .page-content { padding: 14px 18px; }
  .g5, .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .g3, .g4 { grid-template-columns: repeat(2, 1fr); }
  #metrics-row { grid-template-columns: repeat(3, 1fr) !important; }
}
