/* ==========================================================================
   NasdaqBot v4 — GitHub Dark Theme
   Applies to: dashboard, rapport, gann2, login, monitoring
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Theme Variables
   -------------------------------------------------------------------------- */
:root, [data-theme="dark"] {
  --bg: #0f1117;
  --card: #161b22;
  --border: #30363d;
  --text: #e1e4e8;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --accent: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --orange: #d29922;
  --purple: #bc8cff;
  --header-bg: #161b22;
  --hover-bg: #1c2128;
}

[data-theme="light"] {
  --bg: #f8f9fc;
  --card: #ffffff;
  --border: #d1d5db;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --accent: #3b82f6;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #ea580c;
  --purple: #7c3aed;
  --header-bg: #ffffff;
  --hover-bg: #f3f4f6;
}

/* --------------------------------------------------------------------------
   2. Reset + Base
   -------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------------
   3. Typography
   -------------------------------------------------------------------------- */
.mono {
  font-family: 'JetBrains Mono', monospace;
}

.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-orange { color: var(--orange); }
.text-accent { color: var(--accent); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   4. Header / Navigation
   -------------------------------------------------------------------------- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.header-logo {
  font-weight: 700;
  color: var(--accent);
  font-size: 16px;
  text-decoration: none;
}

.header-nav {
  display: flex;
  gap: 4px;
  margin-left: 32px;
}

.header-nav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.header-nav a:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.header-nav a.active {
  background: var(--hover-bg);
  color: var(--text);
}

.header-nav.open {
  display: flex;
}

.header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  flex-direction: column;
  gap: 4px;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

.hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

/* --------------------------------------------------------------------------
   5. Layout
   -------------------------------------------------------------------------- */
main {
  padding: 24px;
  margin-top: 56px;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.grid-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* --------------------------------------------------------------------------
   6. Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}

.card-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.card-value {
  font-size: 24px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.kpi-card {
  text-align: center;
  padding: 20px;
}

/* --------------------------------------------------------------------------
   7. Tables
   -------------------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: var(--hover-bg);
}

tbody td {
  padding: 8px 12px;
}

tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.02);
}

/* --------------------------------------------------------------------------
   8. Badges
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-a {
  background: rgba(88,166,255,0.15);
  color: var(--accent);
}

.badge-c {
  background: rgba(188,140,255,0.15);
  color: var(--purple);
}


.badge-buy {
  background: rgba(63,185,80,0.15);
  color: var(--green);
}

.badge-sell {
  background: rgba(248,81,73,0.15);
  color: var(--red);
}

.badge-skip {
  background: rgba(210,153,34,0.15);
  color: var(--orange);
}

.badge-wait {
  background: rgba(139,148,158,0.15);
  color: var(--text-secondary);
}

.badge-blocked {
  background: rgba(248,81,73,0.3);
  color: var(--red);
}

.badge-open {
  background: rgba(88,166,255,0.15);
  color: var(--accent);
}

.badge-closed-tp {
  background: rgba(63,185,80,0.15);
  color: var(--green);
}

.badge-closed-sl {
  background: rgba(248,81,73,0.15);
  color: var(--red);
}

.badge-closed-manual {
  background: rgba(139,148,158,0.15);
  color: var(--text-secondary);
}

.badge-sl {
  background: rgba(248,81,73,0.15);
  color: var(--red);
}

.badge-tp {
  background: rgba(63,185,80,0.15);
  color: var(--green);
}

.badge-deepseek {
  background: rgba(88,166,255,0.15);
  color: var(--accent);
}

.badge-ah {
  background: rgba(210,153,34,0.15);
  color: var(--orange);
}

.badge-killswitch {
  background: rgba(248,81,73,0.25);
  color: #b02a22;
  font-weight: 700;
}

.badge-manual {
  background: rgba(139,148,158,0.15);
  color: var(--text-secondary);
}

.badge-unknown {
  background: rgba(139,148,158,0.10);
  color: var(--text-secondary);
  font-style: italic;
}

/* --------------------------------------------------------------------------
   9. Buttons
   -------------------------------------------------------------------------- */
.btn {
  padding: 6px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover {
  background: var(--hover-bg);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn-danger:hover {
  opacity: 0.9;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-group {
  display: flex;
  gap: 4px;
}

/* --------------------------------------------------------------------------
   10. Filter / Period Groups
   -------------------------------------------------------------------------- */
.filter-group,
.period-group {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: 6px;
  padding: 2px;
  border: 1px solid var(--border);
}

.filter-group button,
.period-group button {
  padding: 4px 12px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.filter-group button.active,
.period-group button.active {
  background: var(--accent);
  color: #fff;
}

/* --------------------------------------------------------------------------
   11. Expandable Rows
   -------------------------------------------------------------------------- */
.expand-row {
  display: none;
  background: var(--hover-bg);
  border-bottom: 1px solid var(--border);
}

.expand-row.open {
  display: table-row;
}

.expand-row td {
  padding: 12px 16px;
}

.expand-content {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 13px;
}

.expand-content .label {
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
}

.expand-content .value {
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}

.expand-content .reason {
  flex: 1 1 100%;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   12. Status Dots
   -------------------------------------------------------------------------- */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.green {
  background: var(--green);
}

.status-dot.orange {
  background: var(--orange);
}

.status-dot.red {
  background: var(--red);
}

.status-dot.gray {
  background: var(--text-muted);
}

/* --------------------------------------------------------------------------
   13. Monitoring Components
   -------------------------------------------------------------------------- */
.countdown {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
  font-weight: 700;
}

.scheduler-job {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.kill-btn {
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 700;
  background: #da3633;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.kill-btn:hover {
  background: #f85149;
}

/* --------------------------------------------------------------------------
   14. Gann Phase Cards
   -------------------------------------------------------------------------- */
.phase-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}

/* --------------------------------------------------------------------------
   15. Progress Bar
   -------------------------------------------------------------------------- */
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
}

/* --------------------------------------------------------------------------
   16. Toast Notifications
   -------------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 200;
  animation: fadeIn 0.3s;
}

.toast.success {
  background: var(--green);
  color: #fff;
}

.toast.error {
  background: var(--red);
  color: #fff;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --------------------------------------------------------------------------
   17. Modal
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  max-width: 600px;
  width: 90%;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
}

/* --------------------------------------------------------------------------
   18. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .header-nav { display: none; }
  .hamburger { display: flex; }
  main { padding: 16px; }

  /* Wide tables: allow horizontal scroll inside the card instead of overflowing */
  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card table { min-width: 720px; }
  thead th, tbody td { padding: 6px 8px; font-size: 12px; }

  /* Header: compact layout + nav dropdown au lieu d'overflow */
  .header { padding: 0 8px; gap: 4px; }
  .header-logo { font-size: 13px; }
  .header-actions { gap: 3px; flex-wrap: nowrap; }
  .header-actions .filter-group { gap: 2px; }
  .header-actions .btn { padding: 3px 6px; font-size: 11px; }

  .header-nav.open {
    display: flex;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    margin: 0;
    padding: 8px;
    gap: 2px;
    z-index: 99;
  }
  .header-nav.open a { padding: 12px 16px; border-radius: 4px; }
}
