/* BRMB Executive Platform — Core Stylesheet */

/* ── Reset & Variables ──────────────────────────────────────────────────── */

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d2e;
  --bg-card: #222640;
  --bg-input: #2a2e45;
  --text-primary: #e8eaf0;
  --text-secondary: #9da3b4;
  --text-muted: #6b7280;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --border: #2d3250;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --nav-height: 56px;
  --max-width: 960px;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* ── Skip Link ──────────────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  top: -100px;
  left: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius);
  z-index: 1000;
  transition: top 0.2s;
}
.skip-link:focus { top: 8px; }

/* ── Navbar ─────────────────────────────────────────────────────────────── */

.navbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: var(--nav-height);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand { flex-shrink: 0; }

.brand-link {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  letter-spacing: 1px;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 24px;
  flex: 1;
}

.nav-link {
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.nav-link:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-link.active { background: var(--bg-card); color: var(--text-primary); }
.nav-logout { margin-left: auto; color: var(--text-muted); }

.badge {
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.health-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 4px;
}
.health-dot.health-healthy, .health-dot.health-green, .health-dot.health-active { background: var(--success); }
.health-dot.health-degraded, .health-dot.health-yellow { background: var(--warning); }
.health-dot.health-unhealthy, .health-dot.health-red { background: var(--danger); }
.health-dot.health-unknown { background: var(--text-muted); }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  margin-left: auto;
}

.menu-icon {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  position: relative;
}
.menu-icon::before, .menu-icon::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  left: 0;
}
.menu-icon::before { top: -6px; }
.menu-icon::after { top: 6px; }

/* ── Main Content ───────────────────────────────────────────────────────── */

.main-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ── Page Header ────────────────────────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 600;
}

.page-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Status Cards ───────────────────────────────────────────────────────── */

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

.status-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
}

