/* linkedin_db_harvester — feld.ai brand dashboard */

:root {
  --brand-dark: #0f172a;
  --brand-primary: #2563eb;
  --brand-primary-hover: #1d4ed8;
  --brand-accent: #06b6d4;
  --brand-success: #059669;
  --brand-warning: #d97706;
  --brand-danger: #dc2626;
  --brand-bg: #f8fafc;
  --brand-card: #ffffff;
  --brand-border: #e2e8f0;
  --brand-text: #1e293b;
  --brand-text-secondary: #64748b;
  --brand-text-muted: #94a3b8;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

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

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

/* ---- layout ---- */

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

.sidebar {
  width: 240px;
  background: var(--brand-dark);
  color: #fff;
  padding: 20px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 8px;
}

.sidebar-brand h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sidebar-brand small {
  font-size: 11px;
  color: var(--brand-text-muted);
  display: block;
  margin-top: 2px;
}

.sidebar nav { flex: 1; }

.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.sidebar a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar a.active { background: rgba(37,99,235,0.3); color: #fff; font-weight: 500; }
.sidebar a .icon { width: 18px; text-align: center; font-size: 16px; }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer .user-info {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}

.sidebar-footer button {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  margin-top: 8px;
  width: 100%;
}

.sidebar-footer button:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.main-content {
  margin-left: 240px;
  padding: 24px 32px;
  flex: 1;
  min-width: 0;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--brand-dark);
}

.page-header p {
  font-size: 14px;
  color: var(--brand-text-secondary);
  margin-top: 4px;
}

/* ---- cards ---- */

.card {
  background: var(--brand-card);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--brand-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--brand-dark);
}

.card-sub {
  font-size: 12px;
  color: var(--brand-text-muted);
  margin-top: 4px;
}

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

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

/* ---- tables ---- */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 12px;
  background: var(--brand-bg);
  border-bottom: 2px solid var(--brand-border);
  font-weight: 600;
  color: var(--brand-text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--brand-border);
  vertical-align: top;
}

tbody tr:hover { background: rgba(37,99,235,0.03); }

.truncate {
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.truncate-lg {
  max-width: 420px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}

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

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

.btn-danger {
  background: var(--brand-danger);
  color: #fff;
}

.btn-sm { padding: 5px 10px; font-size: 12px; }

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

/* ---- forms ---- */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--brand-text);
  margin-bottom: 4px;
}

.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--brand-border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--brand-text);
  background: #fff;
  transition: border-color 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ---- badges ---- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* ---- search bar ---- */

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-bar .form-input {
  max-width: 300px;
}

/* ---- status indicator ---- */

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.online { background: var(--brand-success); }
.status-dot.offline { background: var(--brand-text-muted); }

/* ---- login page ---- */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--brand-dark);
  padding: 16px;
}

.login-box {
  background: var(--brand-card);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

.login-box h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 4px;
}

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

.login-box .error {
  background: #fee2e2;
  color: #991b1b;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

/* ---- rate limit bars ---- */

.rate-bar {
  background: #e2e8f0;
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin-top: 4px;
}

.rate-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

.rate-bar-fill.ok { background: var(--brand-success); }
.rate-bar-fill.warn { background: var(--brand-warning); }
.rate-bar-fill.full { background: var(--brand-danger); }

/* ---- messages ---- */

.messages-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
}

/* conversation list scrolls inside its card (was an inline style) */
.messages-layout > .card:first-child {
  max-height: 700px;
  overflow-y: auto;
}

.message-thread {
  max-height: 500px;
  overflow-y: auto;
  padding: 12px;
  background: var(--brand-bg);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.message-bubble {
  padding: 8px 14px;
  border-radius: 12px;
  margin-bottom: 8px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.4;
}

.message-bubble.own {
  background: var(--brand-primary);
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.message-bubble.other {
  background: var(--brand-card);
  border: 1px solid var(--brand-border);
  border-bottom-left-radius: 4px;
}

.message-meta {
  font-size: 11px;
  color: var(--brand-text-muted);
  margin-top: 2px;
}

/* ---- avatars ---- */

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.name-cell .name-text strong { cursor: pointer; color: var(--brand-primary); }
.name-cell .name-text strong:hover { text-decoration: underline; }

/* ---- contact column ---- */

.contact-line {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  line-height: 1.6;
}

.contact-line a { color: var(--brand-primary); text-decoration: none; }
.contact-line a:hover { text-decoration: underline; }

/* ---- detail panel (slide-out) ---- */

.detail-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(0,0,0,0.3);
  z-index: 200;
  display: flex;
  justify-content: flex-end;
}

.detail-panel {
  width: 580px;
  max-width: 90vw;
  background: var(--brand-card);
  height: 100%;
  overflow-y: auto;
  padding: 24px;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.detail-panel .dp-close {
  float: right;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--brand-text-muted);
  padding: 4px 8px;
}

.detail-panel .dp-close:hover { color: var(--brand-text); }

.detail-panel .dp-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 12px;
}

.detail-panel .dp-photo-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 12px;
}

.detail-panel h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--brand-dark);
  margin-bottom: 4px;
}

.detail-panel .dp-headline {
  font-size: 14px;
  color: var(--brand-text-secondary);
  margin-bottom: 4px;
}

.detail-panel .dp-location {
  font-size: 13px;
  color: var(--brand-text-muted);
  margin-bottom: 16px;
}

.detail-panel .dp-section {
  margin-bottom: 16px;
}

.detail-panel .dp-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand-text-muted);
  margin-bottom: 6px;
}

.detail-panel .dp-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}

.detail-panel .dp-row .dp-label {
  color: var(--brand-text-muted);
}

