/**
 * MONVAY DESIGN SYSTEM v5.1
 * Padrão Premium — Mercury Bank, Linear, Notion
 *
 * "A interface perfeita é aquela que o usuário não percebe estar usando."
 */

/* ========================================
   VARIÁVEIS CSS
   ======================================== */

:root {
  /* Cores principais */
  --bg: #060D0A;
  --surface: #0F1A14;
  --surface-hover: #152118;
  --border: rgba(201, 168, 76, 0.12);

  --primary: #c9a84c;
  --primary-dim: #a88c3d;

  --white: #f9f6ef;
  --text-dim: #8a9184;
  --gray: #64748b;

  /* Cores de estado */
  --positivo: #27ae60;
  --negativo: #c0392b;
  --atencao: #f39c12;
  --info: #3498db;

  /* Espaçamento (sistema de 8px) */
  --space-xs: 8px;
  --space-sm: 16px;
  --space-md: 24px;
  --space-lg: 32px;
  --space-xl: 48px;

  /* Border radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --radius-xl: 16px;

  /* Sombras */
  --shadow-sm: 0 4px 24px rgba(26, 46, 30, 0.08);
  --shadow-md: 0 8px 32px rgba(26, 46, 30, 0.12);
  --shadow-lg: 0 12px 48px rgba(26, 46, 30, 0.16);

  /* Tipografia */
  --font-title: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

/* ========================================
   CLASSES UTILITÁRIAS
   ======================================== */

/* Botões */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--positivo);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-weight: 600;
  font-size: 0.88rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: #229954;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-weight: 600;
  font-size: 0.88rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  border-color: var(--primary);
  background: var(--surface-hover);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:active {
  transform: scale(0.98);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--negativo);
  border: 1px solid var(--negativo);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-weight: 600;
  font-size: 0.88rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger:hover {
  background: var(--negativo);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}

.btn-danger:active {
  transform: scale(0.98);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-destaque {
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg) 100%);
  border: 1px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.card-alerta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--atencao);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.card-alerta.positivo {
  border-left-color: var(--positivo);
}

.card-alerta.negativo {
  border-left-color: var(--negativo);
}

.card-alerta.info {
  border-left-color: var(--info);
}

/* Inputs */
.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  color: var(--white);
  font-size: 0.88rem;
  font-family: var(--font-body);
  transition: all 0.2s ease;
  width: 100%;
}

.input:focus,
input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.1);
}

.input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--gray);
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}

.pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

.pill.positivo {
  background: rgba(39, 174, 96, 0.15);
  color: var(--positivo);
}

.pill.negativo {
  background: rgba(192, 57, 43, 0.15);
  color: var(--negativo);
}

.pill.atencao {
  background: rgba(243, 156, 18, 0.15);
  color: var(--atencao);
}

.pill.info {
  background: rgba(52, 152, 219, 0.15);
  color: var(--info);
}

/* Valores monetários */
.valor {
  font-family: var(--font-title);
  font-weight: 700;
}

.valor-destaque {
  font-size: 2.5rem;
  line-height: 1;
}

.valor-grande {
  font-size: 1.75rem;
}

.valor-medio {
  font-size: 1.25rem;
}

.valor.positivo {
  color: var(--positivo);
}

.valor.positivo::before {
  content: "↑ ";
}

.valor.negativo {
  color: var(--negativo);
}

.valor.negativo::before {
  content: "↓ ";
}

/* Labels */
.label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray);
}

/* Dividers */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-md) 0;
}

.divider-vertical {
  width: 1px;
  background: var(--border);
  margin: 0 var(--space-sm);
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  color: var(--text-dim);
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--white);
  margin-bottom: var(--space-sm);
}

.empty-state p {
  font-size: 0.88rem;
  line-height: 1.6;
  max-width: 400px;
  margin: 0 auto var(--space-md);
}

/* Loading */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(201, 168, 76, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg,
    var(--surface) 25%,
    var(--surface-hover) 50%,
    var(--surface) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 13, 10, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-md);
}