.status-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.status-value {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-detail {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.status-warning { color: var(--warning); }

.status-link {
  display: inline-block;
  font-size: 0.8rem;
  margin-top: 8px;
}

/* ── Status Badges ──────────────────────────────────────────────────────── */

.status-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.status-large { font-size: 0.9rem; padding: 6px 14px; }

.status-healthy, .status-completed, .status-pass, .status-active { background: rgba(34,197,94,0.15); color: var(--success); }
.status-degraded, .status-waiting, .status-pending { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-unhealthy, .status-failed, .status-blocked { background: rgba(239,68,68,0.15); color: var(--danger); }
.status-executing, .status-running, .status-approved { background: rgba(99,102,241,0.15); color: var(--accent); }
.status-discovery, .status-unknown { background: rgba(107,114,128,0.15); color: var(--text-muted); }

/* ── Sections ───────────────────────────────────────────────────────────── */

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

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.section-link { font-size: 0.8rem; }

/* ── Activity Feed ──────────────────────────────────────────────────────── */

.activity-list { display: flex; flex-direction: column; gap: 8px; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }

.activity-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.75rem;
}
.icon-success { background: rgba(34,197,94,0.15); color: var(--success); }
.icon-failure { background: rgba(239,68,68,0.15); color: var(--danger); }
.icon-info { background: rgba(59,130,246,0.15); color: var(--info); }

.activity-message { flex: 1; font-size: 0.9rem; }

.activity-meta { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

/* ── Initiative List ────────────────────────────────────────────────────── */

.initiative-list { display: flex; flex-direction: column; gap: 8px; }

.initiative-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.initiative-card:last-child { border-bottom: none; }

.initiative-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

/* ── Decision List ──────────────────────────────────────────────────────── */

.decision-list { display: flex; flex-direction: column; gap: 8px; }

.decision-card {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.decision-card:last-child { border-bottom: none; }

.decision-title { font-weight: 500; }
.decision-meta { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

/* ── Health Header ──────────────────────────────────────────────────────── */

.health-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.health-header h2 { font-size: 1.25rem; }

/* ── Alerts ─────────────────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: var(--danger); }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: var(--warning); }
.alert-info { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3); color: var(--info); }

/* ── Login ──────────────────────────────────────────────────────────────── */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
}

.login-container { width: 100%; max-width: 380px; padding: 16px; }

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.login-form { display: flex; flex-direction: column; gap: 12px; }

.login-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
.login-input:focus { border-color: var(--accent); }

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
  min-height: 44px;
  min-width: 44px;
}
.btn:active { transform: scale(0.98); }

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

.btn-secondary { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-card); }

.btn-login { width: 100%; }

/* ── Placeholders ───────────────────────────────────────────────────────── */

.placeholder-page {
  text-align: center;
  padding: 60px 20px;
}
.placeholder-page h2 { margin-bottom: 16px; }

/* ── Empty State ────────────────────────────────────────────────────────── */

.empty-state { color: var(--text-muted); font-style: italic; padding: 8px 0; }

/* ── Refresh Info ───────────────────────────────────────────────────────── */

.refresh-info {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 16px 0;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */

.footer {
  display: flex;
  justify-content: space-between;
  padding: 16px;
  max-width: var(--max-width);
  margin: 0 auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ── Screen Reader Only ─────────────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Executive Cards ────────────────────────────────────────────────────── */

.card-grid { display: flex; flex-direction: column; gap: 12px; }

.exec-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: block;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.exec-card-link { cursor: pointer; color: inherit; }
.exec-card-link:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: inherit; }
.exec-card-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.exec-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.exec-card-titles { flex: 1; min-width: 0; }
.exec-card-title { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exec-card-subtitle { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exec-card-body { margin-top: 8px; }
.exec-card-footer { margin-top: 8px; font-size: 0.75rem; color: var(--text-muted); }
.card-meta { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 8px; }

/* ── Metric Tiles ───────────────────────────────────────────────────────── */

.metric-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  text-align: center;
}
.metric-label { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.metric-value { font-size: 1.5rem; font-weight: 700; }
.metric-delta { font-size: 0.8rem; margin-top: 4px; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }
.trend-flat { color: var(--text-muted); }
.metric-timeframe { color: var(--text-muted); }

/* ── Progress Bar ───────────────────────────────────────────────────────── */

.progress-container { margin: 8px 0; }
.progress-bar { height: 6px; background: var(--bg-input); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s ease; }
.progress-label { font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; }
.progress-empty { font-size: 0.8rem; color: var(--text-muted); }

/* ── Timeline ───────────────────────────────────────────────────────────── */

.activity-timeline { display: flex; flex-direction: column; gap: 4px; }
.timeline-item { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-icon { flex-shrink: 0; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 0.7rem; }
.timeline-content { flex: 1; min-width: 0; }
.timeline-message { font-size: 0.9rem; }
.timeline-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ── Milestone & Work Unit Lists ────────────────────────────────────────── */

.milestone-list, .work-unit-list { display: flex; flex-direction: column; gap: 4px; }
.milestone-item, .work-unit-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.milestone-item:last-child, .work-unit-item:last-child { border-bottom: none; }
.milestone-icon, .wu-icon { flex-shrink: 0; width: 24px; text-align: center; font-size: 0.85rem; }
.milestone-name { flex: 1; font-weight: 500; }
.wu-content { flex: 1; min-width: 0; }
.wu-title { font-weight: 500; font-size: 0.9rem; }
.wu-criteria { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Detail Page ────────────────────────────────────────────────────────── */

.detail-header { margin-bottom: 20px; }
.detail-header-main { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-subtitle { font-size: 0.9rem; color: var(--text-secondary); margin-top: 4px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.detail-field { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.detail-value { font-size: 0.9rem; }

/* ── Tabs ───────────────────────────────────────────────────────────────── */

.tab-bar { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab { padding: 10px 16px; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s; }
.tab:hover { color: var(--text-primary); }
.tab-active { color: var(--text-primary); border-bottom-color: var(--accent); }

/* ── Breadcrumb ─────────────────────────────────────────────────────────── */

.breadcrumb { margin-bottom: 16px; }
.breadcrumb ol { list-style: none; display: flex; gap: 4px; font-size: 0.8rem; }
.breadcrumb li::after { content: '/'; color: var(--text-muted); margin-left: 4px; }
.breadcrumb li:last-child::after { content: ''; }
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb span { color: var(--text-primary); }

/* ── Filters ────────────────────────────────────────────────────────────── */

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; align-items: center; }
.filter-group { display: flex; gap: 4px; }
.filter-btn { padding: 6px 12px; border-radius: var(--radius); font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); background: var(--bg-card); border: 1px solid var(--border); transition: all 0.15s; }
.filter-btn:hover { color: var(--text-primary); border-color: var(--accent); }
.filter-active { color: var(--text-primary); background: var(--accent); border-color: var(--accent); }
.filter-select { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; font-size: 0.8rem; color: var(--text-primary); font-family: var(--font); }
.search-input { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px; font-size: 0.8rem; color: var(--text-primary); font-family: var(--font); min-width: 140px; }
.search-input:focus { border-color: var(--accent); outline: none; }

/* ── Empty State Block ──────────────────────────────────────────────────── */

.empty-state-block { padding: 32px; text-align: center; }

/* ── Status icon colors (for timeline/milestones) ───────────────────────── */

.status-healthy, .status-complete, .status-operating { color: var(--success); background: rgba(34,197,94,0.1); }
.status-executing, .status-validating { color: var(--accent); background: rgba(99,102,241,0.1); }
.status-pending, .status-idle, .status-paused, .status-unknown, .status-archived { color: var(--text-muted); background: rgba(107,114,128,0.1); }
.status-attention { color: var(--warning); background: rgba(245,158,11,0.1); }
.status-blocked, .status-critical, .status-failed { color: var(--danger); background: rgba(239,68,68,0.1); }

/* ── Mobile ─────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .menu-toggle { display: block; }

  .navbar-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    gap: 0;
  }
  .navbar-links.open { display: flex; }

  .nav-link { padding: 12px 8px; width: 100%; }
  .nav-logout { margin-left: 0; margin-top: 8px; border-top: 1px solid var(--border); padding-top: 12px; }

  .status-row { grid-template-columns: 1fr; }

  .activity-item { flex-wrap: wrap; }
  .activity-meta { width: 100%; padding-left: 34px; }

  .initiative-card { flex-direction: column; align-items: flex-start; gap: 4px; }

  .footer { flex-direction: column; gap: 4px; text-align: center; }

  .detail-header-main { flex-direction: column; align-items: flex-start; }
  .detail-grid { grid-template-columns: 1fr; }
  .tab-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .filter-bar { flex-direction: column; }
  .filter-group { flex-wrap: wrap; }
  .search-input { width: 100%; }
  .breadcrumb ol { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .main-content { padding: 16px 12px 32px; }
  .login-card { padding: 32px 20px; }
}
