/* ============================================================
   Bloomberg Dark Theme — Custom Overrides
   Applied on top of Tailwind CSS.
   Bootstrap JS is kept for modal functionality; its CSS classes
   are overridden here to match the dark theme.
   ============================================================ */

/* ---- Base font ---- */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---- Monospace data cells ---- */
.font-data, td.num {
  font-family: 'JetBrains Mono', 'Consolas', 'Fira Code', monospace;
  font-size: 0.875rem;
}

/* ============================================================
   Bootstrap Modal — Layout + Dark Theme
   (Bootstrap CSS not loaded; all layout must be defined here)
   ============================================================ */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1055;
  overflow-x: hidden;
  overflow-y: auto;
  outline: 0;
}
.modal.show { display: block; }

.modal-dialog {
  position: relative;
  width: auto;
  margin: 1.75rem auto;
  max-width: 500px;
  pointer-events: none;
}

.modal-dialog-centered {
  display: flex;
  align-items: center;
  min-height: calc(100% - 3.5rem);
}

.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  pointer-events: auto;
  background-color: #1a2235 !important;
  border: 1px solid #2d3a4f !important;
  border-radius: 0.75rem !important;
  overflow: hidden;
  color: #f9fafb !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6) !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  background-color: #000;
}
.modal-backdrop.fade { opacity: 0; }
.modal-backdrop.show { opacity: 0.7; transition: opacity 0.15s linear; }

.modal.fade .modal-dialog {
  transition: transform 0.2s ease-out;
  transform: translateY(-16px);
}
.modal.show .modal-dialog { transform: none; }

.modal-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 1rem 1.25rem !important;
  background-color: #111827 !important;
  border-bottom: 1px solid #2d3a4f !important;
}

.modal-title {
  font-size: 0.9375rem !important;
  font-weight: 600 !important;
  color: #f9fafb !important;
  line-height: 1.4;
}

.modal-body {
  padding: 1.5rem !important;
  flex: 1 1 auto;
  background-color: #1a2235 !important;
}

.modal-footer {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 0.5rem !important;
  padding: 0.875rem 1.25rem !important;
  background-color: #111827 !important;
  border-top: 1px solid #2d3a4f !important;
}

/* Close button — icon-based (no Bootstrap CSS background image) */
.btn-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 0.375rem;
  background: transparent;
  cursor: pointer;
  color: #6b7280;
  font-size: 0.875rem;
  line-height: 1;
  transition: color 0.15s, background-color 0.15s;
  filter: none !important;
}
.btn-close:hover {
  color: #d1d5db;
  background-color: rgba(255, 255, 255, 0.08);
}

/* ============================================================
   Bootstrap Form Controls — Dark Overrides
   ============================================================ */

.form-control,
.form-select,
textarea.form-control {
  display: block;
  width: 100%;
  padding: 0.5625rem 0.75rem !important;
  background-color: #0f1623 !important;
  border: 1px solid #2d3a4f !important;
  border-radius: 0.4rem !important;
  color: #f9fafb !important;
  font-size: 0.875rem !important;
  line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

.form-control:focus,
.form-select:focus {
  background-color: #0f1623 !important;
  border-color: #3b82f6 !important;
  color: #f9fafb !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
  outline: none;
}

.form-control::placeholder {
  color: #4b5563 !important;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%236b7280' d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.75rem center !important;
  padding-right: 2.25rem !important;
}

.form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.6875rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7280 !important;
}

/* ============================================================
   Tables — Dark Theme
   ============================================================ */

.bb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.bb-table thead tr {
  background-color: #1f2937;
  border-bottom: 1px solid #374151;
}

.bb-table thead th {
  padding: 0.625rem 0.875rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  white-space: nowrap;
}

.bb-table tbody tr {
  border-bottom: 1px solid #1f2937;
  transition: background-color 0.1s;
}

.bb-table tbody tr:hover {
  background-color: #1f2937;
}

.bb-table tbody td {
  padding: 0.625rem 0.875rem;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  color: #e5e7eb;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.8125rem;
}

.bb-table tbody td.text-left {
  text-align: left;
}

.bb-table tbody tr.alert-row {
  background-color: rgba(234, 179, 8, 0.08) !important;
}

.bb-table tbody tr.alert-row:hover {
  background-color: rgba(234, 179, 8, 0.14) !important;
}

