/* ═══════════════════════════════════════════════════════════
   LeadFlow by Mystic — Dark Theme Stylesheet
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #181a24;
  --bg-card: rgba(24, 26, 36, 0.85);
  --bg-card-hover: rgba(32, 35, 48, 0.9);
  --bg-input: #1e2030;
  --bg-modal: rgba(0, 0, 0, 0.6);
  --border: #2b2f3e;
  --border-light: #3d4258;
  --text-primary: #eaecf0;
  --text-secondary: #a0a4b8;
  --text-muted: #6b7084;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --cyan: #22d3ee;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --blue: #60a5fa;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --sidebar-w: 220px;
  --topbar-h: 60px;
}

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

html, body {
  font-family: var(--font);
  background: linear-gradient(160deg, #0f1117 0%, #161926 40%, #1a1f35 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input { font-family: inherit; }

/* ─── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; border: none;
  transition: all var(--transition); white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  color: #fff;
}
.btn-primary:hover {
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-discord {
  background: #5865F2; color: #fff;
  padding: 14px 28px; font-size: 15px; border-radius: var(--radius);
  width: 100%; justify-content: center;
}
.btn-discord:hover {
  background: #4752c4;
  box-shadow: 0 0 24px rgba(88, 101, 242, 0.4);
  transform: translateY(-1px);
}
.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent-light); color: var(--text-primary); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; box-shadow: 0 0 16px rgba(239,68,68,0.3); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon {
  background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
  width: 32px; height: 32px; padding: 0; display: inline-flex;
  align-items: center; justify-content: center; border-radius: var(--radius-xs);
}
.btn-icon:hover { border-color: var(--accent-light); color: var(--text-primary); }

/* ─── Login Page ──────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-container { width: 100%; max-width: 420px; }
.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 48px 36px;
  box-shadow: var(--shadow-lg); text-align: center;
}
.login-brand { margin-bottom: 24px; }
.login-logo { margin-bottom: 16px; }
.login-brand h1 {
  font-size: 28px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent-light), var(--cyan));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-subtitle { color: var(--text-muted); font-size: 13px; font-weight: 400; margin-top: 2px; }
.login-desc { color: var(--text-secondary); font-size: 14px; margin-bottom: 28px; line-height: 1.6; }
.login-footer {
  margin-top: 24px; display: flex; align-items: center; justify-content: center;
  gap: 6px; color: var(--text-muted); font-size: 12px;
}
.error-title { color: var(--red) !important; -webkit-text-fill-color: var(--red) !important; }

/* ─── Top Bar ─────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: rgba(15, 17, 23, 0.9);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-title {
  font-size: 18px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent-light), var(--cyan));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.topbar-badge {
  font-size: 11px; color: var(--text-muted); background: var(--bg-input);
  padding: 2px 8px; border-radius: 20px; border: 1px solid var(--border);
}
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--border); }
.user-name { font-size: 14px; font-weight: 500; color: var(--text-secondary); }

/* ─── App Layout ──────────────────────────────────────────── */
.app-layout {
  display: flex; margin-top: var(--topbar-h); min-height: calc(100vh - var(--topbar-h));
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: rgba(15, 17, 23, 0.7);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 12px; z-index: 50;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-tab {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: transparent; border: none; color: var(--text-secondary);
  font-size: 14px; font-weight: 400; text-align: left; width: 100%;
  transition: all var(--transition); position: relative;
}
.sidebar-tab:hover { background: rgba(99, 102, 241, 0.08); color: var(--text-primary); }
.sidebar-tab.active {
  background: rgba(99, 102, 241, 0.1); color: var(--accent-light); font-weight: 500;
}
.sidebar-tab.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; background: var(--accent); border-radius: 0 3px 3px 0;
}
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 0; }
.sidebar-footer { padding-top: 12px; border-top: 1px solid var(--border); }

/* ─── Main Content ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w); flex: 1; padding: 28px 32px;
}
.content-view { display: none; }
.content-view.active { display: block; }
.content-header { margin-bottom: 24px; }
.content-title-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.content-title-row h2 { font-size: 22px; font-weight: 600; }

/* ─── Search ──────────────────────────────────────────────── */
.search-wrapper {
  position: relative; display: flex; align-items: center;
}
.search-wrapper svg {
  position: absolute; left: 14px; color: var(--text-muted); pointer-events: none;
}
.search-input {
  width: 100%; padding: 10px 14px 10px 40px;
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; outline: none; transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

/* ─── Leads List / Accordion ──────────────────────────────── */
.leads-list { display: flex; flex-direction: column; gap: 8px; }

.lead-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden; transition: border-color var(--transition);
}
.lead-card:hover { border-color: var(--border-light); }

