/* OutPilot Dashboard — Custom styles */
/* Primary brand: indigo/violet #6366f1 */

:root {
  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --primary-light: #eef2ff;
  --sidebar-bg:    #111827;
  --sidebar-text:  #d1d5db;
  --sidebar-hover: #1f2937;
  --sidebar-active:#374151;
  --body-bg:       #f8fafc;
  --card-bg:       #ffffff;
  --border:        #e5e7eb;
  --text-primary:  #111827;
  --text-secondary:#6b7280;
  --text-muted:    #9ca3af;
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #3b82f6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--body-bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

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

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

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid #1f2937;
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  color: #6b7280;
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #4b5563;
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  margin-bottom: 2px;
  user-select: none;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
}

.nav-item .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 9999px;
}

.nav-item.active .nav-badge {
  background: rgba(255,255,255,0.25);
}

.sidebar-footer {
  padding: 12px 10px 20px;
  border-top: 1px solid #1f2937;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
}

.sidebar-user .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user .user-info .name  { color: #fff; font-size: 12px; font-weight: 600; }
.sidebar-user .user-info .plan  { color: #6b7280; font-size: 11px; }

/* ── Main content ─────────────────────────────────────────── */

.main-content {
  flex: 1;
  margin-left: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.topbar-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ecfdf5;
  color: #059669;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 9999px;
}

.topbar-badge .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #10b981;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(1.3); }
}

.page-body {
  flex: 1;
  padding: 24px;
}

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

.card {
  background: var(--card-bg);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  transition: box-shadow 0.2s;
}

.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }

.card-header {
  padding: 18px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 18px 20px; }

/* ── Stat cards ─────────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: var(--card-bg);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  transition: box-shadow 0.2s, transform 0.15s;
}

.stat-card:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,.09);
  transform: translateY(-1px);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stat-icon {
  float: right;
  width: 40px; height: 40px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

/* ── Status badges ──────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-pending        { background: #f3f4f6; color: #6b7280; }
.badge-new            { background: #f3f4f6; color: #6b7280; }
.badge-contacted      { background: #eff6ff; color: #2563eb; }
.badge-replied        { background: #fffbeb; color: #d97706; }
.badge-converted      { background: #ecfdf5; color: #059669; }
.badge-not_interested { background: #fef2f2; color: #dc2626; }
.badge-active         { background: #ecfdf5; color: #059669; }
.badge-completed      { background: #f3f4f6; color: #6b7280; }
.badge-draft          { background: #faf5ff; color: #7c3aed; }
.badge-running        { background: #eff6ff; color: #2563eb; }
.badge-failed         { background: #fef2f2; color: #dc2626; }
.badge-success        { background: #ecfdf5; color: #059669; }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 3px 8px rgba(99,102,241,.35); }

.btn-secondary {
  background: var(--primary-light);
  color: var(--primary);
}
.btn-secondary:hover { background: #e0e7ff; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: #f9fafb; color: var(--text-primary); }

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 6px; }
.btn-xs { padding: 3px 8px;  font-size: 11px; border-radius: 5px; }

/* ── Tables ─────────────────────────────────────────────────── */

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

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: #fafafa; }
.data-table tbody tr:last-child td { border-bottom: none; }

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

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

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

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

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

.modal {
  background: #fff;
  border-radius: 20px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-title { font-size: 16px; font-weight: 700; }

.modal-body { padding: 20px 24px; }

.modal-footer {
  padding: 14px 24px 20px;
  display: flex; justify-content: flex-end; gap: 10px;
  border-top: 1px solid var(--border);
}

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

.progress-bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 9999px;
  transition: width 0.4s ease;
}

/* ── Log console ─────────────────────────────────────────────── */

.log-console {
  background: #0f172a;
  color: #94a3b8;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  height: 260px;
  overflow-y: auto;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line-ok    { color: #86efac; }
.log-line-error { color: #fca5a5; }
.log-line-info  { color: #93c5fd; }
.log-line-done  { color: #fde68a; font-weight: 700; }
.log-line-sep   { color: #c084fc; }

/* ── Job cards ───────────────────────────────────────────────── */

.job-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow 0.2s;
}

.job-card:hover { box-shadow: 0 6px 18px rgba(0,0,0,.08); }

.job-card-icon  { font-size: 32px; line-height: 1; }
.job-card-title { font-size: 15px; font-weight: 700; }
.job-card-desc  { font-size: 12px; color: var(--text-secondary); }
.job-card-meta  { font-size: 11px; color: var(--text-muted); }

/* ── WhatsApp conversation ───────────────────────────────────── */

.chat-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  height: calc(100vh - 140px);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}

.chat-sidebar-pane {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: #f8fafc;
}

.chat-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
}

.chat-contact {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.chat-contact:hover { background: #f1f5f9; }

.chat-contact.active { background: var(--primary-light); border-left: 3px solid var(--primary); }

.chat-contact .c-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}

.chat-contact .c-info { flex: 1; min-width: 0; }
.chat-contact .c-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-contact .c-preview { font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-contact .c-time { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }

.chat-main-pane {
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f0f4f8;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
}

.msg-bubble.lead {
  background: #fff;
  border-radius: 14px 14px 14px 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
  align-self: flex-start;
}

.msg-bubble.ai-msg {
  background: var(--primary);
  color: #fff;
  border-radius: 14px 14px 2px 14px;
  align-self: flex-end;
}

.msg-meta { font-size: 10px; margin-top: 3px; color: var(--text-muted); }
.msg-bubble.ai-msg .msg-meta { color: rgba(255,255,255,.65); }

.chat-input-bar {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Charts wrapper ──────────────────────────────────────────── */

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.chart-container {
  position: relative;
  height: 240px;
}

/* ── Activity feed ───────────────────────────────────────────── */

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.activity-text { flex: 1; font-size: 13px; color: var(--text-primary); }
.activity-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

/* ── Kanban columns ──────────────────────────────────────────── */

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: start;
}

.kanban-col {
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px;
  min-height: 200px;
}

.kanban-col-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kanban-card {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}

.kanban-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  transform: translateY(-1px);
}

.kanban-card .kc-name    { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.kanban-card .kc-area    { font-size: 11px; color: var(--text-secondary); }
.kanban-card .kc-preview { font-size: 11px; color: var(--text-muted); margin-top: 6px; font-style: italic; border-top: 1px solid #f3f4f6; padding-top: 6px; }
.kanban-card .kc-days    { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* ── Misc helpers ────────────────────────────────────────────── */

.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-mono      { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.rating-stars   { color: #f59e0b; }
.wa-btn         { background: #25D366 !important; color: #fff !important; }
.wa-btn:hover   { background: #1da851 !important; }

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

.section-title { font-size: 18px; font-weight: 700; }

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px; height: 24px;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute; inset: 0;
  background: #d1d5db;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider:before {
  position: absolute;
  content: '';
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

input:checked + .toggle-slider { background: var(--primary); }
input:checked + .toggle-slider:before { transform: translateX(20px); }

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

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: repeat(2, 1fr); }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-sidebar-pane { display: none; }
}

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

[x-cloak] { display: none !important; }

.fade-in { animation: fadeIn 0.2s ease-out; }

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

.spin { animation: spin 1s linear infinite; }

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