/* ============================================================
   FINANCEL — RELATÓRIOS (MOBILE-FIRST)
   Redesign completo para clareza em qualquer tela
   ============================================================ */

/* ============================================================
   1. RESET E BASE MOBILE-FIRST
   ============================================================ */

/* Filtros: colapsáveis no mobile */
.relatorios-filtros {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.15);
  margin-bottom: 1.5rem;
}

.relatorios-filtros-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.5rem 0;
}

.relatorios-filtros-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.relatorios-filtros-toggle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.15);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: transform 0.2s ease;
}

.relatorios-filtros.is-collapsed .relatorios-filtros-toggle {
  transform: rotate(180deg);
}

.relatorios-filtros-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}

.relatorios-filtros.is-collapsed .relatorios-filtros-content {
  max-height: 0;
  opacity: 0;
  padding: 0;
}

/* Inputs de data - mobile-first (full width) */
.relatorios-filtros-row {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.relatorios-filtro-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.relatorios-filtro-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #94a3b8;
}

.relatorios-filtro-group input,
.relatorios-filtro-group select {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.5);
  color: #e2e8f0;
  font-size: 1rem;
  -webkit-appearance: none;
  appearance: none;
}

.relatorios-filtro-group input:focus,
.relatorios-filtro-group select:focus {
  outline: none;
  border-color: rgba(250, 204, 21, 0.5);
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.1);
}

/* Atalhos de período - empilhados no mobile */
.relatorios-filtros-shortcuts {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.relatorios-filtros-shortcuts .btn-secondary {
  width: 100%;
  justify-content: center;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}

/* ============================================================
   2. CARDS DE RELATÓRIOS - MOBILE FIRST
   ============================================================ */

.relatorios-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Grupo de relatórios por intenção */
.relatorios-grupo {
  margin-bottom: 1.5rem;
}

.relatorios-grupo-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0 0.25rem;
}

.relatorios-grupo-emoji {
  font-size: 1.5rem;
}

.relatorios-grupo-titulo {
  font-size: 1.1rem;
  font-weight: 800;
  color: #e2e8f0;
  margin: 0;
}

.relatorios-grupo-subtitulo {
  font-size: 0.85rem;
  color: #94a3b8;
  margin: 0.25rem 0 0 0;
}

/* Card individual - vertical no mobile */
.relatorio-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 16px;
  padding: 1.25rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.relatorio-card:active {
  transform: scale(0.98);
}

.relatorio-card--premium {
  border-color: rgba(250, 204, 21, 0.3);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.8), rgba(250, 204, 21, 0.05));
}

.relatorio-card-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.relatorio-card-icon {
  font-size: 2rem;
  line-height: 1;
}

.relatorio-card-info {
  flex: 1;
}

.relatorio-card-titulo {
  font-size: 1rem;
  font-weight: 700;
  color: #e2e8f0;
  margin: 0;
  line-height: 1.3;
}

.relatorio-card-subtitulo {
  font-size: 0.85rem;
  color: #94a3b8;
  margin: 0.25rem 0 0 0;
  line-height: 1.4;
}

.relatorio-card-descricao {
  font-size: 0.9rem;
  color: #64748b;
  margin: 0.75rem 0;
  line-height: 1.5;
}

.relatorio-card-pergunta {
  font-size: 0.85rem;
  color: #facc15;
  font-style: italic;
  margin: 0.5rem 0 1rem 0;
  padding: 0.5rem 0.75rem;
  background: rgba(250, 204, 21, 0.08);
  border-radius: 8px;
  border-left: 3px solid rgba(250, 204, 21, 0.4);
}

.relatorio-card-acoes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.relatorio-card-acoes .btn-main {
  width: 100%;
  justify-content: center;
  padding: 0.875rem 1rem;
  font-size: 0.95rem;
}

/* ============================================================
   3. MODAL - MOBILE FULL SCREEN
   ============================================================ */

#modalRelatorio.relatorio-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  padding: 0;
  overflow: hidden;
}

#modalRelatorio .relatorio-modal {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  background: #0f172a;
  border-radius: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

#modalRelatorio .relatorio-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  position: sticky;
  top: 0;
  z-index: 10;
}

#modalRelatorio #modalTitulo {
  font-size: 1.1rem;
  font-weight: 700;
  color: #facc15;
  margin: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#modalRelatorio .relatorio-modal-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.15);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #e2e8f0;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* Toolbar do modal - vertical no mobile */
#modalRelatorio .relatorio-modal-toolbar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

#modalRelatorio .relatorio-modal-periodo {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

#modalRelatorio .relatorio-modal-periodo > div {
  width: 100%;
}

#modalRelatorio .relatorio-modal-periodo input[type="date"] {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.5);
  color: #e2e8f0;
  font-size: 1rem;
}

#modalRelatorio .relatorio-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  width: 100%;
}

#modalRelatorio .relatorio-modal-actions > button {
  padding: 0.75rem 0.5rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Conteúdo do modal */
#modalRelatorio #modalConteudo.relatorio-modal-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  background: #0f172a;
  -webkit-overflow-scrolling: touch;
}

