/* Bright AI Ops Platform — style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --bg: #0f1117;
  --surface: #161b27;
  --surface2: #1a2035;
  --border: #1e2130;
  --border2: #2a2f42;
  --text: #e0e6f0;
  --text-muted: #8890a4;
  --accent: #ff6b2b;
  --accent-hover: #e55a1f;
  --solar: #f59e0b;
  --green: #10b981;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --red: #ef4444;
  --yellow: #f59e0b;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Header ─────────────────────────────────────────────────────────────────── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.header-logo span.icon { font-size: 1.3rem; }
.header-logo .brand { color: var(--accent); }

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sync-info {
  color: var(--text-muted);
  font-size: .82rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 16px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  font-family: inherit;
}

.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.user-chip {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: .82rem;
  color: var(--text-muted);
}

/* ── Filter bar ──────────────────────────────────────────────────────────────── */
.filters {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

select, input[type="text"], input[type="search"] {
  background: var(--bg);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 12px;
  font-size: .85rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}

select:focus, input[type="text"]:focus, input[type="search"]:focus {
  border-color: var(--accent);
}

.search-input { min-width: 220px; }

.filter-count {
  margin-left: auto;
  color: var(--text-muted);
  font-size: .82rem;
}

/* ── Main content ────────────────────────────────────────────────────────────── */
.main {
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

/* ── Job grid ────────────────────────────────────────────────────────────────── */
.job-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.job-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .15s;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.job-card:hover {
  transform: translateY(-2px);
  border-color: var(--border2);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}

.job-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.job-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.job-address {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* Stage badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 5px;
  padding: 3px 8px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}

.badge-stage-early    { background: #232840; color: #8890a4; }
.badge-stage-permit   { background: #2d2410; color: #f59e0b; }
.badge-stage-install  { background: #0e2a1f; color: #10b981; }
.badge-stage-submit   { background: #0e1b38; color: #3b82f6; }
.badge-stage-complete { background: #0a2018; color: #34d399; }

.badge-vertical {
  background: rgba(245,158,11,.15);
  color: #f59e0b;
}

.blocker-flag {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 1rem;
  title: "Stalled >14 days";
}

.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: .82rem;
  color: var(--text-muted);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.meta-item strong { color: var(--text); }

.lr-id {
  font-family: 'Courier New', monospace;
  font-size: .75rem;
  color: #5a6180;
  margin-top: 4px;
}

.days-badge {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: .75rem;
  color: var(--text-muted);
}

.days-badge.stalled { border-color: #7f1d1d; color: #ef4444; }

/* ── Empty state ──────────────────────────────────────────────────────────────── */
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h2 { font-size: 1.2rem; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: .9rem; }

/* ── Job detail ──────────────────────────────────────────────────────────────── */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .detail-layout { grid-template-columns: 1fr; }
}

.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 20px;
  cursor: pointer;
}

.detail-back:hover { color: var(--text); }

.detail-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.detail-subtitle {
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 20px;
}

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.section-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

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

.field-item label {
  display: block;
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 3px;
  font-weight: 500;
}

.field-item .value {
  font-size: .9rem;
  color: var(--text);
  font-weight: 500;
}

.field-item .value.empty { color: #3a3f55; font-style: italic; }

/* ── Pipeline tracker ────────────────────────────────────────────────────────── */
.pipeline-tracker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  position: sticky;
  top: 80px;
}

.pipeline-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.stage-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.stage-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  padding-bottom: 18px;
}

.stage-item:last-child { padding-bottom: 0; }

.stage-item::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 24px;
  bottom: 0;
  width: 2px;
  background: var(--border2);
}

.stage-item:last-child::before { display: none; }

.stage-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.stage-item.done .stage-dot {
  background: #0e2a1f;
  border-color: var(--green);
  color: var(--green);
}

.stage-item.active .stage-dot {
  background: rgba(255,107,43,.15);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255,107,43,.1);
}

.stage-item.active::before { background: var(--border2); }

.stage-name-label {
  padding-top: 3px;
  font-size: .85rem;
}

.stage-item.done .stage-name-label { color: var(--text-muted); }
.stage-item.active .stage-name-label { color: var(--text); font-weight: 600; }
.stage-item.pending .stage-name-label { color: #3a3f55; }

/* ── Loading & toasts ────────────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px;
  color: var(--text-muted);
  gap: 12px;
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: .88rem;
  color: var(--text);
  z-index: 9999;
  animation: slideUp .2s ease;
  max-width: 340px;
}

.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }

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

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .header { padding: 0 16px; }
  .filters { padding: 10px 16px; }
  .main { padding: 16px; }
  .job-grid { grid-template-columns: 1fr; }
}
