/* =====================
   RESET E CONFIGURAÇÃO GLOBAL
   ===================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
}

body:not(.login-page) {
  height: 100%;
  width: 100%;
  background: #f5f7fa;
  overflow: hidden;
}

/* =====================
   CORES PADRÃO LOGCOMEX (Brand Guidelines)
   ===================== */
:root {
  /* Paleta Principal */
  --log-roxo: #6613D0;
  --log-laranja: #FE8F1C;
  --log-branco: #FFFFFF;
  --log-offwhite: #F4F4F4;
  /* Roxos */
  --log-roxo-escuro: #2D085D;
  --log-roxo-medio: #440C8C;
  --log-roxo-1: #5B11BA;
  --log-roxo-2: #7215E9;
  --log-roxo-3: #8E44ED;
  --log-roxo-4: #AA72F2;
  --log-roxo-5: #C6A1F6;
  --log-roxo-6: #E2D0FA;
  /* Laranjas */
  --log-laranja-escuro: #984D00;
  --log-laranja-medio: #CB6700;
  --log-laranja-1: #FD8101;
  --log-laranja-2: #FE9A33;
  --log-laranja-3: #FEB366;
  --log-laranja-4: #FECC99;
  --log-laranja-5: #FEE5CC;
  --log-laranja-6: #FFF2E4;
  /* Verdes */
  --log-verde: #1fac66;
  --log-verde-2: #27d780;
  --log-verde-3: #52df99;
  --log-verde-4: #7de7b3;
  --log-verde-5: #a8efcc;
  --log-verde-6: #d3f7e5;
  /* Azuis */
  --log-azul: #1da6ae;
  --log-azul-2: #24cfda;
  --log-azul-3: #50d9e1;
  --log-azul-4: #7c6e28;
  --log-azul-5: #a7ecf0;
  --log-azul-6: #d3f5f7;
  /* Amarelos */
  --log-amarelo: #c99d02;
  --log-amarelo-2: #fcc502;
  --log-amarelo-3: #fcd035;
  --log-amarelo-4: #fddc67;
  --log-amarelo-5: #fde79a;
  --log-amarelo-6: #fef3cc;
  /* Magentas */
  --log-magenta: #c00bae;
  --log-magenta-2: #f00ed9;
  --log-magenta-3: #f33e1e1;
  --log-magenta-4: #f66ee8;
  --log-magenta-5: #f99ef0;
  --log-magenta-6: #ffccf7;
  /* Vermelhos */
  --log-vermelho: #c70404;
  --log-vermelho-2: #f90505;
  --log-vermelho-3: #fa3737;
  --log-vermelho-4: #fb6969;
  --log-vermelho-5: #fc9b9b;
  --log-vermelho-6: #fdcdcd;
  /* Cinzas */
  --log-cinza-escuro: #0b0d19;
  --log-cinza-1: #34353f;
  --log-cinza-2: #5f616a;
  --log-cinza-3: #8e8f98;
  --log-cinza-4: #c0c1c9;
  --log-cinza-5: #f5f6fc;
  }

/* =====================
   BOTÕES (UNIFICADO)
   ===================== */
.btn {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none !important;
}

/* Botão primário */
.btn-primary {
  background: #FE8F1C;
  color: #fff;
  margin-bottom: 15px;
}

.btn-primary:hover:not(:disabled) {
  background: #fd8101;
  box-shadow: 0 10px 25px rgba(254, 143, 28, 0.2);
  color: #fff;
  transform: translateY(-2px);
}

/* Botão secundário */
.btn-secondary {
  background: #f5f7fa;
  color: #6613D0;
  border: 2px solid #6613D0;
  margin-bottom: 15px;
}

.btn-secondary:hover:not(:disabled) {
  background: #ece9f6;
  color: #333;
  border-color: #6613D0;
}

/* Botão Google */
.btn-google {
  background: white;
  color: #2d3748;
  border: 2px solid #e2e8f0;
  text-decoration: none;
  margin-bottom: 24px;
}

.btn-google:hover {
  background: #f7fafc;
  border-color: #cbd5e0;
  text-decoration: none;
}

/* Botão com loading */
.btn.loading {
  pointer-events: none;
  opacity: 0.8;
  position: relative;
}

.btn.loading::after {
  content: '';
  border: 3px solid #fff;
  border-top: 3px solid #6613D0;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  animation: spin 1s linear infinite;
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
}

