/* ========================================
   Flywheel Dashboard — Dark Theme v2
   ======================================== */

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-card: #1e2130;
  --bg-card-hover: #252839;
  --bg-input: #141620;
  --border: #2a2d3a;
  --border-light: #353849;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0b0;
  --text-muted: #6b7280;
  --accent: #6c8cff;
  --accent-hover: #8ba3ff;
  --green: #4ade80;
  --green-bg: rgba(74, 222, 128, 0.1);
  --yellow: #fbbf24;
  --yellow-bg: rgba(251, 191, 36, 0.1);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.1);
  --blue: #60a5fa;
  --blue-bg: rgba(96, 165, 250, 0.1);
  --purple: #a78bfa;
  --purple-bg: rgba(167, 139, 250, 0.1);
  --sidebar-width: 240px;
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ======== Sidebar ======== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-brand {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.brand-icon { font-size: 1.5rem; }
.brand-name { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }

.nav-links { list-style: none; padding: 1rem 0.75rem; flex: 1; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.nav-link:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
}

/* ======== Main ======== */
.content {
  margin-left: var(--sidebar-width);
  padding: 2.5rem;
  width: calc(100% - var(--sidebar-width));
  max-width: 1200px;
}

.section { display: none; }
.section.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ======== Headers ======== */
.section-header { margin-bottom: 2rem; }
.section-header h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.subtitle { color: var(--text-secondary); margin-top: 0.25rem; font-size: 0.9rem; }
.section-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.header-actions { display: flex; align-items: center; gap: 1rem; }
.last-updated { font-size: 0.8rem; color: var(--text-muted); }

/* ======== Grid ======== */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: 1fr 2fr; }
.mt { margin-top: 1.5rem; }

/* ======== Cards ======== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.2s ease;
}

.card:hover { border-color: var(--border-light); }

.company-card { cursor: pointer; }
.company-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 { font-size: 0.9rem; font-weight: 600; }
.card-body { padding: 1.25rem; }
.card-footer { padding: 0.75rem 1.25rem; border-top: 1px solid var(--border); }
.click-hint { font-size: 0.8rem; color: var(--accent); }
.placeholder-text { color: var(--text-muted); font-size: 0.85rem; text-align: center; padding: 1rem 0; }

/* ======== Status Badges ======== */
.pulse-status {
  font-size: 0.7rem; font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  white-space: nowrap;
}

.status-green { background: var(--green-bg); color: var(--green); }
.status-yellow { background: var(--yellow-bg); color: var(--yellow); }
.status-red { background: var(--red-bg); color: var(--red); }
.status-blue { background: var(--blue-bg); color: var(--blue); }
.status-purple { background: var(--purple-bg); color: var(--purple); }

/* ======== Pulse ======== */
.pulse-grid { display: flex; flex-direction: column; gap: 0.5rem; }
.pulse-item { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0; }
.pulse-name { font-weight: 500; font-size: 0.9rem; }

/* ======== Detail Lists ======== */
.detail-list { list-style: none; margin-top: 0.75rem; }
.detail-list li {
  padding: 0.3rem 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.detail-list li::before { content: "•"; color: var(--accent); }

/* ======== Company Detail ======== */
.company-detail { margin-top: 2rem; }
.company-detail.hidden { display: none; }

.back-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  transition: all 0.2s;
}
.back-btn:hover { background: var(--bg-card); color: var(--text-primary); }

/* ======== Filters & Tabs ======== */
.filter-bar, .tab-bar { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }

.filter-btn, .tab-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 100px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s;
}
.filter-btn:hover, .tab-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.filter-btn.active, .tab-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ======== Projects ======== */
.projects-list { display: flex; flex-direction: column; gap: 0.75rem; }

.project-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s;
}
.project-row:hover { border-color: var(--border-light); }
.project-row.completed { opacity: 0.5; }
.project-row.hidden { display: none; }

.project-tag {
  font-size: 0.65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.25rem 0.5rem; border-radius: 6px;
  white-space: nowrap; min-width: 70px; text-align: center;
}
.tag-yespac { background: rgba(108,140,255,0.15); color: var(--accent); }
.tag-eta { background: rgba(251,191,36,0.15); color: var(--yellow); }
.tag-elshazly { background: rgba(96,165,250,0.15); color: var(--blue); }
.tag-sprintpac { background: rgba(74,222,128,0.15); color: var(--green); }
.tag-personal { background: rgba(167,139,250,0.15); color: var(--purple); }

.project-info { flex: 1; }
.project-info h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.15rem; }
.project-info p { font-size: 0.75rem; color: var(--text-secondary); }

.project-meta { display: flex; align-items: center; gap: 0.75rem; }
.project-target { font-size: 0.75rem; color: var(--text-muted); }

.project-actions { display: flex; gap: 0.5rem; }

/* ======== Tasks ======== */
.task-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.task-item:last-child { border-bottom: none; }