/* Hint do modal */
#modalRelatorio #modalRelatorioHint {
  width: 100%;
  color: #94a3b8;
  font-size: 0.85rem;
  margin: 0;
  padding: 0.75rem;
  background: rgba(148, 163, 184, 0.08);
  border-radius: 8px;
  text-align: center;
}

/* ============================================================
   4. HERO/HEADER - COMPACTO NO MOBILE
   ============================================================ */

.relatorios-hero {
  padding: 1rem;
  margin-bottom: 1rem;
}

.relatorios-hero-titulo {
  font-size: 1.5rem;
  font-weight: 800;
  color: #e2e8f0;
  margin: 0 0 0.5rem 0;
}

.relatorios-hero-subtitulo {
  font-size: 0.9rem;
  color: #94a3b8;
  margin: 0;
  line-height: 1.5;
}

.relatorios-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.relatorios-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 20px;
  font-size: 0.8rem;
  color: #94a3b8;
}

/* ============================================================
   5. TABELAS RESPONSIVAS → CARDS NO MOBILE
   ============================================================ */

.relatorio-table-wrapper {
  overflow-x: hidden;
}

/* No mobile, tabelas viram lista de cards */
.relatorio-table-mobile {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.relatorio-table-mobile-item {
  padding: 1rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 12px;
}

.relatorio-table-mobile-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.25rem 0;
}

.relatorio-table-mobile-label {
  font-size: 0.85rem;
  color: #64748b;
}

.relatorio-table-mobile-value {
  font-size: 0.95rem;
  color: #e2e8f0;
  font-weight: 600;
  text-align: right;
}

.relatorio-table-mobile-value--positive {
  color: #22c55e;
}

.relatorio-table-mobile-value--negative {
  color: #ef4444;
}

/* Tabelas desktop escondidas no mobile */
.relatorio-table-desktop {
  display: none;
}

/* ============================================================
   6. KPIs - LEGÍVEIS NO MOBILE
   ============================================================ */

.relatorio-kpis {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.relatorio-kpi {
  padding: 1rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.relatorio-kpi-info {
  flex: 1;
}

.relatorio-kpi-label {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-bottom: 0.25rem;
}

.relatorio-kpi-valor {
  font-size: 1.25rem;
  font-weight: 800;
  color: #e2e8f0;
}

.relatorio-kpi-valor--positive {
  color: #22c55e;
}

.relatorio-kpi-valor--negative {
  color: #ef4444;
}

.relatorio-kpi-icon {
  font-size: 2rem;
  opacity: 0.7;
}

/* ============================================================
   7. BREAKPOINTS TABLET E DESKTOP
   ============================================================ */

/* Tablet (768px+) */
@media (min-width: 768px) {
  .relatorios-filtros-content {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
  }
  
  .relatorios-filtros-row {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .relatorios-filtro-group {
    flex: 1;
    min-width: 180px;
    max-width: 220px;
  }
  
  .relatorios-filtros-shortcuts {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .relatorios-filtros-shortcuts .btn-secondary {
    width: auto;
    flex: 1;
    min-width: 120px;
  }
  
  .relatorios-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }
  
  .relatorios-grupo {
    grid-column: 1 / -1;
  }
  
  .relatorios-grupo .relatorios-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .relatorio-card--premium {
    grid-column: 1 / -1;
  }
  
  .relatorio-card-acoes {
    flex-direction: row;
  }
  
  .relatorio-card-acoes .btn-main {
    width: auto;
    flex: 1;
  }
  
  /* Modal tablet - não full screen */
  #modalRelatorio.relatorio-modal-overlay {
    padding: 2rem;
  }
  
  #modalRelatorio .relatorio-modal {
    max-width: 900px;
    max-height: calc(100dvh - 4rem);
    margin: 0 auto;
    border-radius: 20px;
    height: auto;
  }
  
  #modalRelatorio .relatorio-modal-toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
  }
  
  #modalRelatorio .relatorio-modal-periodo {
    flex-direction: row;
    width: auto;
  }
  
  #modalRelatorio .relatorio-modal-periodo > div {
    width: auto;
    min-width: 160px;
  }
  
  #modalRelatorio .relatorio-modal-actions {
    width: auto;
    grid-template-columns: repeat(3, auto);
  }
  
  #modalRelatorio #modalConteudo.relatorio-modal-content {
    max-height: 60vh;
  }
  
  .relatorio-kpis {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .relatorio-kpi {
    flex: 1;
    min-width: 200px;
  }
  
  /* Tabelas visíveis no tablet+ */
  .relatorio-table-desktop {
    display: block;
  }
  
  .relatorio-table-mobile {
    display: none;
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  .relatorios-filtros {
    padding: 1.5rem;
  }
  
  .relatorios-filtros-row {
    flex-wrap: nowrap;
  }
  
  .relatorios-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }
  
  .relatorios-grupo .relatorios-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .relatorio-card {
    padding: 1.5rem;
  }
  
  .relatorio-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  }
  
  #modalRelatorio .relatorio-modal {
    max-width: 1100px;
  }
  
  .relatorio-kpis {
    flex-wrap: nowrap;
  }
  
  .relatorios-hero {
    padding: 1.5rem 2rem;
  }
  
  .relatorios-hero-titulo {
    font-size: 1.75rem;
  }
}