.lead-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; cursor: pointer; user-select: none;
  transition: background var(--transition);
}
.lead-header:hover { background: var(--bg-card-hover); }
.lead-header-left { display: flex; align-items: center; gap: 12px; }
.lead-company { font-size: 15px; font-weight: 500; }
.lead-country {
  font-size: 12px; color: var(--text-muted); background: var(--bg-input);
  padding: 2px 8px; border-radius: 4px; border: 1px solid var(--border);
}
.lead-chevron {
  transition: transform 0.3s ease; color: var(--text-muted);
}
.lead-card.expanded .lead-chevron { transform: rotate(180deg); }

.lead-body {
  max-height: 0; overflow: hidden;
  transition: max-height 0.35s ease;
}
.lead-body-inner { padding: 6px 20px 20px; }

/* Lead detail rows */
.lead-detail { margin-bottom: 14px; }
.lead-detail-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.lead-detail-value { font-size: 14px; color: var(--text-secondary); line-height: 1.5; }
.lead-email-row { display: flex; align-items: center; gap: 10px; }
.lead-email-row .lead-detail-value { flex: 1; }

.btn-copy {
  padding: 4px 10px; font-size: 11px; border-radius: var(--radius-xs);
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text-secondary); transition: all var(--transition);
}
.btn-copy:hover { border-color: var(--cyan); color: var(--cyan); }
.btn-copy.copied { border-color: var(--green); color: var(--green); }

/* Clickable email */
.lead-email-clickable {
  cursor: pointer; transition: color var(--transition);
}
.lead-email-clickable:hover { color: var(--cyan); }

/* Website link */
.lead-website-link {
  color: var(--accent-light); text-decoration: none;
  transition: color var(--transition); word-break: break-all;
}
.lead-website-link:hover { color: var(--cyan); text-decoration: underline; }

/* Address multi-line */
.lead-address { white-space: pre-line; }

/* Lead actions bar */
.lead-actions {
  display: flex; align-items: center; gap: 8px;
  padding-top: 14px; margin-top: 14px;
  border-top: 1px solid var(--border);
}
.lead-actions .status-select {
  padding: 6px 10px; font-size: 12px;
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  outline: none; cursor: pointer;
}
.lead-actions .status-select:focus { border-color: var(--accent); }