.task-check {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.task-text { flex: 1; }
.task-text.done { text-decoration: line-through; color: var(--text-muted); }

.task-delete {
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  opacity: 0;
  transition: all 0.2s;
}
.task-item:hover .task-delete { opacity: 1; }
.task-delete:hover { color: var(--red); background: var(--red-bg); }

/* ======== Pipeline ======== */
.pipeline-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.pipeline-item:last-child { border-bottom: none; }
.pipeline-status {
  font-size: 0.65rem; font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
.pipeline-info { flex: 1; }
.pipeline-info strong { font-weight: 600; }
.pipeline-info p { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.15rem; }

/* ======== Ideas ======== */
.ideas-grid { display: flex; flex-direction: column; gap: 0.75rem; }

.idea-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  transition: all 0.2s;
}
.idea-card:hover { border-color: var(--border-light); }

.idea-content { flex: 1; }
.idea-content h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.25rem; }
.idea-content p { font-size: 0.8rem; color: var(--text-secondary); }
.idea-date { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.25rem; }
.idea-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* ======== Action Buttons ======== */
.btn-primary {
  background: var(--accent); color: #fff; border: none;
  padding: 0.6rem 1.25rem; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.85rem; font-weight: 600; transition: all 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary.loading { position: relative; color: transparent; }
.btn-primary.loading::after {
  content: ""; position: absolute;
  width: 16px; height: 16px;
  top: 50%; left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-secondary {
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 0.6rem 1.25rem; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.85rem; font-weight: 500; transition: all 0.2s;
}
.btn-secondary:hover { color: var(--text-primary); border-color: var(--border-light); }

.btn-small {
  background: none; border: 1px solid var(--border);
  color: var(--accent); padding: 0.3rem 0.75rem;
  border-radius: 6px; cursor: pointer;
  font-size: 0.75rem; font-weight: 600; transition: all 0.2s;
}
.btn-small:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.btn-icon {
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); padding: 0.3rem 0.5rem;
  border-radius: 6px; cursor: pointer;
  font-size: 0.75rem; transition: all 0.2s;
}
.btn-icon:hover { color: var(--text-primary); border-color: var(--border-light); }
.btn-icon.danger:hover { color: var(--red); border-color: var(--red); }

/* ======== Market Tracker ======== */
.tracker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.tracker-placeholder { grid-column: 1 / -1; text-align: center; color: var(--text-muted); padding: 1.5rem; }

.tracker-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.tracker-item.flagged { border-color: var(--red); background: var(--red-bg); }
.tracker-symbol { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tracker-price { font-size: 1.4rem; font-weight: 700; }
.tracker-change { font-size: 0.8rem; font-weight: 600; }
.tracker-change.positive { color: var(--green); }
.tracker-change.negative { color: var(--red); }
.tracker-change.neutral { color: var(--text-muted); }
.tracker-ytd { font-size: 0.75rem; font-weight: 600; }
.tracker-ytd.positive { color: var(--green); }
.tracker-ytd.negative { color: var(--red); }
.tracker-ytd.neutral { color: var(--text-muted); }
.tracker-meta { font-size: 0.65rem; color: var(--text-muted); margin-top: 0.15rem; }
.tracker-sources { font-size: 0.6rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.25rem; }
.source-match { color: var(--green); }
.source-mismatch { color: var(--red); }

/* ======== Alerts ======== */
.alerts-container { margin-bottom: 1.5rem; }
.alerts-container.hidden { display: none; }
.alert {
  background: var(--red-bg);
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem; margin-bottom: 0.5rem;
  font-size: 0.8rem; color: var(--red);
}

/* ======== News ======== */
.news-item { display: flex; gap: 1rem; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.news-item:last-child { border-bottom: none; }
.news-tag {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  padding: 0.2rem 0.5rem; border-radius: 4px;
  background: var(--bg-secondary); color: var(--text-muted);
  white-space: nowrap; height: fit-content;
}
.news-content h4 { font-size: 0.85rem; font-weight: 500; margin-bottom: 0.15rem; }
.news-content h4 a { color: var(--text-primary); text-decoration: none; transition: color 0.2s; }
.news-content h4 a:hover { color: var(--accent); }
.news-content p { font-size: 0.75rem; color: var(--text-secondary); }

/* ======== Modal ======== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%; max-width: 500px;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 1.2rem; padding: 0.25rem;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 0.75rem;
}

.form-group { margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  display: block; font-size: 0.8rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 0.4rem;
}
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 0.6rem 0.75rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 0.85rem; font-family: inherit;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none; border-color: var(--accent);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* ======== Clickable Items ======== */
.item-link {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s;
  cursor: pointer;
}
.item-link:hover {
  color: var(--accent);
}
.link-icon {
  font-size: 0.7em;
  opacity: 0;
  transition: opacity 0.2s;
  color: var(--accent);
}
.item-link:hover .link-icon {
  opacity: 1;
}
.item-name {
  cursor: pointer;
  transition: color 0.2s;
  border-bottom: 1px dashed var(--border-light);
}
.item-name:hover {
  color: var(--accent);
}
.task-item:hover .btn-icon {
  opacity: 1 !important;
}

/* ======== Lock Screen ======== */
#lock-screen {
  position: fixed; inset: 0;
  background: var(--bg-primary);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.lock-box {
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem 2.5rem;
  width: 90%; max-width: 360px;
}
.lock-icon { font-size: 3rem; margin-bottom: 1rem; }
.lock-box h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 1.5rem; }
.lock-box input {
  width: 100%; padding: 0.75rem 1rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 0.9rem; font-family: inherit;
  text-align: center; margin-bottom: 1rem;
}
.lock-box input:focus { outline: none; border-color: var(--accent); }
.lock-box button {
  width: 100%; padding: 0.75rem;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 0.9rem; font-weight: 600; transition: background 0.2s;
}
.lock-box button:hover { background: var(--accent-hover); }

/* ======== Responsive ======== */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .nav-label, .sidebar-footer span:not(.status-dot) { display: none; }
  .nav-link { justify-content: center; padding: 0.75rem; }
  .sidebar-brand { justify-content: center; }
  .brand-name { display: none; }
  .content { margin-left: 60px; width: calc(100% - 60px); padding: 1.5rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .section-header-row { flex-direction: column; }
}
