/* ============================================================================
   Módulo: M01 - Core Multi-Tenant (tema visual da plataforma)
   Camada: Web (wwwroot)
   Arquivo: src/VixLeads.Web/wwwroot/css/site.css
   ============================================================================ */

:root {
  --vx-sidebar-width: 248px;
  --vx-sidebar-width-collapsed: 72px;
  --vx-navy-950: #0f172a;
  --vx-navy-900: #141f38;
  --vx-navy-800: #1c2c4d;
  --vx-navy-700: #26386324;
  --vx-accent: #3461fd;
  --vx-accent-dark: #2749c9;
  --vx-bg: #f4f6fb;
  --vx-card-border: #e6e9f2;
  --vx-hot: #e5484d;
  --vx-warm: #f5a623;
  --vx-cold: #4a89dc;
  --vx-text-muted: #6b7280;
}

html, body {
  height: 100%;
  background-color: var(--vx-bg);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* --- Shell / Sidebar ------------------------------------------------------ */

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

.app-sidebar {
  width: var(--vx-sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--vx-navy-950), var(--vx-navy-900));
  color: #dbe3f5;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width .15s ease;
}

/* Sidebar recolhida: apenas ícones, rótulos e nome do tenant escondidos */
.app-shell.sidebar-collapsed .app-sidebar {
  width: var(--vx-sidebar-width-collapsed);
}

.app-shell.sidebar-collapsed .sidebar-brand span,
.app-shell.sidebar-collapsed .sidebar-nav .nav-link span,
.app-shell.sidebar-collapsed .sidebar-footer {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.app-shell.sidebar-collapsed .sidebar-nav .nav-link {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.app-shell.sidebar-collapsed .sidebar-nav .nav-link i {
  width: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.35rem 1.25rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand i {
  color: var(--vx-accent);
  font-size: 1.4rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.75rem;
  gap: 0.15rem;
  flex: 1 1 auto;
  overflow-y: auto;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.5rem;
  color: #b7c3de;
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}

.sidebar-nav .nav-link i {
  font-size: 1.05rem;
  width: 1.3rem;
  text-align: center;
}

.sidebar-nav .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  background-color: var(--vx-accent);
  color: #fff;
}

/* Submenu (ex.: Integrações > Conexões / Importações) */
.sidebar-nav .nav-sublink {
  padding-left: 2.1rem;
  font-size: 0.9rem;
}

.sidebar-nav .nav-sublink i {
  font-size: 1.3rem;
  width: 1.3rem;
}

.sidebar-nav [data-bs-toggle="collapse"] i.bi-chevron-down {
  transition: transform .15s ease;
}

.sidebar-nav [data-bs-toggle="collapse"][aria-expanded="true"] i.bi-chevron-down {
  transform: rotate(180deg);
}

.app-shell.sidebar-collapsed .sidebar-nav .nav-sublink,
.app-shell.sidebar-collapsed .sidebar-nav [data-bs-toggle="collapse"] i.bi-chevron-down {
  display: none;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* --- Main / Topbar --------------------------------------------------------- */

.app-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--vx-card-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 460px;
}

.topbar-search i {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--vx-text-muted);
}

.topbar-search .form-control {
  padding-left: 2.25rem;
  background-color: var(--vx-bg);
  border-color: var(--vx-card-border);
}

.topbar-user .btn {
  border: 1px solid var(--vx-card-border);
  background: #fff;
}

/* M18 - WhatsApp: atalho do Inbox com contador de mensagens novas (barra superior) */
.topbar-whatsapp {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 0.65rem;
  background: #25d366;
  color: #fff;
  font-size: 1.3rem;
  text-decoration: none;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.topbar-whatsapp:hover,
.topbar-whatsapp:focus {
  background: #1ebe5b;
  color: #fff;
}

.topbar-whatsapp-badge {
  position: absolute;
  top: -0.45rem;
  right: -0.5rem;
  min-width: 1.3rem;
  height: 1.3rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #e53935;
  color: #fff;
  border: 2px solid #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: calc(1.3rem - 4px);
  text-align: center;
}

.topbar-whatsapp.has-unread {
  animation: vx-whatsapp-pulse 1.6s ease-out 2;
}

@keyframes vx-whatsapp-pulse {
  0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.55); }
  100% { box-shadow: 0 0 0 0.7rem rgba(37, 211, 102, 0); }
}

