/* Outpilot — App Styles */

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2e3350;
  --accent:    #6366f1;
  --accent2:   #818cf8;
  --success:   #10b981;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --text:      #e2e8f0;
  --text-muted:#94a3b8;
  --text-dim:  #64748b;
}

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

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

/* ── Layout ─────────────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent2);
  padding: 0 1.25rem 1.5rem;
  letter-spacing: -0.02em;
}

.sidebar-nav { flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: color 0.15s, background 0.15s;
}
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--accent2); background: rgba(99,102,241,0.1); }

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0.75rem 1.25rem 0.25rem;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2.5rem;
  max-width: 1200px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary   { background: var(--accent);  color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-sm        { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.btn-lg        { padding: 0.75rem 1.5rem; font-size: 1rem; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card-sm { padding: 0.875rem; }

/* ── Stats ───────────────────────────────────── */

.stat-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  flex: 1;
}
.stat-label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text); margin-top: 0.25rem; }
.stat-sub   { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── Forms ───────────────────────────────────── */

.form-group { margin-bottom: 1rem; }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

input, select, textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  transition: border-color 0.15s;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 120px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Table ───────────────────────────────────── */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }

thead { background: var(--surface2); }
thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

td { padding: 0.75rem 1rem; font-size: 0.875rem; }

/* ── Tags / badges ────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-pending  { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-sent     { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-failed   { background: rgba(239,68,68,0.15);  color: var(--danger);  }
.badge-active   { background: rgba(99,102,241,0.15); color: var(--accent2); }
.badge-inactive { background: rgba(100,116,139,0.15); color: var(--text-dim); }
.badge-researching { background: rgba(245,158,11,0.15); color: var(--warning); }

/* ── Modal ───────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  width: 560px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.modal-title { font-size: 1.1rem; font-weight: 600; }

.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.5rem; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ── Empty / loading states ──────────────────── */

.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-dim);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state h3 { font-size: 1rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.empty-state p  { font-size: 0.875rem; }

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent2);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row td { opacity: 0.5; }

/* ── Toast ───────────────────────────────────── */

#toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  pointer-events: all;
}
.toast-error   { border-left: 3px solid var(--danger); }
.toast-success { border-left: 3px solid var(--success); }

/* ── Utility ─────────────────────────────────── */

.text-muted { color: var(--text-muted); }
.text-dim   { color: var(--text-dim); }
.text-sm    { font-size: 0.8rem; }
.text-xs    { font-size: 0.72rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1.5rem 0 0.75rem;
}
.section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}

.page-section { margin-bottom: 2rem; }

/* ── Progress bar ────────────────────────────── */

.progress-bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s;
}

/* ── Scrollbar ───────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Animations ──────────────────────────────── */

.fade-in { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Media ───────────────────────────────────── */

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 0.75rem; }
  .sidebar-nav { display: flex; gap: 0.5rem; }
  .sidebar-logo { padding: 0; margin-right: 1rem; }
  .main-content { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .stat-row { flex-wrap: wrap; }
}