/* Desktop grande (1280px+) */
@media (min-width: 1280px) {
  #modalRelatorio .relatorio-modal {
    max-width: 1200px;
  }
  
  .relatorios-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================================
   8. UTILITÁRIOS E ESTADOS
   ============================================================ */

/* Loading state */
.relatorio-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
  color: #94a3b8;
}

.relatorio-loading-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  animation: relatorio-pulse 1.5s ease-in-out infinite;
}

@keyframes relatorio-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.95); }
}

/* Empty state */
.relatorio-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: #64748b;
  background: rgba(148, 163, 184, 0.05);
  border: 1px dashed rgba(148, 163, 184, 0.2);
  border-radius: 12px;
}

.relatorio-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

/* Error state */
.relatorio-error {
  padding: 1.5rem;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 12px;
  color: #fecaca;
}

.relatorio-error-titulo {
  font-weight: 700;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Scrollbar customizada */
.relatorio-modal-content::-webkit-scrollbar {
  width: 6px;
}

.relatorio-modal-content::-webkit-scrollbar-track {
  background: rgba(148, 163, 184, 0.1);
  border-radius: 3px;
}

.relatorio-modal-content::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 3px;
}

.relatorio-modal-content::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.5);
}

/* ============================================================
   9. SAFE AREA (iOS)
   ============================================================ */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #modalRelatorio .relatorio-modal-content {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
}

/* ============================================================
   10. DARK MODE / LIGHT MODE ADJUSTMENTS
   ============================================================ */

[data-theme="light"] .relatorios-filtros,
[data-theme="light"] .relatorio-card,
[data-theme="light"] #modalRelatorio .relatorio-modal {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(148, 163, 184, 0.2);
}

[data-theme="light"] .relatorios-filtro-group input,
[data-theme="light"] .relatorios-filtro-group select,
[data-theme="light"] #modalRelatorio .relatorio-modal-periodo input {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(148, 163, 184, 0.3);
  color: #1e293b;
}

[data-theme="light"] .relatorio-card-titulo,
[data-theme="light"] .relatorios-grupo-titulo,
[data-theme="light"] .relatorios-hero-titulo {
  color: #1e293b;
}

[data-theme="light"] .relatorio-card-subtitulo,
[data-theme="light"] .relatorios-grupo-subtitulo,
[data-theme="light"] .relatorios-hero-subtitulo,
[data-theme="light"] .relatorio-kpi-label {
  color: #64748b;
}

[data-theme="light"] #modalRelatorio #modalConteudo.relatorio-modal-content {
  background: #f8fafc;
}

/* ============================================================
   11. ANIMAÇÕES E MICROINTERAÇÕES
   ============================================================ */

/* Hover suave nos cards de relatório */
.dash-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dash-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.25);
}

/* Card premium com brilho especial */
.relatorio-card--premium {
  position: relative;
  overflow: hidden;
}

.relatorio-card--premium::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 40%,
    rgba(250, 204, 21, 0.03) 50%,
    transparent 60%
  );
  animation: shimmer 3s infinite;
  pointer-events: none;
}

@keyframes shimmer {
  0% { transform: translateX(-100%) rotate(0deg); }
  100% { transform: translateX(100%) rotate(0deg); }
}

/* Botão com estado de loading */
.btn-main[disabled],
.btn-secondary[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-main:not([disabled]):active {
  transform: scale(0.97);
}

/* Animação do toggle de filtros */
.relatorios-filtros-toggle {
  transition: transform 0.3s ease, background 0.2s ease;
}

.relatorios-filtros-toggle:hover {
  background: rgba(148, 163, 184, 0.25);
}

/* Animação de entrada dos grupos */
.relatorios-grupo {
  animation: fadeInUp 0.4s ease-out;
  animation-fill-mode: both;
}

.relatorios-grupo:nth-child(1) { animation-delay: 0.05s; }
.relatorios-grupo:nth-child(2) { animation-delay: 0.1s; }
.relatorios-grupo:nth-child(3) { animation-delay: 0.15s; }
.relatorios-grupo:nth-child(4) { animation-delay: 0.2s; }

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pulse suave no badge premium */
.relatorios-hero .relatorios-hero-badges span:first-child {
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.2); }
  50% { box-shadow: 0 0 0 6px rgba(250, 204, 21, 0); }
}

/* ============================================================
   12. ESTADOS VAZIOS E FEEDBACK
   ============================================================ */

.relatorio-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #94a3b8;
}

.relatorio-empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.relatorio-empty-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 0.5rem;
}

.relatorio-empty-text {
  font-size: 0.9rem;
  max-width: 280px;
  margin: 0 auto;
}

/* Skeleton loading */
.relatorio-skeleton {
  background: linear-gradient(90deg, 
    rgba(148, 163, 184, 0.1) 0%, 
    rgba(148, 163, 184, 0.2) 50%, 
    rgba(148, 163, 184, 0.1) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 8px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