/* Notes section */
.notes-section { margin-top: 16px; }
.notes-title { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.notes-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.note-card {
  padding: 10px 14px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.note-content { font-size: 13px; color: var(--text-secondary); flex: 1; line-height: 1.5; }
.note-meta { font-size: 11px; color: var(--text-muted); white-space: nowrap; text-align: right; }
.note-user { color: var(--accent-light); font-weight: 500; }

.note-input-row { display: flex; gap: 8px; }
.note-input {
  flex: 1; padding: 8px 12px;
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  font-size: 13px; outline: none; transition: border-color var(--transition);
}
.note-input:focus { border-color: var(--accent); }
.note-input::placeholder { color: var(--text-muted); }

/* ─── Logs ────────────────────────────────────────────────── */
.logs-list { display: flex; flex-direction: column; gap: 6px; }
.log-entry {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.log-badge {
  padding: 3px 8px; border-radius: 4px; font-size: 10px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap;
}
.log-badge.created { background: rgba(16,185,129,0.15); color: var(--green); }
.log-badge.edited { background: rgba(59,130,246,0.15); color: var(--blue); }
.log-badge.deleted { background: rgba(239,68,68,0.15); color: var(--red); }
.log-badge.status { background: rgba(245,158,11,0.15); color: var(--yellow); }
.log-badge.note { background: rgba(124,58,237,0.15); color: var(--accent-light); }
.log-body { flex: 1; min-width: 0; }
.log-text { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.log-text strong { color: var(--text-primary); font-weight: 500; }
.log-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.log-changes { margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.log-changes span { color: var(--text-secondary); }
.logs-pagination {
  display: flex; justify-content: center; gap: 8px; margin-top: 20px;
}
.page-btn {
  padding: 6px 12px; background: var(--bg-input); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  font-size: 12px; cursor: pointer; transition: all var(--transition);
}
.page-btn:hover { border-color: var(--accent-light); color: var(--text-primary); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* ─── Loading / Empty States ──────────────────────────────── */
.loading-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 60px 0; color: var(--text-muted);
}
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 60px 0; color: var(--text-muted);
}
.empty-state p { font-size: 16px; font-weight: 500; }
.empty-state span { font-size: 13px; }
.hidden { display: none !important; }

/* ─── Modals ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: var(--bg-modal);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal-card {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  width: 100%; max-width: 480px; box-shadow: var(--shadow-lg);
}
.modal-sm { max-width: 400px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close {
  background: transparent; border: none; color: var(--text-muted);
  padding: 4px; transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }
.modal-body-text { font-size: 14px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 12px; color: var(--text-secondary);
  margin-bottom: 6px; font-weight: 500;
}
.form-group input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  font-size: 14px; outline: none; transition: border-color var(--transition);
}
.form-group textarea {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  font-size: 14px; outline: none; transition: border-color var(--transition);
  font-family: inherit; resize: vertical; min-height: 60px;
  -webkit-appearance: none; appearance: none;
  color-scheme: dark; box-sizing: border-box;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--accent); }
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-muted); }

/* ─── Toast ───────────────────────────────────────────────── */
.toast-container {
  position: fixed; top: 76px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 300; pointer-events: none;
  max-width: 340px; width: 100%;
}
.toast {
  padding: 14px 20px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  pointer-events: auto;
  animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.toast.hiding {
  animation: toastSlideOut 0.3s ease forwards;
}
.toast.success { background: rgba(52,211,153,0.12); color: var(--green); border: 1px solid rgba(52,211,153,0.25); }
.toast.error { background: rgba(248,113,113,0.12); color: var(--red); border: 1px solid rgba(248,113,113,0.25); }
.toast.info { background: rgba(96,165,250,0.12); color: var(--blue); border: 1px solid rgba(96,165,250,0.25); }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(60px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to { opacity: 0; transform: translateX(60px) scale(0.95); }
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 56px;
    --topbar-h: 52px;
  }

  /* Topbar */
  .topbar { padding: 0 14px; }
  .topbar-badge { display: none; }
  .topbar-right { gap: 10px; }
  .user-name { display: none; }
  .avatar { width: 28px; height: 28px; }
  .topbar-title { font-size: 16px; }
  #logout-btn span,
  #logout-btn { font-size: 0; padding: 6px; gap: 0; }
  #logout-btn svg { font-size: initial; }

  /* Sidebar */
  .sidebar { width: var(--sidebar-w); padding: 12px 6px; }
  .sidebar-tab span { display: none; }
  .sidebar-tab {
    justify-content: center; padding: 10px;
    border-radius: var(--radius-xs);
  }
  .sidebar-tab svg { margin: 0; }
  .sidebar-tab.active::before { display: none; }
  .sidebar-footer { padding-top: 8px; }
  .sidebar-footer .btn {
    justify-content: center; padding: 8px; width: 100%;
  }
  .sidebar-footer .btn span { display: none; }

  /* Main Content */
  .main-content {
    margin-left: var(--sidebar-w);
    padding: 20px 16px;
  }

  /* Content header */
  .content-title-row { gap: 10px; }
  .content-title-row h2 { font-size: 18px; }
  #add-lead-btn { padding: 8px 14px; font-size: 13px; }

  /* Search */
  .search-input { padding: 9px 12px 9px 36px; font-size: 13px; }

  /* Lead cards */
  .lead-header { padding: 14px 16px; }
  .lead-company { font-size: 14px; }
  .lead-country { font-size: 11px; padding: 1px 6px; }
  .lead-body-inner { padding: 0 16px 16px; }
  .lead-email-row { flex-wrap: wrap; gap: 6px; }
  .lead-actions { flex-wrap: wrap; gap: 6px; }
  .lead-actions .status-select { flex: 1; min-width: 100px; }
  .note-input-row { flex-direction: column; gap: 6px; }
  .note-input-row .btn { align-self: flex-end; }

  /* Modals */
  .modal-overlay { padding: 12px; align-items: flex-end; }
  .modal-card { padding: 22px 18px; border-radius: var(--radius) var(--radius) 0 0; max-width: 100%; }
  .modal-sm { max-width: 100%; }

  /* Logs */
  .log-entry { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .log-badge { font-size: 9px; }
  .log-text { font-size: 12px; }
}

@media (max-width: 480px) {
  :root { --sidebar-w: 48px; }

  .topbar { padding: 0 10px; }
  .topbar-left { gap: 6px; }
  .topbar-title { font-size: 14px; }

  .sidebar { padding: 10px 4px; }
  .sidebar-tab { padding: 8px; }
  .sidebar-tab svg { width: 16px; height: 16px; }

  .main-content { padding: 16px 10px; }
  .content-title-row { flex-wrap: wrap; }
  .content-title-row h2 { font-size: 16px; }

  .lead-header { padding: 12px; }
  .lead-header-left { gap: 8px; }
  .lead-body-inner { padding: 0 12px 12px; }

  .modal-card { padding: 18px 14px; }
  .form-group input { padding: 9px 12px; font-size: 13px; }
}