/* ============================================================
   Signal Badges
   ============================================================ */

.ticker-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  cursor: pointer;
  transition: opacity 0.15s;
  letter-spacing: 0.03em;
}

.ticker-badge:hover { opacity: 0.8; }

.ticker-bullish  { background: rgba(16,185,129,0.2); color: #10b981; border: 1px solid rgba(16,185,129,0.4); }
.ticker-reset    { background: rgba(59,130,246,0.2);  color: #60a5fa; border: 1px solid rgba(59,130,246,0.4); }
.ticker-position { background: rgba(239,68,68,0.2);   color: #f87171; border: 1px solid rgba(239,68,68,0.4); }
.ticker-neutral  { background: rgba(107,114,128,0.2); color: #9ca3af; border: 1px solid rgba(107,114,128,0.4); }
.ticker-exit     { background: rgba(239,68,68,0.2);   color: #fca5a5; border: 1px solid rgba(239,68,68,0.5); }

/* ============================================================
   Cards
   ============================================================ */

.bb-card {
  background-color: #111827;
  border: 1px solid #1f2937;
  border-radius: 0.5rem;
  overflow: hidden;
}

.bb-card-header {
  padding: 0.75rem 1rem;
  background-color: #1f2937;
  border-bottom: 1px solid #374151;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.bb-card-header.active {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-bottom-color: rgba(59, 130, 246, 0.3);
}

.bb-card-header.exit-active {
  background-color: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-bottom-color: rgba(239, 68, 68, 0.3);
}

.bb-card-body {
  padding: 1rem;
}

/* ============================================================
   Stat Cards (Dashboard)
   ============================================================ */

.stat-card {
  background-color: #111827;
  border: 1px solid #1f2937;
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
}

.stat-card .stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  margin-bottom: 0.375rem;
}

.stat-card .stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  color: #f9fafb;
}

.stat-card .stat-sub {
  font-size: 0.6875rem;
  color: #6b7280;
  margin-top: 0.25rem;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
}

/* ============================================================
   Tabs (Positions)
   ============================================================ */

.bb-tabs {
  display: flex;
  border-bottom: 1px solid #374151;
  margin-bottom: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;        /* Firefox */
}
.bb-tabs::-webkit-scrollbar { display: none; }  /* Chrome/Safari */

.bb-tab {
  padding: 0.625rem 1.25rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.bb-tab:hover { color: #d1d5db; }

.bb-tab.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
}

@media (max-width: 640px) {
  .bb-tab {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }
}

/* ============================================================
   Buttons
   ============================================================ */

.bb-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.bb-btn-primary {
  background-color: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.bb-btn-primary:hover { background-color: #1d4ed8; }

.bb-btn-secondary {
  background-color: transparent;
  color: #9ca3af;
  border-color: #374151;
}
.bb-btn-secondary:hover { color: #f9fafb; border-color: #6b7280; }

.bb-btn-danger {
  background-color: transparent;
  color: #ef4444;
  border-color: #374151;
}
.bb-btn-danger:hover { background-color: rgba(239,68,68,0.1); border-color: #ef4444; }

.bb-btn-warning {
  background-color: transparent;
  color: #f59e0b;
  border-color: #374151;
}
.bb-btn-warning:hover { background-color: rgba(245,158,11,0.1); border-color: #f59e0b; }

.bb-btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* ============================================================
   Code / Pre (Logs)
   ============================================================ */

.bb-log-output {
  background-color: #0a0e1a;
  border: 1px solid #1f2937;
  border-radius: 0.375rem;
  padding: 1rem;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.8125rem;
  color: #d1d5db;
  max-height: 65vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
}

/* ============================================================
   Scrollbar (dark thin)
   ============================================================ */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #0a0e1a; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #4b5563; }

/* ============================================================
   Misc
   ============================================================ */

.text-green  { color: #10b981 !important; }
.text-red    { color: #ef4444 !important; }
.text-yellow { color: #f59e0b !important; }
.text-blue   { color: #3b82f6 !important; }
.text-purple { color: #8b5cf6 !important; }

.animate-pulse-slow {
  animation: pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes bb-spin {
  to { transform: rotate(360deg); }
}

.bb-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid #2d3a4f;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: bb-spin 0.65s linear infinite;
}

/* Collapse for about page — use Bootstrap collapse, override styles */
.collapse.show { display: block; }

/* Sector cards — unified neutral style (Regular Turtles) */
.sector-card-0,  .sector-card-1,  .sector-card-2,  .sector-card-3,
.sector-card-4,  .sector-card-5,  .sector-card-6,  .sector-card-7,
.sector-card-8,  .sector-card-9,  .sector-card-10, .sector-card-11 {
  border-color: #374151;
  border-left: 2px solid rgba(59,130,246,0.3);
}
.sector-hdr-0,  .sector-hdr-1,  .sector-hdr-2,  .sector-hdr-3,
.sector-hdr-4,  .sector-hdr-5,  .sector-hdr-6,  .sector-hdr-7,
.sector-hdr-8,  .sector-hdr-9,  .sector-hdr-10, .sector-hdr-11 {
  background: #1a2334;
  color: #9ca3af;
}

/* Theme Hunter card variant */
.sector-card-theme { border-left: 2px solid rgba(245,158,11,0.4); }
.sector-hdr-theme  { background: rgba(245,158,11,0.07); color: #d97706; }

/* Sector with open position — red accent */
.sector-card-in-position { border-left: 3px solid rgba(239,68,68,0.9) !important; }
.sector-hdr-in-position  { background: rgba(239,68,68,0.15) !important; }

/* Ticker chips */
.ticker-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0.18rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  cursor: pointer;
  background: #1f2937;
  color: #d1d5db;
  border: 1px solid #374151;
  transition: background 0.12s, color 0.12s;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.ticker-chip:hover { background: #263244; color: #f9fafb; }
.ticker-chip.chip-position { border-color: rgba(239,68,68,0.45); color: #fca5a5; }

.chip-dots { display: inline-flex; gap: 3px; align-items: center; margin-left: 3px; }
.cdot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cdot-reset    { background: #60a5fa; }
.cdot-bullish  { background: #10b981; }
.cdot-vol      { background: #8b5cf6; }
.cdot-earnings { background: #b45309; }
.cdot-position { background: #ef4444; }

/* Loading spinner overlay */
.bb-loading {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.bb-loading.active { display: flex; }


/* ---- Toggle switch ---- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
  margin: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #374151;
  border-radius: 20px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: #9ca3af;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: #2563eb; }
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(16px);
  background: #f9fafb;
}

/* History page — breakout signal dots (new types) */
/* Color = signal type: amber=breakout, cyan=reset, violet=vol, green=bullish */
/* Shape = tier: circle=System 1 / standard, diamond=System 2 / extended     */
.cdot-bo20     { background: #f59e0b; }                                                  /* amber circle  — 20d breakout */
.cdot-bo55     { background: #92400e; border-radius: 2px; transform: rotate(45deg); }   /* dark amber diamond — 55d breakout */
.cdot-reset-10 { background: #22d3ee; }                                                  /* cyan circle — System 1 reset */
.cdot-reset-20 { background: #0e7490; border-radius: 2px; transform: rotate(45deg); }   /* dark cyan diamond  — System 2 reset */
.cdot-vol      { background: #8b5cf6; }                                                  /* violet circle — vol spike */

/* History page — loading spinner */
.hist-spinner { text-align: center; padding: 2rem 0; color: #6b7280; font-size: 1.25rem; }
@keyframes hist-spin { to { transform: rotate(360deg); } }
.hist-spin-icon { display: inline-block; animation: hist-spin 0.8s linear infinite; }

/* History list view — date group header */
.hist-date-hdr {
  cursor: pointer;
  background: #1a2334;
  border-top: 1px solid #374151;
}
.hist-date-hdr:hover { background: #1f2d42; }
.hist-date-hdr td { padding: 0.45rem 1rem; font-size: 0.8rem; }
.hist-chevron { display: inline-block; width: 1rem; color: #6b7280; font-size: 0.7rem; }

/* History list view — ticker rows */
.hist-row-active { background-color: rgba(59,130,246,0.04); }
.hist-row-active:hover { background-color: rgba(59,130,246,0.1) !important; }

/* History grid view — horizontal scroll with sticky date column */
.hist-grid-wrapper { overflow-x: auto; }
.hist-grid-table .hist-sticky-col {
  position: sticky;
  left: 0;
  background: #1f2937;
  z-index: 2;
  box-shadow: 2px 0 6px rgba(0,0,0,0.5);
}
.hist-grid-table tbody .hist-sticky-col { background: #111827; z-index: 1; }