/* M18 - WhatsApp: Inbox (marcadores de não lidas, mídia e documentos nas mensagens) */
.vx-unread-badge {
  display: inline-block;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #25d366;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
}

.vx-conversation-unread .fw-semibold {
  font-weight: 800 !important;
}

.vx-msg-bubble {
  max-width: 70%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.vx-msg-text {
  white-space: pre-wrap;
}

.vx-msg-image {
  display: block;
  max-width: 100%;
  width: 280px;
  max-height: 320px;
  object-fit: cover;
  border-radius: 0.5rem;
}

.vx-msg-audio {
  width: 260px;
  max-width: 100%;
}

.vx-msg-doc {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.85);
  color: var(--vx-navy-900);
  max-width: 300px;
}

.vx-msg-doc a {
  color: var(--vx-accent);
}

.vx-msg-doc-icon {
  font-size: 1.75rem;
  line-height: 1;
}

.vx-pending-file {
  padding: 0.35rem 0.6rem;
  border-radius: 0.5rem;
  background: var(--vx-bg);
  border: 1px dashed var(--vx-card-border);
}

/* M18 - WhatsApp: atalho no card do Pipeline para a conversa do lead */
.kanban-whatsapp-link {
  position: relative;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.45rem;
  background: #25d366;
  color: #fff;
  font-size: 0.9rem;
  text-decoration: none;
  flex-shrink: 0;
}

.kanban-whatsapp-link:hover {
  background: #1ebe5b;
  color: #fff;
}

.kanban-whatsapp-link .kanban-whatsapp-badge {
  position: absolute;
  top: -0.4rem;
  right: -0.45rem;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.2rem;
  border-radius: 999px;
  background: #e53935;
  color: #fff;
  border: 1.5px solid #fff;
  font-size: 0.58rem;
  font-weight: 700;
  line-height: calc(1rem - 3px);
  text-align: center;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--vx-accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
}

.app-content {
  padding: 1.5rem;
  flex: 1 1 auto;
}

/* --- Page header ------------------------------------------------------------ */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--vx-navy-900);
}

.page-header .text-muted {
  font-size: 0.9rem;
}

/* --- Cards / KPI tiles ------------------------------------------------------ */

.vx-card {
  background: #fff;
  border: 1px solid var(--vx-card-border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.kpi-tile {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.kpi-tile .kpi-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #fff;
  flex-shrink: 0;
}

.kpi-tile .kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--vx-navy-900);
  line-height: 1.1;
}

.kpi-tile .kpi-label {
  color: var(--vx-text-muted);
  font-size: 0.85rem;
}

/* --- Temperature / stage badges --------------------------------------------- */