/* Toast/Notification */
.toast {
  position: fixed;
  bottom: var(--space-md);
  right: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 400px;
  z-index: 2000;
}

.toast.success {
  border-left: 4px solid var(--positivo);
}

.toast.error {
  border-left: 4px solid var(--negativo);
}

.toast.warning {
  border-left: 4px solid var(--atencao);
}

.toast.info {
  border-left: 4px solid var(--info);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Barras de progresso */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-dim), var(--primary));
  border-radius: var(--radius-sm);
  transition: width 0.6s ease;
}

/* Grid responsivo */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-sm);
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* Flex utilities */
.flex {
  display: flex;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

/* Spacing utilities */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

/* Text utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.text-white { color: var(--white); }
.text-dim { color: var(--text-dim); }
.text-gray { color: var(--gray); }
.text-primary { color: var(--primary); }
.text-positivo { color: var(--positivo); }
.text-negativo { color: var(--negativo); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-normal { font-weight: 400; }

/* Animações */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.fade-in {
  animation: fadeIn 0.3s ease;
}

.fade-up {
  animation: fadeUp 0.3s ease;
}

/* Scrollbar customizada */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dim);
}

/* ========================================
   GRÁFICOS
   ======================================== */

/* Seção completa com gráfico + Maven */
.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.chart-section h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--white);
  margin-bottom: var(--space-sm);
}

/* Container de gráfico */
.chart-container {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-sm) 0;
}

/* Skeleton loader para gráficos */
.chart-skeleton {
  width: 100%;
  height: 300px;
  background: linear-gradient(90deg,
    var(--surface) 25%,
    var(--surface-hover) 50%,
    var(--surface) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-lg);
}

.chart-skeleton-donut {
  width: 200px;
  height: 200px;
  margin: 0 auto;
  border-radius: 50%;
  border: 40px solid var(--surface);
  background: transparent;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

/* Estado vazio de gráfico */
.chart-empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.chart-empty-icon {
  font-size: 4rem;
  margin-bottom: var(--space-md);
  opacity: 0.3;
}

.chart-empty-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--white);
  margin-bottom: var(--space-sm);
}

.chart-empty-state p {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: var(--space-md);
}

/* Legendas customizadas */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  justify-content: center;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.81rem;
  color: var(--white);
}

.chart-legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Tooltip customizado */
.chart-tooltip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-md);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 0.88rem;
}

.chart-tooltip-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--primary);
}

.chart-tooltip-value {
  font-family: var(--font-title);
  font-size: 1.125rem;
  font-weight: 700;
}

/* Valor central em gráfico de rosca */
.chart-center-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.chart-center-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.chart-center-number {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1;
}

/* Maven Insight (interpretação do gráfico) */
.maven-insight {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: rgba(201, 168, 76, 0.05);
  border: 1px solid rgba(201, 168, 76, 0.15);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  margin-top: var(--space-md);
  align-items: flex-start;
}

.maven-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--positivo);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.25rem;
}

.maven-texto {
  flex: 1;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--white);
}

.maven-acao {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--positivo);
  border-radius: var(--radius-sm);
  color: var(--positivo);
  font-size: 0.81rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  align-self: flex-start;
}

.maven-acao:hover {
  background: var(--positivo);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.maven-acao:active {
  transform: scale(0.98);
}

/* ========================================
   RESPONSIVIDADE
   ======================================== */

@media (max-width: 768px) {
  :root {
    --space-md: 20px;
    --space-lg: 28px;
    --space-xl: 40px;
  }

  .grid,
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .card,
  .card-destaque,
  .card-alerta {
    padding: 20px;
  }

  .valor-destaque {
    font-size: 2rem;
  }

  .modal-overlay {
    padding: var(--space-sm);
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ========================================
   PRINT
   ======================================== */

@media print {
  .btn-primary,
  .btn-secondary,
  .btn-danger,
  .modal-overlay,
  .toast {
    display: none;
  }

  .card,
  .card-destaque {
    border: 1px solid #000;
    box-shadow: none;
  }
}
