/* ============================================================
   Yestermorrow Mission Control Dashboard — Styles
   ============================================================ */

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #1c2128;
  --bg-card: #21262d;
  --bg-hover: #292e36;
  --border: #30363d;
  --border-light: #3d444d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --accent-dim: #1f6feb;
  --green: #3fb950;
  --green-dim: #238636;
  --yellow: #d29922;
  --yellow-dim: #9e6a03;
  --red: #f85149;
  --red-dim: #da3633;
  --orange: #db6d28;
  --purple: #bc8cff;
  --sidebar-width: 220px;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --transition: 0.15s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Login Gate ── */
.login-overlay {
  position: fixed; inset: 0;
  background: var(--bg-primary);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.login-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 360px;
  text-align: center;
  box-shadow: var(--shadow);
}
.login-box h1 {
  font-size: 1.4rem;
  margin-bottom: 4px;
  color: var(--text-primary);
}
.login-box .subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 24px;
}
.login-box input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-bottom: 12px;
  outline: none;
  transition: border var(--transition);
}
.login-box input:focus { border-color: var(--accent); }
.login-box button {
  width: 100%;
  padding: 10px;
  background: var(--accent-dim);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.login-box button:hover { background: var(--accent); }
.login-error {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 8px;
  min-height: 20px;
}

/* ── App Layout ── */
.login-overlay.hidden { display: none; }
.app { display: flex; min-height: 100vh; }
.app.hidden { display: none; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100;
}
.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.sidebar-header .version {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}
.nav-section-label {
  padding: 12px 16px 4px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-left-color: var(--accent);
}
.nav-item .icon { font-size: 1rem; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--red-dim);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
}
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── Main Content ── */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 24px 28px;
  min-height: 100vh;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.page-header .actions { display: flex; gap: 8px; }

/* ── Buttons ── */
.btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-light); }
.btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: #fff;
}
.btn-primary:hover { background: var(--accent); }
.btn-sm { padding: 4px 10px; font-size: 0.78rem; }
.btn-success { background: var(--green-dim); border-color: var(--green-dim); color: #fff; }
.btn-danger { background: var(--red-dim); border-color: var(--red-dim); color: #fff; }

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border var(--transition);
}
.kpi-card:hover { border-color: var(--border-light); }
.kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
}
.kpi-card.green .kpi-value { color: var(--green); }
.kpi-card.yellow .kpi-value { color: var(--yellow); }
.kpi-card.red .kpi-value { color: var(--red); }
.kpi-card.blue .kpi-value { color: var(--accent); }
.kpi-card.purple .kpi-value { color: var(--purple); }

/* ── Cards ── */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

/* ── Two Column Layout ── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ── Agent Cards Grid ── */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.agent-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: all var(--transition);
}
.agent-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.agent-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.agent-card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.active { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.idle { background: var(--text-muted); }
.status-dot.blocked { background: var(--red); box-shadow: 0 0 6px var(--red); }
.agent-role {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.agent-meta {
  display: flex; flex-direction: column; gap: 4px;
}
.agent-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.agent-meta-row .label { color: var(--text-muted); min-width: 90px; }
.agent-meta-row .value { color: var(--text-secondary); }

/* ── Tables ── */
.table-wrapper {
  overflow-x: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}
thead th {
  background: var(--bg-tertiary);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--text-primary); }
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--bg-tertiary); }
tbody tr:last-child td { border-bottom: none; }
.clickable-row { cursor: pointer; }

/* ── Status Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-active, .badge-completed, .badge-success { background: var(--green-dim); color: var(--green); }
.badge-in-progress, .badge-in_progress, .badge-waiting { background: var(--yellow-dim); color: var(--yellow); }
.badge-blocked, .badge-overdue, .badge-failure { background: var(--red-dim); color: var(--red); }
.badge-idle, .badge-backlog, .badge-planned, .badge-archived { background: var(--bg-tertiary); color: var(--text-muted); }
.badge-high { background: var(--red-dim); color: var(--red); }
.badge-medium { background: var(--yellow-dim); color: var(--yellow); }
.badge-low { background: var(--bg-tertiary); color: var(--text-muted); }

/* ── Filters ── */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filters select, .filters input[type="text"] {
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
}
.filters select:focus, .filters input[type="text"]:focus { border-color: var(--accent); }

/* ── Feed Items ── */
.feed-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.feed-item:last-child { border-bottom: none; }
.feed-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.feed-item-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
}
.feed-item-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.feed-item-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Detail Page ── */
.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
  margin-bottom: 16px;
}
.detail-back:hover { text-decoration: underline; }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; }
}
.detail-field {
  margin-bottom: 12px;
}
.detail-field .label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 2px;
}
.detail-field .value {
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.modal h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
}
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}

/* ── Daily Summary Detail ── */
.summary-section {
  margin-bottom: 18px;
}
.summary-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}
.summary-list {
  list-style: none;
  padding: 0;
}
.summary-list li {
  padding: 4px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.summary-list li:last-child { border-bottom: none; }
.agent-activity-item {
  margin-bottom: 8px;
}
.agent-activity-item .agent-name {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-primary);
}
.agent-activity-item .activity-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-left: 8px;
}

/* ── Utility ── */
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-accent { color: var(--accent); }
.flex-center { display: flex; align-items: center; gap: 8px; }
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.last-updated {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}
