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

:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #718096;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warn: #d97706;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);

  /* Negócios */
  --cz: #16a34a;
  --tm: #b45309;
  --el: #7c3aed;
}

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

/* ─── Header ─── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.header-right { display: flex; align-items: center; gap: 12px; }
.filtros { display: flex; gap: 8px; }

.filtros select,
.filtros input {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}

.filtros select:focus,
.filtros input:focus { border-color: var(--primary); }
.filtros input { width: 200px; }

/* ─── Buttons ─── */
.btn-primary, .btn-secondary, .btn-danger {
  padding: 7px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover   { background: var(--primary-hover); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e0; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover    { background: var(--danger-hover); }

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

/* ─── Kanban ─── */
.kanban {
  display: flex;
  gap: 16px;
  padding: 24px;
  overflow-x: auto;
  flex: 1;
  align-items: flex-start;
}

.coluna {
  flex: 0 0 280px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 112px);
}

.coluna-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius) var(--radius) 0 0;
}

.coluna-header h3 {
  font-size: .875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}

.coluna-badge {
  background: var(--bg);
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 24px;
  text-align: center;
}

.coluna-cards {
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

/* ─── Card ─── */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  position: relative;
}

.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }

.card-negocio {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
  color: #fff;
}

.negocio-carbono_zero .card-negocio       { background: var(--cz); }
.negocio-tarmac .card-negocio             { background: var(--tm); }
.negocio-elevation .card-negocio          { background: var(--el); }

.drawer-negocio-badge.negocio-carbono_zero { background: var(--cz); }
.drawer-negocio-badge.negocio-tarmac       { background: var(--tm); }
.drawer-negocio-badge.negocio-elevation    { background: var(--el); }

.card-empresa { font-size: .9rem; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.card-nome    { font-size: .8rem; color: var(--text-muted); margin-bottom: 8px; }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  flex-wrap: wrap;
  gap: 4px;
}

.card-contato { font-size: .75rem; color: var(--text-muted); }
.card-contato.urgente { color: var(--danger); font-weight: 600; }
.card-contato.hoje    { color: var(--warn);   font-weight: 600; }

.card-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.card:hover .card-actions { opacity: 1; }

.card-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: .75rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .15s;
}

.card-btn:hover     { background: var(--surface); color: var(--text); }
.card-btn.del:hover { border-color: var(--danger); color: var(--danger); }

.coluna-vazia {
  text-align: center;
  color: var(--text-muted);
  font-size: .8rem;
  padding: 24px 0;
}

/* ─── Drawer ─── */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 150;
  justify-content: flex-end;
}

.drawer-overlay.open { display: flex; }

.drawer {
  background: var(--surface);
  width: 420px;
  max-width: 100vw;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
  animation: drawer-in .22s ease;
}

@keyframes drawer-in {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.drawer-titulo { display: flex; align-items: flex-start; gap: 12px; flex: 1; min-width: 0; }

.drawer-negocio-badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 3px 10px;
  border-radius: 999px;
  color: #fff;
  white-space: nowrap;
  margin-top: 2px;
}

.drawer-empresa {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-nome {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 24px;
}

.drawer-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.drawer-section-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

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

.drawer-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meta-link {
  font-size: .875rem;
  color: var(--primary);
  text-decoration: none;
}
.meta-link:hover { text-decoration: underline; }

.meta-tag {
  font-size: .875rem;
  color: var(--text-muted);
}

/* Próximo contato */
.proximo-badge {
  display: inline-block;
  font-size: .875rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius);
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.proximo-badge.hoje {
  background: #fffbeb;
  color: var(--warn);
  border-color: #fde68a;
}

.proximo-badge.urgente {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}

.drawer-obs {
  font-size: .875rem;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Ações do lead */
.drawer-acoes {
  display: flex;
  gap: 8px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

/* Histórico */
.drawer-historico-section {
  border-bottom: none;
}

.registrar-form {
  margin-bottom: 12px;
}

.registrar-form textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: inherit;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}

.registrar-form textarea:focus { border-color: var(--primary); }

.registrar-acoes {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.historico-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.historico-vazio {
  font-size: .85rem;
  color: var(--text-muted);
  padding: 12px 0;
}

.historico-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.historico-data {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.historico-nota {
  font-size: .875rem;
  color: var(--text);
  line-height: 1.5;
}

/* ─── E-mail com IA ─── */
.btn-email-gerar {
  background: #7c3aed;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 5px 12px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.btn-email-gerar:hover:not(:disabled) { background: #6d28d9; }
.btn-email-gerar:disabled { opacity: .6; cursor: default; }

.btn-enviar {
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 5px 12px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-enviar:hover:not(:disabled) { background: #059669; }
.btn-enviar:disabled { opacity: .6; cursor: default; }

.email-form { display: flex; flex-direction: column; gap: 10px; }

.email-form .form-group label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.email-form input,
.email-form textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.email-form input:focus,
.email-form textarea:focus  { border-color: #7c3aed; }
.email-form textarea        { resize: vertical; line-height: 1.55; }

.email-acoes {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.email-status {
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: .82rem;
  font-weight: 500;
}
.email-status-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.email-status-ok   { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.email-status-erro { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

/* ─── Modal ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  animation: slide-in .2s ease;
}

.modal.modal-sm { max-width: 400px; }
.modal.modal-sm p { margin: 12px 0 20px; color: var(--text-muted); }

@keyframes slide-in {
  from { transform: translateY(-16px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

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

.modal-header h2 { font-size: 1.1rem; font-weight: 700; }

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

.btn-fechar:hover { color: var(--text); }

/* ─── Form ─── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); }

.form-group textarea { resize: vertical; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

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