/* ===========================================================
   Admin CRM — Painel de Gestão de Leads
   Paleta baseada no portfólio de Jeferson Araujo
   =========================================================== */

/* ---------- Design Tokens ---------- */
:root {
  --bg-deep: #06080E;
  --bg-body: #0A0C14;
  --surface: #12141D;
  --surface-hover: #181B28;
  --surface-glass: rgba(18, 20, 29, 0.72);
  --border: #1E2130;
  --border-light: rgba(124, 155, 255, 0.12);

  --text-primary: #F0F2F8;
  --text-secondary: #9AA4B2;
  --text-muted: #6B7280;

  --accent: #7C9BFF;
  --accent-soft: rgba(124, 155, 255, 0.12);
  --accent-glow: rgba(124, 155, 255, 0.25);

  --green: #34D399;
  --green-soft: rgba(52, 211, 153, 0.12);
  --amber: #FBBF24;
  --amber-soft: rgba(251, 191, 36, 0.10);
  --red: #EF4444;
  --red-soft: rgba(239, 68, 68, 0.12);
  --purple: #A78BFA;
  --purple-soft: rgba(167, 139, 250, 0.10);
  --cyan: #22D3EE;
  --cyan-soft: rgba(34, 211, 238, 0.10);
  --gray: #6B7280;
  --gray-soft: rgba(107, 114, 128, 0.12);

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 200ms var(--ease-out);
  --transition-med: 400ms var(--ease-out);

  --topbar-height: 60px;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; transition: var(--transition-fast); }
a:hover { color: #A8C0FF; }

/* ---------- Topbar ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
}

.topbar-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.brand-mark-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent-gradient, linear-gradient(135deg, #7C9BFF, #A78BFA));
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-user {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ---------- Main Content ---------- */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(var(--topbar-height) + 24px) 20px 40px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Alert ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 16px;
}
.alert-error {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: #90ACFF;
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.btn-danger {
  color: var(--red) !important;
}
.btn-danger:hover {
  background: var(--red-soft) !important;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
}

/* ---------- Search Bar ---------- */
.search-bar {
  margin-bottom: 20px;
}
.search-bar form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: var(--transition-fast);
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-input::placeholder {
  color: var(--text-muted);
}

/* ---------- Table ---------- */
.table-wrapper {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  text-align: left;
  padding: 14px 16px;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-deep);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--surface-hover);
}

.lead-name-link {
  font-weight: 600;
  color: var(--text-primary);
}
.lead-name-link:hover {
  color: var(--accent);
}

.text-muted {
  color: var(--text-muted);
}

.link-external {
  font-size: 0.85rem;
  word-break: break-all;
}

.actions-cell {
  display: flex;
  gap: 4px;
  align-items: center;
}

.inline-form {
  display: inline;
}

/* ---------- Status Badges ---------- */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-small { font-size: 0.65rem; padding: 2px 8px; }

.status-novo { background: var(--accent-soft); color: var(--accent); }
.status-contatado { background: var(--cyan-soft); color: var(--cyan); }
.status-interessado { background: var(--amber-soft); color: var(--amber); }
.status-reunião-agendada { background: var(--purple-soft); color: var(--purple); }
.status-proposta-enviada { background: var(--purple-soft); color: var(--purple); }
.status-aguardando-retorno { background: var(--amber-soft); color: var(--amber); }
.status-fechado { background: var(--green-soft); color: var(--green); }
.status-recusado { background: var(--red-soft); color: var(--red); }
.status-arquivado { background: var(--gray-soft); color: var(--gray); }

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center !important;
  padding: 40px 20px !important;
}
.empty-state-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty-title {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.empty-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ---------- Forms ---------- */
.lead-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group-full {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 14px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: var(--transition-fast);
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group select {
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* ---------- Detail Page ---------- */
.detail-grid {
  display: grid;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-list {
  display: grid;
  gap: 0;
}

.detail-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row dt {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.detail-row dd {
  font-size: 0.95rem;
  color: var(--text-primary);
  word-break: break-word;
}

/* ---------- Copy Card ---------- */
.card-copy .card-title {
  margin-bottom: 12px;
}

.copy-container {
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
}

.copy-text {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text-primary);
  margin: 0;
}

.copy-btn {
  cursor: pointer;
}

/* ---------- Notes ---------- */
.notes-content {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

/* ---------- Timeline (History) ---------- */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 16px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: -18px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-body);
}

.timeline-content {
  padding-left: 4px;
}

.timeline-desc {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 500;
}

.timeline-detail {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.timeline-date {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---------- Login Page ---------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-deep);
}

.login-wrapper {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #7C9BFF, #A78BFA);
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 12px;
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

.login-form .form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.login-form .form-group input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

.login-form .form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-form .btn-block {
  margin-top: 8px;
  padding: 12px;
  font-size: 1rem;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .detail-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .detail-row dt {
    font-size: 0.8rem;
  }

  .search-bar form {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input {
    min-width: unset;
  }

  .data-table th:nth-child(2),
  .data-table td:nth-child(2) {
    display: none;
  }
}

@media (max-width: 480px) {
  .data-table th:nth-child(3),
  .data-table td:nth-child(3) {
    display: none;
  }

  .login-card {
    padding: 24px 20px;
  }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-deep);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}