/* ═══════════════════════════════════════════════════════════
   iReliance LTD — Dashboard / User Pages — Deep Navy-Purple Theme
   ═══════════════════════════════════════════════════════════ */
:root {
  --primary:    #6c63ff;
  --primary-d:  #4f46e5;
  --primary-l:  #8b85ff;
  --gold:       #f0a500;
  --gold-d:     #c8860a;
  --gold-l:     #ffc947;
  --success:    #2ecc71;
  --danger:     #e74c3c;
  --warning:    #f0a500;
  --info:       #5b9cf6;
  --dark:       #13151a;
  --card-bg:    #1c1f28;
  --card-bg2:   #1e2230;
  --input-bg:   #181b22;
  --border:     #2c3040;
  --text:       #dde1ec;
  --text-muted: #9aa3b8;
  --bottom-nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body.dashboard-body {
  background: var(--dark) !important;
  color: var(--text) !important;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
}

/* ── App Container ─────────────────────────────────────────── */
.app-container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px)  { .app-container { padding: 0 24px; } }
@media (min-width: 1200px) { .app-container { padding: 0 32px; } }

/* ── Page Content ─────────────────────────────────────────── */
.page-content { width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px 16px 100px; }
@media (min-width: 768px)  { .page-content { padding: 20px 24px 100px; } }
@media (min-width: 1200px) { .page-content { padding: 24px 32px 32px; } }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  position: sticky; top: 0; z-index: 1030; width: 100%;
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar .dropdown-menu { z-index: 1055 !important; }

/* ── Bottom Navigation ─────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1040;
  background: rgba(28, 31, 40, 0.97);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; color: var(--text-muted);
  text-decoration: none; font-size: 0.65rem; font-weight: 600;
  letter-spacing: 0.03em; padding: 8px 4px; transition: color .15s; min-height: 44px;
}
.bottom-nav a i { font-size: 1.25rem; line-height: 1; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a.active i { color: var(--primary); }
.bottom-nav a:hover { color: var(--text); }
.bottom-nav a.trade-btn {
  color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-d));
  border-radius: 14px; margin: 6px 4px; padding: 6px 4px;
  box-shadow: 0 4px 12px rgba(108,99,255,.4);
}
.bottom-nav a.trade-btn i { font-size: 1.4rem; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: 220px; min-height: 100vh; background: var(--card-bg);
  border-right: 1px solid var(--border);
  position: fixed; top: 0; left: 0; z-index: 1040;
  display: flex; flex-direction: column;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform .25s ease;
  visibility: hidden;
}
.sidebar.open {
  transform: translateX(0) !important;
  visibility: visible !important;
}
@media (min-width: 1200px) {
  .sidebar {
    transform: translateX(0);
    visibility: visible;
  }
  body.dashboard-body .main-content { margin-left: 220px; }
  .bottom-nav { display: none; }
  body.dashboard-body { padding-bottom: 0; }
}
.sidebar-brand { padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }
.sidebar-brand h5 { color: #eef0f6; font-weight: 700; margin: 0; font-size: .95rem; }
.sidebar-nav { padding: 8px 0; flex: 1; overflow-y: auto; }
.sidebar-nav .nav-link {
  color: var(--text-muted); padding: 10px 20px;
  display: flex; align-items: center; gap: 10px;
  font-size: .875rem; font-weight: 500;
  border-left: 3px solid transparent;
  text-decoration: none; transition: all .15s;
}
.sidebar-nav .nav-link:hover { color: var(--text); background: rgba(108,99,255,.07); }
.sidebar-nav .nav-link.active { color: #fff; background: rgba(108,99,255,.12); border-left-color: var(--primary); }
.sidebar-nav .nav-link i { font-size: 1rem; width: 18px; flex-shrink: 0; }
.main-content { min-height: 100vh; display: flex; flex-direction: column; overflow: visible; }

/* ── Dark theme overrides ─────────────────────────────────── */
body.dashboard-body h1,body.dashboard-body h2,body.dashboard-body h3,
body.dashboard-body h4,body.dashboard-body h5,body.dashboard-body h6,
body.dashboard-body p,body.dashboard-body span,body.dashboard-body label,
body.dashboard-body li,body.dashboard-body td,body.dashboard-body th,
body.dashboard-body div { color: inherit; }