.badge-temp-hot { background-color: var(--vx-hot); color: #fff; }
.badge-temp-warm { background-color: var(--vx-warm); color: #3a2900; }
.badge-temp-cold { background-color: var(--vx-cold); color: #fff; }

/* --- Avatar circles (lead initials) ----------------------------------------- */

.lead-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

.avatar-color-0 { background-color: #e5484d; }
.avatar-color-1 { background-color: #3461fd; }
.avatar-color-2 { background-color: #0d9488; }
.avatar-color-3 { background-color: #d97706; }
.avatar-color-4 { background-color: #7c3aed; }
.avatar-color-5 { background-color: #db2777; }
.avatar-color-6 { background-color: #16a34a; }

/* --- Kanban (Pipeline / Negócios) -------------------------------------------- */

.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
}

.kanban-column {
  background: #eef1f8;
  border-radius: 0.75rem;
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
}

.kanban-column-header {
  padding: 0.85rem 1rem;
  font-weight: 700;
  color: var(--vx-navy-900);
  border-bottom: 2px solid rgba(0, 0, 0, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kanban-column-body {
  padding: 0.65rem;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 60px;
}

.kanban-column-body.drag-over {
  background-color: rgba(52, 97, 253, 0.08);
  outline: 2px dashed var(--vx-accent);
  outline-offset: -4px;
}

.kanban-card {
  background: #fff;
  border-radius: 0.6rem;
  border: 1px solid var(--vx-card-border);
  border-left: 4px solid var(--vx-cold);
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.4rem;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.kanban-card.temp-hot { border-left-color: var(--vx-hot); }
.kanban-card.temp-warm { border-left-color: var(--vx-warm); }
.kanban-card.temp-cold { border-left-color: var(--vx-cold); }

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card.dragging {
  opacity: 0.5;
}

.kanban-card .card-title-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.2rem;
}

.kanban-card .lead-name {
  font-weight: 600;
  color: var(--vx-navy-900);
  font-size: 0.82rem;
}

.kanban-card .lead-meta {
  font-size: 0.7rem;
  color: var(--vx-text-muted);
}

.kanban-card .badge {
  font-size: 0.68rem;
}

.risk-dot {
  display: inline-block;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --- Editar Estágios do Funil (modal em /Pipeline) -------------------------- */

.stage-drag-handle {
  cursor: grab;
}

.stage-edit-row.dragging {
  opacity: 0.5;
}

.kanban-card .vx-stage-select {
  font-size: 0.7rem;
  padding-top: 0.15rem;
  padding-bottom: 0.15rem;
}

/* --- Timeline (CRM 360) ------------------------------------------------------ */

.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 0.6rem;
  top: 0.25rem;
  bottom: 0.25rem;
  width: 2px;
  background: var(--vx-card-border);
}

.timeline-item {
  position: relative;
  margin-bottom: 1.25rem;
}

.timeline-item .timeline-icon {
  position: absolute;
  left: -2rem;
  top: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--vx-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

/* M18 - WhatsApp: mensagens do mesmo dia agrupadas (e recolhidas) na Timeline do lead */
.timeline-item .timeline-icon.timeline-icon-whatsapp {
  background: #25d366;
}

.timeline-whatsapp-count {
  background: #25d366;
  color: #fff;
  font-size: 0.65rem;
  vertical-align: middle;
}

.timeline-whatsapp-messages li {
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.35rem;
  border-left: 3px solid #25d366;
  border-radius: 0.35rem;
  background: var(--vx-bg);
  font-size: 0.85rem;
}

/* --- Auth pages --------------------------------------------------------------- */

.auth-page {
  background: linear-gradient(135deg, var(--vx-navy-950), var(--vx-navy-800));
  min-height: 100vh;
}

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-footer {
  position: fixed;
  bottom: 0.5rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.8rem;
  pointer-events: none;
}

.auth-footer a {
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  pointer-events: auto;
}

.auth-footer a:hover { color: #fff; }

.auth-card {
  background: #fff;
  border-radius: 1rem;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
}

.auth-card .sidebar-brand {
  color: var(--vx-navy-900);
  border: none;
  padding: 0 0 1.5rem 0;
  justify-content: center;
}

.auth-card .sidebar-brand i {
  color: var(--vx-accent);
}

/* --- Utility ------------------------------------------------------------------- */

.nav-tabs .nav-link.active {
  font-weight: 600;
  border-bottom: 2px solid var(--vx-accent);
}

.table > :not(caption) > * > * {
  vertical-align: middle;
}

.validation-summary-valid {
  display: none;
}

.field-validation-valid {
  display: none;
}

/* --- Impressão (Leads > Relatório) ---------------------------------------------- */

@media print {
  .app-sidebar,
  .app-topbar,
  .no-print {
    display: none !important;
  }

  .app-content {
    padding: 0 !important;
  }

  .vx-card {
    border: none !important;
    box-shadow: none !important;
  }
}

/* M19 - API & Automação: documentação e blocos de código */
.vx-code {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.vx-docs h4 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.vx-docs section { scroll-margin-top: 80px; }
.vx-docs-toc { position: sticky; top: 80px; }
.vx-docs-toc a {
  display: block;
  padding: 4px 0;
  font-size: 0.875rem;
  color: inherit;
  text-decoration: none;
}
.vx-docs-toc a:hover { color: var(--bs-primary); }

/* M20 - VixAI: simulador e transcrição */
.vx-sim-thread { background: #efeae2; border-radius: 0 0 8px 8px; }
.vx-sim-bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}
.vx-sim-lead { background: #d9fdd3; }
.vx-sim-ai { background: #ffffff; }
.vx-ai-badge { background: #6f42c1; color: #fff; }

/* M18 - Inbox: filtros de situação de atendimento (Não lidas / Aguardando resposta / Respondidas) */
.vx-inbox-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.vx-inbox-filter {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
}