.detail-panel .dp-row .dp-value {
  color: var(--brand-text);
  text-align: right;
  max-width: 60%;
  word-break: break-all;
}

.detail-panel .dp-row .dp-value a {
  color: var(--brand-primary);
  text-decoration: none;
}

.detail-panel .dp-row .dp-value a:hover {
  text-decoration: underline;
}

.detail-panel details {
  margin-top: 12px;
}

.detail-panel details summary {
  font-size: 12px;
  color: var(--brand-text-muted);
  cursor: pointer;
}

.detail-panel details pre {
  font-size: 11px;
  background: var(--brand-bg);
  border: 1px solid var(--brand-border);
  border-radius: 4px;
  padding: 8px;
  overflow-x: auto;
  margin-top: 4px;
  max-height: 300px;
  overflow-y: auto;
}

/* clickable table rows */
tbody tr.clickable { cursor: pointer; }

/* conversation list rows (hover used to be an inline onmouseover handler) */
.conv-row:hover { background: var(--brand-bg); }

/* ---- utilities ---- */

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.mono { font-family: 'IBM Plex Mono', monospace; font-size: 12px; }

/* ---- toast ---- */

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand-dark);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
#toast.show { opacity: 1; }

/* ---- task cards ---- */

.task-card { border: 1px solid var(--brand-border); border-radius: 8px; padding: 14px 16px; margin-bottom: 12px; background: var(--brand-card); }
.task-card .task-head { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--brand-text-muted); margin-bottom: 6px; flex-wrap: wrap; }
.task-card .task-title { font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.task-card textarea { width: 100%; min-height: 90px; font-size: 13px; font-family: inherit; padding: 8px; border: 1px solid var(--brand-border); border-radius: 6px; box-sizing: border-box; }
.task-card pre.task-params { font-size: 11px; background: var(--brand-bg); border: 1px solid var(--brand-border); border-radius: 4px; padding: 8px; overflow-x: auto; max-height: 180px; overflow-y: auto; margin: 0 0 8px; }
.task-card .task-lock { font-size: 12px; color: var(--brand-warning); margin-bottom: 8px; }
.task-card .task-reason { font-size: 12px; color: var(--brand-text-secondary); margin-bottom: 8px; }

/* ---- CV sections ---- */

.cv-item { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--brand-border); }
.cv-item:last-child { border-bottom: none; }
.cv-logo { width: 40px; height: 40px; border-radius: 4px; object-fit: contain; flex-shrink: 0; background: var(--brand-bg); }
.cv-item-body { flex: 1; min-width: 0; }
.cv-title { font-weight: 500; font-size: 13px; }
.cv-subtitle { font-size: 12px; color: var(--brand-text-secondary); }
.cv-date { font-size: 11px; color: var(--brand-text-muted); }
.cv-desc { font-size: 12px; color: var(--brand-text-secondary); margin-top: 4px; white-space: pre-line; }

.cv-item a { color: var(--brand-primary); text-decoration: none; }
.cv-item a:hover { text-decoration: underline; }

/* ---- skill badges ---- */

.skill-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: #f1f5f9;
  color: #475569;
  margin: 2px;
}

/* ---- photo zoom lightbox ---- */

.dp-photo { width: 120px; height: 120px; cursor: zoom-in; }

.dp-photo-zoomed {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  max-width: 90vw; max-height: 90vh;
  border-radius: 8px;
  z-index: 1100;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.7);
  cursor: zoom-out;
}

.dp-photo-placeholder {
  width: 120px;
  height: 120px;
  font-size: 42px;
}

/* ---- queue page ---- */

.queue-tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.queue-tab {
  padding: 8px 16px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid var(--brand-border);
  border-bottom: none;
  background: var(--brand-bg);
}
.queue-tab.active { background: var(--brand-card); font-weight: 500; }
.q-play { padding: 2px 8px; font-size: 16px; line-height: 1; }
.q-status { font-size: 11px; padding: 2px 6px; border-radius: 8px; }
.q-status.running { background: #dbeafe; color: #1e40af; }
.q-status.done { background: #d1fae5; color: #065f46; }
.q-status.failed { background: #fee2e2; color: #991b1b; }

/* ---- responsive ---- */

/* Mobile chrome (topbar + drawer backdrop) is injected by shell.js on every
   authed page; it only becomes visible under the phone media query below. */
.mobile-topbar, .sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    padding: 0 8px;
    background: var(--brand-dark);
    color: #fff;
    z-index: 150;
  }

  .mobile-topbar .nav-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    padding: 12px 14px;  /* ≥44px touch target */
    cursor: pointer;
  }

  .mobile-topbar .mobile-brand {
    font-size: 15px;
    font-weight: 600;
  }

  /* off-canvas drawer */
  .sidebar {
    width: 260px;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 250;
  }
  .sidebar a { padding: 12px 20px; }

  .main-content { margin-left: 0; padding: 64px 12px 16px; }

  .hide-sm { display: none; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header.flex-between { flex-wrap: wrap; gap: 8px; }
  .detail-panel { width: 100vw; max-width: 100vw; padding: 16px; }
  .truncate { max-width: 180px; }
  .truncate-lg { max-width: 220px; }
  .form-input { font-size: 16px; }  /* stops iOS zoom-on-focus */
  .search-bar .form-input { max-width: 100%; }
  .message-bubble { max-width: 92%; }
  .card { padding: 14px; }
  .cv-item { flex-wrap: wrap; }
  .messages-layout { grid-template-columns: 1fr; }
  .messages-layout > .card:first-child { max-height: 40vh; overflow-y: auto; }
  .detail-panel .dp-row { flex-wrap: wrap; }
  .detail-panel .dp-row .dp-value { max-width: 100%; text-align: left; }
}