/* Botão de header (portal) */
.header-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  position: relative;
  transition: background-color 0.2s;
}

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

/* =====================
   COMPONENTES GLOBAIS
   ===================== */

/* Utilitários compartilhados */
.purple { color: #6613D0 !important; font-weight: bold; }
.orange { color: #FE8F1C !important; font-weight: 500; }
.loading-spinner { display: flex; align-items: center; justify-content: center; min-height: 120px; font-size: 1.1em; color: #6613D0; font-weight: 500; }

.divider {
  text-align: center;
  margin: 25px 0;
  position: relative;
}

.divider span {
  background: none;
  padding: 0 15px;
  color: #718096;
  font-size: 14px;
  position: relative;
  z-index: 1;
}

.divider span::before,
.divider span::after {
  content: '';
  display: inline-block;
  width: 40px;
  height: 1px;
  background: #e2e8f0;
  vertical-align: middle;
  margin: 0 8px;
}

.divider span::before {
  margin-left: 0;
}

.divider span::after {
  margin-right: 0;
}

.error-message {
  background: #fed7d7;
  color: #c53030;
  border: 1px solid #feb2b2;
  border-radius: 8px;
  padding: 12px 18px;
  margin-bottom: 16px;
  font-size: 15px;
  font-weight: 500;
}

.success-message {
  background: #c6f6d5;
  color: #22543d;
  border: 1px solid #68d391;
  border-radius: 8px;
  padding: 12px 18px;
  margin-bottom: 16px;
  font-size: 15px;
  font-weight: 500;
}

.notification {
  position: fixed;
  top: 24px;
  right: 24px;
  min-width: 280px;
  max-width: 350px;
  z-index: 9999;
  padding: 16px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  display: flex;
  align-items: center;
  gap: 12px;
}

.notification-success {
  background: #c6f6d5;
  color: #22543d;
  border: 1px solid #68d391;
}

.notification-error {
  background: #fed7d7;
  color: #c53030;
  border: 1px solid #feb2b2;
}

/* =====================
   ANIMAÇÕES GLOBAIS
   ===================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.fa-spin {
  animation: spin 1s linear infinite;
}

/* Loading states */
.btn.loading {
  position: relative;
  color: transparent;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* =====================
   CONTAINER PRINCIPAL DO PORTAL
   ===================== */
.portal-container {
  display: grid;
  grid-template-areas: 
    "header header"
    "sidebar main"
    "footer footer";
  grid-template-rows: 60px 1fr 50px;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  width: 100vw;
  transition: grid-template-columns 0.3s ease;
}

.portal-container.sidebar-collapsed {
  grid-template-columns: 60px 1fr;
}

/* =====================
   HEADER FIXO
   ===================== */
.portal-header {
  grid-area: header;
  background: linear-gradient(135deg, #6613D0 0%, #8B5CF6 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  box-shadow: 0 2px 10px rgba(102, 19, 208, 0.3);
  z-index: 1000;
  position: relative;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: background-color 0.2s;
}

.menu-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.header-logo-link {
  display: inline-block;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.header-logo-link:hover {
  opacity: 0.8;
}

.header-logo {
  height: 40px;
  width: auto;
}

.header-title h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.header-title span {
  font-size: 12px;
  opacity: 0.9;
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
}

.user-role {
  font-size: 11px;
  opacity: 0.8;
}

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

.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #FE8F1C;
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  object-fit: cover;
}

/* =====================
   SIDEBAR (MENU LATERAL)
   ===================== */
.portal-sidebar {
  grid-area: sidebar;
  background: white;
  border-right: 1px solid #e1e5e9;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.3s ease;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-nav {
  padding: 20px 0;
}

.nav-menu {
  list-style: none;
}

.nav-item {
  margin-bottom: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  color: #64748b;
  text-decoration: none;
  transition: all 0.2s;
  border-radius: 0 8px 8px 0;
  margin-right: 12px;
  font-weight: 500;
}

.nav-link:hover {
  background: #f1f5f9;
  color: #6613D0;
}

.nav-item.active .nav-link {
  background: linear-gradient(135deg, #6613D0 0%, #8B5CF6 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(102, 19, 208, 0.3);
}

.nav-link i {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

.nav-label {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar colapsado */
.portal-container.sidebar-collapsed .nav-label {
  display: none;
}

.portal-container.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 12px;
  margin-right: 8px;
}

/* =====================
   CONTEÚDO PRINCIPAL
   ===================== */
.portal-main {
  grid-area: main;
  background: #f5f7fa;
  overflow: hidden;
  position: relative;
}

.content-wrapper {
  height: 100%;
  width: 100%;
  overflow: auto;
  padding: 24px;
}

/* =====================
   RODAPÉ (UNIFICADO)
   ===================== */
.footer-text {
  text-align: center;
  color: #718096;
  font-size: 14px;
  margin-top: 20px;
  margin-bottom: 10px;
}

.footer-text a {
  color: #6613D0;
  text-decoration: underline;
  transition: color 0.2s;
}

.footer-text a:hover {
  color: #6613D0;
  text-decoration: none;
}

.footer-text i {
  margin-right: 4px;
  color: #6613D0;
}

.footer-text strong {
  color: #2d3748;
  font-weight: 600;
}

/* =====================
   JANELAS FLUTUANTES (CONTEÚDO DAS PÁGINAS)
   ===================== */
.page-window {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.window-header {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  padding: 16px 24px 10px 24px;
  border-bottom: 1px solid #e1e5e9;
  flex-shrink: 0;
}

.window-title {
  font-size: 1.35em;
  font-weight: 700;
  margin-bottom: 2px;
}

.window-subtitle {
  font-size: 1em;
  color: #888;
  margin-bottom: 0;
}

.window-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: #6613D0 #f1f5f9;
}

.window-content::-webkit-scrollbar {
  width: 10px;
  background: #f1f5f9;
  border-radius: 8px;
}

.window-content::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #6613D0 0%, #8B5CF6 100%);
  border-radius: 8px;
}

.window-content::-webkit-scrollbar-thumb:hover {
  background: #6613D0;
}

/* =====================
   RODAPÉ DO PORTAL (DUAS COLUNAS)
   ===================== */
.portal-footer {
  grid-area: footer;
  background: #fff;
  border-top: 1px solid #e1e5e9;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  min-height: 50px;
  box-sizing: border-box;
  font-size: 13px;
  color: #64748b;
  padding: 0 24px;
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
}

.version-info {
  background: #f1f5f9;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 500;
  color: #6613D0;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #10b981;
  font-size: 13px;
}

.status-indicator i {
  font-size: 8px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* =====================
   RESPONSIVIDADE GLOBAL
   ===================== */
@media (max-width: 1024px) {
  .portal-container {
    grid-template-columns: 60px 1fr;
}

  .nav-label {
    display: none;
}

  .nav-link {
  justify-content: center;
    padding: 12px;
    margin-right: 8px;
}

  .header-title {
    display: none;
  }
}

@media (max-width: 768px) {
  .portal-container {
    grid-template-areas: 
      "header"
      "main"
      "footer";
    grid-template-rows: 60px 1fr 50px;
    grid-template-columns: 1fr;
}

  .portal-sidebar {
    position: fixed;
    top: 60px;
    left: -220px;
    width: 220px;
    height: calc(100vh - 110px);
    z-index: 999;
    transition: left 0.3s ease;
}

  .portal-container.sidebar-open .portal-sidebar {
    left: 0;
}

  .content-wrapper {
    padding: 16px;
  }
  
  .window-content {
    padding: 12px;
}

  .footer-content {
  flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }
  
  .portal-footer {
    height: auto;
    min-height: 60px;
    padding: 8px 12px;
    font-size: 12px;
}
}

@media (max-width: 480px) {
  .portal-header {
    padding: 0 16px;
  }
  
  .header-right {
    gap: 12px;
  }
  
  .user-info {
    display: none;
  }
  
  .content-wrapper {
    padding: 12px;
  }
}

/* =====================
   FONTES
   ===================== */
@font-face {
  font-family: 'Poppins';
  src: url('/static/fonts/Poppins-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: 'Poppins';
  src: url('/static/fonts/Poppins-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
}

@font-face {
  font-family: 'Poppins';
  src: url('/static/fonts/Poppins-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
}

@font-face {
  font-family: 'Poppins';
  src: url('/static/fonts/Poppins-Italic.ttf') format('truetype');
  font-weight: 400;
  font-style: italic;
}

/* =====================
   CARDS E GRIDS BASE (COMPARTILHADO)
   ===================== */

.insight-card {
  background: white; border: 1px solid #e1e5e9; border-radius: 12px; overflow: hidden;
  transition: all 0.2s; min-height: 320px; display: flex; flex-direction: column; justify-content: flex-start;
}
.insight-card:hover { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); transform: translateY(-2px); }
.insight-card.full-width { grid-column: 1 / -1; min-height: 340px; }

.card-header {
  background: #f8fafc; padding: 16px 20px; border-bottom: 1px solid #e1e5e9;
  display: flex; align-items: center; gap: 0; background: none; border: none; box-shadow: none;
}
.card-title h3 { font-size: 16px; font-weight: 600; color: #1e293b; margin: 0 0 2px 0; }
.card-title p { font-size: 12px; color: #64748b; margin: 0; }

.card-content {
  flex: 1 1 auto; display: flex; flex-direction: column; justify-content: flex-start;
  min-height: 0; padding: 20px; height: 100%;
}

.chart-container {
  height: 180px; min-height: 120px; max-height: 220px; margin-bottom: 16px;
  position: relative; overflow: visible !important;
}

.data-list {
  max-height: 200px; overflow-y: auto; margin-bottom: 16px; overflow: visible !important;
  max-height: none !important; flex-grow: 0;
}

.chart-container + .data-list { margin-bottom: auto; }
.data-list:empty { margin-bottom: auto; }

.card-content > *:not(.insight-ia):not(#objeções-ia):not(#demanda-ia):not(#competidores-ia):not(#deals-ia):not(#clusters-ia):last-of-type { margin-bottom: auto; }

.data-item {
  padding: 12px; margin-bottom: 8px; background: #f8fafc; border-radius: 8px;
  border-left: 4px solid #6613D0; font-size: 14px;
}
.data-item-label { font-weight: 600; color: #1e293b; margin-bottom: 4px; }
.data-item-value {
  font-weight: 700; color: #6613D0; background: #ede7fa; padding: 4px 8px;
  border-radius: 6px; font-size: 12px; display: inline-block; margin-top: 4px;
}

.performance-card {
  background: #fff; border-radius: 16px; box-shadow: 0 4px 24px rgba(102, 19, 208, 0.08);
  padding: 32px 28px 32px 28px; margin-bottom: 32px; display: flex; flex-direction: column;
  gap: 32px; width: 100%; max-width: 100%;
}
.performance-header { margin-bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }
.performance-header h2 { font-size: 2em; font-weight: 700; color: #1e293b; margin-bottom: 6px; }
.performance-header p { font-size: 1.1em; color: #64748b; margin: 0; }
.performance-header-left { flex: 1 1 300px; min-width: 220px; }
.performance-metrics { display: flex; gap: 28px; align-items: flex-end; flex-wrap: wrap; }

.metric { display: flex; flex-direction: column; align-items: center; min-width: 80px; }
.metric-emoji { font-size: 1.7em; margin-bottom: 2px; line-height: 1; }
.metric-value { color: #FE8F1C; font-size: 1.3em; font-weight: 700; margin-bottom: 2px; }
.metric-label { color: #FE8F1C; font-size: 0.98em; font-weight: 500; opacity: 0.85; }

/* Modal de aviso de inatividade */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal-content {
  background: white;
  border-radius: 8px;
  padding: 0;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

.modal-header {
  background: linear-gradient(135deg, #ff6b35, #f7931e);
  color: white;
  padding: 20px;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
  color: #333;
}

.modal-body p {
  margin: 0 0 10px 0;
  line-height: 1.5;
}

.modal-footer {
  padding: 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid #eee;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsividade para o modal */
@media (max-width: 480px) {
  .modal-content {
    width: 95%;
    margin: 10px;
  }
  
  .modal-footer {
    flex-direction: column;
  }
  
  .modal-footer button {
    width: 100%;
  }
}

/* Barra de progresso da contagem regressiva */
.countdown-bar {
  width: 100%;
  height: 8px;
  background-color: #f0f0f0;
  border-radius: 4px;
  margin: 15px 0;
  overflow: hidden;
}

.countdown-progress {
  height: 100%;
  background: linear-gradient(90deg, #ff6b35, #f7931e);
  border-radius: 4px;
  transition: width 1s linear;
  width: 0%;
}

/* Animação de pulso para o contador */
#countdown {
  font-weight: bold;
  color: #ff6b35;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}