/* ==========================================================================
   JT REVESTIMENTOS - ADMIN BACKEND STYLESHEET
   Painel de Gestão de Leads, Métricas Comerciais e Configurações
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --adm-bg: #0b0f19;
  --adm-sidebar: #070a12;
  --adm-card: #111827;
  --adm-card-hover: #172033;
  --adm-border: rgba(255, 255, 255, 0.08);
  --adm-border-active: rgba(245, 158, 11, 0.4);

  --adm-text: #f8fafc;
  --adm-muted: #94a3b8;
  --adm-dim: #64748b;

  --adm-primary: #2563eb;
  --adm-accent: #f59e0b;
  --adm-success: #10b981;
  --adm-warning: #f59e0b;
  --adm-danger: #ef4444;
  --adm-info: #06b6d4;

  --adm-radius: 10px;
  --adm-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

body.admin-body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--adm-bg);
  color: var(--adm-text);
  margin: 0;
  padding: 0;
  display: flex;
  min-height: 100vh;
}

/* TELA DE LOGIN */
.admin-login-wrapper {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, rgba(37, 99, 235, 0.15) 0%, transparent 60%),
              linear-gradient(to bottom, #090d16 0%, #05070c 100%);
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  position: relative;
}

.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--adm-primary), var(--adm-accent));
  border-radius: 16px 16px 0 0;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header img {
  height: 48px;
  margin: 0 auto 1rem auto;
}

.login-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  color: #fff;
  margin-bottom: 0.3rem;
}

.login-header p {
  color: var(--adm-muted);
  font-size: 0.85rem;
}

/* LAYOUT DO PAINEL LOGADO */
.admin-layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* SIDEBAR */
.admin-sidebar {
  width: 260px;
  background: var(--adm-sidebar);
  border-right: 1px solid var(--adm-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--adm-border);
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.sidebar-header img {
  height: 38px;
}

.sidebar-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  line-height: 1.2;
}

.sidebar-title span {
  display: block;
  font-size: 0.7rem;
  color: var(--adm-accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sidebar-menu {
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-grow: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  border-radius: var(--adm-radius);
  color: var(--adm-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.menu-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.menu-item.active {
  color: #fff;
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.4);
  font-weight: 600;
}

.menu-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1.2rem;
  border-top: 1px solid var(--adm-border);
}

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 0.75rem;
  border-radius: var(--adm-radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fff;
}

/* ÁREA DE CONTEÚDO PRINCIPAL */
.admin-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--adm-bg);
}

.admin-topbar {
  height: 70px;
  padding: 0 2rem;
  border-bottom: 1px solid var(--adm-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(10px);
}

.topbar-left h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  padding: 0.4rem 0.8rem;
  border-radius: var(--adm-radius);
  font-size: 0.85rem;
}

.user-avatar {
  width: 28px;
  height: 28px;
  background: var(--adm-primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.admin-body-content {
  padding: 2rem;
  flex-grow: 1;
}

/* KPIS E STATS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: var(--adm-radius);
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.stat-info span {
  font-size: 0.8rem;
  color: var(--adm-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  display: block;
  margin-bottom: 0.4rem;
}

.stat-info h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--adm-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.stat-icon.icon-blue { background: rgba(37, 99, 235, 0.15); color: #60a5fa; }
.stat-icon.icon-amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.stat-icon.icon-green { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.stat-icon.icon-cyan { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }

/* FILTROS E BARRA DE AÇÕES */
.actions-bar {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: var(--adm-radius);
  padding: 1.2rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.search-input-wrap {
  position: relative;
  min-width: 280px;
}

.search-input-wrap input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.4rem;
  background: var(--adm-bg);
  border: 1px solid var(--adm-border);
  border-radius: var(--adm-radius);
  color: #fff;
  font-size: 0.85rem;
}

.search-input-wrap input:focus {
  outline: none;
  border-color: var(--adm-accent);
}

.search-input-wrap svg {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--adm-dim);
  width: 16px;
  height: 16px;
}

.status-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--adm-border);
  color: var(--adm-muted);
  padding: 0.45rem 0.9rem;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.filter-btn.active {
  background: var(--adm-accent);
  color: #0b0f19;
  border-color: var(--adm-accent);
  font-weight: 600;
}

/* TABELA DE LEADS */
.leads-table-wrap {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: var(--adm-radius);
  overflow-x: auto;
  box-shadow: var(--adm-shadow);
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.leads-table th {
  background: #0d1320;
  padding: 1rem 1.2rem;
  color: var(--adm-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  border-bottom: 1px solid var(--adm-border);
}

.leads-table td {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--adm-border);
  color: #cbd5e1;
}

.leads-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* BADGES DE STATUS */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-Novo { background: rgba(6, 182, 212, 0.15); color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.3); }
.status-Em-Análise { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.status-Proposta-Enviada { background: rgba(37, 99, 235, 0.15); color: #60a5fa; border: 1px solid rgba(37, 99, 235, 0.3); }
.status-Aprovado { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.status-Concluído { background: rgba(139, 92, 246, 0.15); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.3); }
.status-Arquivado { background: rgba(100, 116, 139, 0.15); color: #94a3b8; border: 1px solid rgba(100, 116, 139, 0.3); }

/* BOTÕES DE AÇÃO NA LINHA */
.table-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-action {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--adm-border);
  color: var(--adm-muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-action:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn-whatsapp-action {
  background: rgba(37, 211, 102, 0.15);
  color: #25d366;
  border-color: rgba(37, 211, 102, 0.3);
}

.btn-whatsapp-action:hover {
  background: #25d366;
  color: #fff;
}

/* MODAL DE DETALHES DO LEAD */
.admin-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.admin-modal-overlay.hidden {
  display: none;
}

.admin-modal {
  width: 100%;
  max-width: 680px;
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 16px;
  box-shadow: var(--adm-shadow);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.4rem 1.8rem;
  border-bottom: 1px solid var(--adm-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-family: 'Outfit', sans-serif;
  color: #fff;
  font-size: 1.2rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--adm-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.8rem;
  overflow-y: auto;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin-bottom: 1.5rem;
}

.modal-field label {
  font-size: 0.75rem;
  color: var(--adm-muted);
  text-transform: uppercase;
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
}

.modal-field p {
  font-size: 0.95rem;
  color: #fff;
}

.modal-notes-section {
  border-top: 1px solid var(--adm-border);
  padding-top: 1.5rem;
  margin-top: 1.5rem;
}

.notes-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin: 1rem 0;
  max-height: 180px;
  overflow-y: auto;
}

.timeline-item {
  background: rgba(0, 0, 0, 0.25);
  border-left: 3px solid var(--adm-accent);
  padding: 0.6rem 0.9rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.timeline-item-meta {
  color: var(--adm-dim);
  font-size: 0.75rem;
  margin-bottom: 0.2rem;
}

.modal-footer {
  padding: 1.2rem 1.8rem;
  border-top: 1px solid var(--adm-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0c111e;
}

/* RESPONSIVIDADE ADMIN */
@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed;
    left: -260px;
    height: 100vh;
    z-index: 1500;
  }
  .admin-sidebar.open {
    left: 0;
  }
}