/* Force readable muted text — Bootstrap's #6c757d is invisible on dark bg */
body.dashboard-body .text-muted,
body.dashboard-body .text-secondary,
.dashboard-body .text-muted,
.text-muted { color: #9aa3b8 !important; }

body.dashboard-body .text-white     { color: #eef0f6 !important; }
body.dashboard-body .text-dark      { color: var(--text) !important; }

/* Small text should always be readable */
body.dashboard-body small,
body.dashboard-body .small { color: #9aa3b8; }
body.dashboard-body .fw-semibold,
body.dashboard-body .fw-bold,
body.dashboard-body strong { color: #eef0f6; }

/* Cards */
.card-dark { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; color: var(--text); }
body.dashboard-body .card {
  background: var(--card-bg) !important; border-color: var(--border) !important;
  color: var(--text) !important; border-radius: 14px !important;
}
body.dashboard-body .card-header,
body.dashboard-body .card-footer { background: transparent !important; border-color: var(--border) !important; }

/* Stat cards */
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; padding: 16px; color: var(--text); }
.stat-label { color: var(--text-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: #eef0f6; }
@media (min-width: 768px) { .stat-value { font-size: 1.75rem; } }

/* ── Forms ────────────────────────────────────────────────── */
body.dashboard-body .form-control,
body.dashboard-body .form-select,
body.dashboard-body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
body.dashboard-body textarea,
body.dashboard-body select {
  background: var(--input-bg) !important; border-color: var(--border) !important;
  color: var(--text) !important; min-height: 48px; font-size: 1rem; border-radius: 10px !important;
}
body.dashboard-body .form-control:focus,
body.dashboard-body input:focus,
body.dashboard-body textarea:focus,
body.dashboard-body select:focus {
  background: var(--input-bg) !important; border-color: var(--primary) !important;
  color: var(--text) !important; box-shadow: 0 0 0 3px rgba(108,99,255,.12) !important;
}
body.dashboard-body .form-label { color: var(--text-muted) !important; font-size: .85rem; }
body.dashboard-body .input-group-text {
  background: #1e2230 !important; border-color: var(--border) !important; color: var(--text-muted) !important;
}
/* Placeholder text */
body.dashboard-body ::placeholder { color: #6b7280 !important; opacity: 1 !important; }
body.dashboard-body ::-webkit-input-placeholder { color: #6b7280 !important; }
body.dashboard-body ::-moz-placeholder { color: #6b7280 !important; opacity: 1 !important; }

/* ── Tables ───────────────────────────────────────────────── */
.table-dark-custom { color: var(--text); margin-bottom: 0; }
.table-dark-custom thead th {
  color: var(--text-muted); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; border-color: var(--border); background: rgba(0,0,0,.15);
  padding: 10px 12px; font-weight: 600; white-space: nowrap;
}
.table-dark-custom td { border-color: var(--border); vertical-align: middle; padding: 10px 12px; }
.table-dark-custom tbody tr:hover { background: rgba(255,255,255,.025); }
body.dashboard-body .table { color: var(--text) !important; border-color: var(--border) !important; }
body.dashboard-body .table th,
body.dashboard-body .table td { color: var(--text) !important; border-color: var(--border) !important; background: transparent !important; }
body.dashboard-body .table thead th { color: var(--text-muted) !important; background: rgba(0,0,0,.15) !important; }

/* ── Dropdowns ────────────────────────────────────────────── */
body.dashboard-body .dropdown-menu {
  background: var(--card-bg) !important; border-color: var(--border) !important;
  z-index: 1055 !important; border-radius: 12px !important;
}
body.dashboard-body .dropdown-item { color: var(--text) !important; background: transparent !important; }
body.dashboard-body .dropdown-item:hover { background: rgba(108,99,255,.1) !important; color: #eef0f6 !important; }
body.dashboard-body .dropdown-divider { border-color: var(--border) !important; }
.dropdown-menu { z-index: 1055 !important; }

/* ── Modals ───────────────────────────────────────────────── */
body.dashboard-body .modal-content {
  background: #1c1f28 !important; border-color: var(--border) !important;
  color: var(--text) !important; border-radius: 16px !important;
}
body.dashboard-body .modal-header { background: transparent !important; border-color: var(--border) !important; }
body.dashboard-body .modal-footer { background: transparent !important; border-color: var(--border) !important; }
body.dashboard-body .btn-close { filter: invert(1) grayscale(1) brightness(2) !important; }
.info-box { background: var(--card-bg2); border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.25rem; }

/* ── Alerts ───────────────────────────────────────────────── */
body.dashboard-body .alert-success { background: rgba(46,204,113,.1) !important; border-color: rgba(46,204,113,.25) !important; color: #7ee8a2 !important; }
body.dashboard-body .alert-danger  { background: rgba(231,76,60,.1) !important;  border-color: rgba(231,76,60,.25) !important;  color: #f5a9a0 !important; }
body.dashboard-body .alert-warning { background: rgba(240,165,0,.1) !important;  border-color: rgba(240,165,0,.25) !important;  color: #fcd97a !important; }
body.dashboard-body .alert-info    { background: rgba(91,156,246,.1) !important; border-color: rgba(91,156,246,.25) !important; color: #93c5fd !important; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn { min-height: 44px; border-radius: 10px !important; font-weight: 600; }
.btn-primary { background: var(--primary) !important; border-color: var(--primary) !important; }
.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold-d)); border: none; color: #000; font-weight: 700; }
.btn-gold:hover { opacity: .9; color: #000; }
body.dashboard-body .btn-outline-secondary {
  border-color: var(--border) !important; color: var(--text-muted) !important; background: transparent !important;
}
body.dashboard-body .btn-outline-secondary:hover { background: rgba(255,255,255,.06) !important; color: #eef0f6 !important; }
body.dashboard-body .btn-secondary { background: #2c3040 !important; border-color: #2c3040 !important; color: var(--text) !important; }
.btn-xs { padding: 4px 10px; font-size: .75rem; border-radius: 6px !important; font-weight: 600; min-height: 32px; }

/* ── Badges ───────────────────────────────────────────────── */
.badge-win       { background: #16a34a;  color: #fff; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 700; display: inline-block; }
.badge-loss      { background: #dc2626;  color: #fff; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 700; display: inline-block; }
.badge-pending   { background: #d97706;  color: #fff; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 700; display: inline-block; }
.badge-active    { background: #16a34a;  color: #fff; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 700; display: inline-block; }
.badge-completed { background: #2563eb;  color: #fff; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 700; display: inline-block; }
.badge-frozen    { background: #7c3aed;  color: #fff; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 700; display: inline-block; }
.badge-cancelled { background: #475569;  color: #fff; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 700; display: inline-block; }
.dir-badge { padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 700; display: inline-block; }
.dir-badge.up   { background: #16a34a; color: #fff; }
.dir-badge.down { background: #dc2626; color: #fff; }
.dir-badge.rise { background: #16a34a; color: #fff; }
.dir-badge.fall { background: #dc2626; color: #fff; }

/* ── Timer pill ───────────────────────────────────────────── */
.timer-pill {
  background: var(--input-bg); border: 1px solid var(--primary); color: #eef0f6;
  border-radius: 6px; padding: 2px 8px; font-family: monospace;
  font-size: .9rem; font-weight: 700; display: inline-block; min-width: 52px; text-align: center;
}
.timer-pill.urgent { background: rgba(231,76,60,.2); border-color: var(--danger); color: #f5a9a0; animation: blink .5s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ── Notifications ────────────────────────────────────────── */
.notif-badge { position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff; border-radius: 50%; width: 18px; height: 18px; font-size: .62rem; display: flex; align-items: center; justify-content: center; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s; color: var(--text); }
.notif-item:hover { background: rgba(255,255,255,.05); }
.notif-item.unread { border-left: 3px solid var(--primary); background: rgba(108,99,255,.06); }
.notif-item .small.fw-semibold { color: #f0f0f0 !important; }
.notif-item .small.text-muted { color: #a0aec0 !important; }

/* ── Plan cards ───────────────────────────────────────────── */
.plan-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; padding: 20px; transition: border-color .2s, transform .2s; }
.plan-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.plan-card.featured { border-color: var(--gold); }
.plan-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: .75rem; font-weight: 700; margin-bottom: 12px; }
.plan-badge.gold   { background: rgba(240,165,0,.15);   color: var(--gold); }
.plan-badge.purple { background: rgba(108,99,255,.15);  color: var(--primary); }
.plan-badge.green  { background: rgba(46,204,113,.15);  color: var(--success); }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Misc ─────────────────────────────────────────────────── */
body.dashboard-body .bg-white  { background: var(--card-bg) !important; }
body.dashboard-body .bg-light  { background: rgba(255,255,255,.04) !important; }
body.dashboard-body .border    { border-color: var(--border) !important; }
body.dashboard-body hr { border-color: var(--border) !important; opacity: 1; }
body.dashboard-body .list-group-item { background: var(--card-bg) !important; border-color: var(--border) !important; color: var(--text) !important; }
body.dashboard-body .nav-pills .nav-link.active { background: var(--primary) !important; color: #fff !important; }
body.dashboard-body .page-link { background: var(--card-bg) !important; border-color: var(--border) !important; color: var(--text-muted) !important; }
body.dashboard-body .page-item.active .page-link { background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; }
body.dashboard-body .progress { background: rgba(255,255,255,.07) !important; }
.balance-display { font-size: 1.75rem; font-weight: 700; color: #eef0f6; line-height: 1.2; }
@media (min-width: 768px) { .balance-display { font-size: 2rem; } }

/* ── Topbar hamburger ─────────────────────────────────────── */
.topbar-menu-btn {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 5px; width: 44px; height: 44px; border-radius: 10px;
  background: rgba(108,99,255,.1); border: 1px solid rgba(108,99,255,.25);
  cursor: pointer; padding: 0; transition: all .2s; flex-shrink: 0;
}
.topbar-menu-btn .menu-bar { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; }

/* ── Responsive grid helpers ──────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 576px) { .grid-3 { grid-template-columns: 1fr 1fr; gap: 14px; } }
@media (min-width: 768px) { .grid-3 { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 768px) { .grid-4 { grid-template-columns: repeat(4, 1fr); gap: 14px; } }

/* ── Chips ────────────────────────────────────────────────── */
.chip-scroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chip-scroll::-webkit-scrollbar { display: none; }
.chip { background: var(--card-bg); border: 1px solid var(--border); color: var(--text-muted); border-radius: 20px; padding: 6px 14px; font-size: .82rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all .15s; min-height: 36px; display: inline-flex; align-items: center; }
.chip.active, .chip:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.gold-chip.active, .chip.gold-chip:hover { background: var(--gold); border-color: var(--gold); color: #000; }

/* ── Stat icon ────────────────────────────────────────────── */
.stat-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }

/* ── Trade card ───────────────────────────────────────────── */
.trade-card { background: var(--input-bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.direction-badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: .75rem; font-weight: 700; }
.direction-badge.up   { background: #16a34a; color: #fff; }
.direction-badge.down { background: #dc2626; color: #fff; }
.direction-badge.rise { background: #16a34a; color: #fff; }
.direction-badge.fall { background: #dc2626; color: #fff; }
.timer-display { font-family: monospace; font-size: .95rem; font-weight: 700; }

/* ── Quick amount buttons ─────────────────────────────────── */
.quick-amount-btn { background: var(--card-bg); border: 1px solid var(--border); color: var(--text-muted); border-radius: 8px; padding: 6px 12px; font-size: .82rem; font-weight: 600; cursor: pointer; transition: all .15s; }
.quick-amount-btn:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Rise/Fall buttons ────────────────────────────────────── */
.btn-rise { background: linear-gradient(135deg, #1a9e4a, #157a38); border: none; color: #fff; font-weight: 700; }
.btn-rise:hover { background: linear-gradient(135deg, #157a38, #116030); color: #fff; }
.btn-fall { background: linear-gradient(135deg, #c0392b, #962d22); border: none; color: #fff; font-weight: 700; }
.btn-fall:hover { background: linear-gradient(135deg, #962d22, #7a241b); color: #fff; }

/* ── Auth pages ───────────────────────────────────────────── */
.auth-body { background: var(--dark); min-height: 100vh; }

/* ── Mobile-responsive tables — user pages (card layout on mobile) ── */
@media (max-width: 767px) {
  .mob-table-wrap { overflow: visible !important; overflow-x: visible !important; padding: 8px !important; }

  .mob-table-wrap table { display: block !important; width: 100% !important; }
  .mob-table-wrap thead { display: block !important; }
  .mob-table-wrap tbody { display: block !important; width: 100% !important; }
  .mob-table-wrap thead tr { display: none !important; }

  /* Each row = a card */
  .mob-table-wrap tbody tr {
    display: block !important;
    background: var(--card-bg) !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    margin-bottom: 8px !important;
    padding: 10px 12px !important;
  }
  .mob-table-wrap tbody tr:hover { background: var(--card-bg) !important; }

  /* Each cell = label left, value right */
  .mob-table-wrap td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 7px 0 !important;
    border: none !important;
    border-bottom: 1px solid rgba(255,255,255,.05) !important;
    font-size: .85rem !important;
    gap: 8px !important;
    background: transparent !important;
    color: var(--text) !important;
    min-height: 0 !important;
  }
  .mob-table-wrap td:last-child { border-bottom: none !important; }

  /* Label via ::before */
  .mob-table-wrap td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 80px;
  }
  .mob-table-wrap td[data-label=""] { display: none !important; }

  /* Action buttons */
  .mob-table-wrap td.td-actions {
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding-top: 10px !important;
    border-bottom: none !important;
  }
  .mob-table-wrap td.td-actions::before { display: none !important; }
  .mob-table-wrap td.td-actions .btn,
  .mob-table-wrap td.td-actions button {
    flex: 1 1 auto !important;
    min-width: 60px !important;
    text-align: center !important;
    justify-content: center !important;
  }

  /* Colspan empty rows */
  .mob-table-wrap td[colspan] {
    display: block !important;
    text-align: center !important;
    border: none !important;
    padding: 20px 0 !important;
  }
  .mob-table-wrap td[colspan]::before { display: none !important; }
}
