/* ============================================================
   PlayTech Sistemas - Módulo de Relatórios Personalizados
   Estilo e Design System Integrado
   ============================================================ */

/* Container Principal do Construtor */
.rp-container {
  padding: 16px;
  background: var(--bg, #f3f4f6);
  min-height: calc(100vh - 120px);
  font-family: inherit;
  color: var(--text, #111827);
}

/* Header & Barra Superior de Ações */
.rp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.rp-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
}

.rp-header-title svg,
.rp-header-title i {
  color: var(--primary, #1a56db);
}

.rp-header-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted, #64748b);
  margin-top: 2px;
}

/* Grid de Relatórios Salvos */
.rp-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.rp-report-card {
  background: #ffffff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.rp-report-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
  border-color: #cbd5e1;
}

.rp-card-header-bar {
  height: 6px;
  width: 100%;
}

.rp-card-body {
  padding: 16px;
  flex: 1;
}

.rp-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #475569;
  margin-bottom: 8px;
}

.rp-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 6px;
  line-height: 1.3;
}

.rp-card-desc {
  font-size: 0.825rem;
  color: #64748b;
  line-height: 1.4;
  margin-bottom: 12px;
  min-height: 36px;
}

.rp-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.78rem;
  color: #94a3b8;
  border-top: 1px solid #f1f5f9;
  padding-top: 10px;
}

.rp-card-footer {
  padding: 12px 16px;
  background: #f8fafc;
  border-top: 1px solid #edf2f7;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Card especial: "+ Novo Relatório" */
.rp-card-create-new {
  border: 2px dashed #cbd5e1;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  cursor: pointer;
  border-radius: 8px;
  text-align: center;
  padding: 24px;
  transition: all 0.2s ease;
}

.rp-card-create-new:hover {
  border-color: var(--primary, #1a56db);
  background: #f8faff;
  transform: translateY(-2px);
}

.rp-create-icon-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #e0e7ff;
  color: var(--primary, #1a56db);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 12px;
}

/* ============================================================
   WIZARD DE CRIAÇÃO / EDIÇÃO DE RELATÓRIO PERSONALIZADO
   ============================================================ */
.rp-wizard-wrapper {
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  display: flex;
  min-height: 680px;
  overflow: hidden;
}

/* Sidebar de Navegação dos Passos (Esquerda) */
.rp-wizard-sidebar {
  width: 250px;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.rp-wizard-sidebar-header {
  padding: 18px 20px;
  font-weight: 700;
  font-size: 0.95rem;
  color: #1e293b;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rp-step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.15s ease, border-left 0.15s ease;
  position: relative;
  text-decoration: none;
}

.rp-step-item:hover {
  background: #f1f5f9;
}

.rp-step-item.active {
  background: #0f172a;
  color: #ffffff;
}

.rp-step-item.active .rp-step-num-badge {
  background: var(--primary, #1a56db);
  color: #ffffff;
}

.rp-step-item.active .rp-step-title {
  color: #ffffff;
}

.rp-step-item.active .rp-step-sub {
  color: #94a3b8;
}

.rp-step-item.completed:not(.active) .rp-step-num-badge {
  background: #10b981;
  color: #ffffff;
}

.rp-step-num-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.rp-step-content {
  display: flex;
  flex-direction: column;
}

.rp-step-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e293b;
}

.rp-step-sub {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 2px;
}

/* Área de Conteúdo do Passo Ativo (Direita) */
.rp-wizard-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  overflow-y: auto;
}

.rp-wizard-step-body {
  padding: 24px 30px;
  flex: 1;
}

.rp-step-header {
  margin-bottom: 24px;
}

.rp-step-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rp-step-header p {
  font-size: 0.88rem;
  color: #64748b;
  margin-top: 4px;
}

/* Barra Inferior de Navegação (Voltar / Continuar) */
.rp-wizard-footer {
  padding: 16px 30px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ============================================================
   PASSO 1: O QUE VOCÊ QUER VER (CARDS DE ENTIDADE)
   ============================================================ */
.rp-category-section {
  margin-bottom: 24px;
}

.rp-category-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rp-entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.rp-entity-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: all 0.15s ease;
  background: #ffffff;
  position: relative;
}

.rp-entity-card:hover {
  border-color: #94a3b8;
  background: #f8fafc;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
}

.rp-entity-card.selected {
  border-color: var(--primary, #1a56db);
  background: #eff6ff;
  box-shadow: 0 0 0 1px var(--primary, #1a56db);
}

.rp-entity-icon {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.rp-entity-card.selected .rp-entity-icon {
  background: #dbeafe;
  color: var(--primary, #1a56db);
}

.rp-entity-info {
  flex: 1;
  min-width: 0;
}

.rp-entity-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: #0f172a;
}

.rp-entity-desc {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 3px;
  line-height: 1.35;
}

.rp-entity-radio-circle {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  margin-top: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rp-entity-card.selected .rp-entity-radio-circle {
  border-color: var(--primary, #1a56db);
}

.rp-entity-card.selected .rp-entity-radio-circle::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary, #1a56db);
}

/* ============================================================
   PASSO 2: COMBINAR (RELACIONAMENTOS)
   ============================================================ */
.rp-join-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 780px;
}

.rp-join-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px 20px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all 0.15s ease;
}

.rp-join-card:hover {
  border-color: #cbd5e1;
}

.rp-join-card.active {
  border-color: #93c5fd;
  background: #f8fafc;
}

.rp-join-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.rp-join-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1e293b;
}

.rp-join-sub {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 2px;
}

.rp-toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.rp-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.rp-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .2s;
  border-radius: 24px;
}

.rp-toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

.rp-toggle-switch input:checked + .rp-toggle-slider {
  background-color: var(--primary, #1a56db);
}

.rp-toggle-switch input:checked + .rp-toggle-slider:before {
  transform: translateX(20px);
}

.rp-empty-joins-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  color: #64748b;
  font-size: 0.92rem;
  max-width: 600px;
}

/* ============================================================
   PASSO 3: COLUNAS (DISPONÍVEIS E ORDENAÇÃO DRAG-AND-DROP)
   ============================================================ */
.rp-columns-builder {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  min-height: 480px;
}

.rp-col-panel {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rp-col-panel-header {
  padding: 14px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rp-col-panel-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #1e293b;
}

.rp-col-panel-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  background: #e2e8f0;
  padding: 2px 8px;
  border-radius: 12px;
}

.rp-col-panel-search {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
}

.rp-col-panel-search input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.825rem;
  outline: none;
}

.rp-col-panel-body {
  padding: 12px 14px;
  flex: 1;
  overflow-y: auto;
  max-height: 420px;
}

/* Grupos de Colunas Disponíveis */
.rp-col-group-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  margin: 12px 0 6px 4px;
}

.rp-col-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #1e293b;
  transition: background 0.1s ease;
}

.rp-col-checkbox-label:hover {
  background: #f1f5f9;
}

/* Lista de Colunas Ordenáveis (Direita) */
.rp-sortable-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 200px;
}

.rp-sortable-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: grab;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  user-select: none;
}

.rp-sortable-item:active {
  cursor: grabbing;
}

.rp-sortable-item.dragging {
  opacity: 0.5;
  background: #eff6ff;
  border-color: var(--primary, #1a56db);
}

.rp-sortable-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rp-drag-handle {
  color: #94a3b8;
  font-size: 14px;
}

.rp-col-badge-source {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #64748b;
}

.rp-remove-col-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
}

.rp-remove-col-btn:hover {
  background: #fee2e2;
  color: #ef4444;
}

.rp-empty-columns-msg {
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
  font-size: 0.88rem;
}

/* ============================================================
   PASSO 4: AVANÇADO (AGRUPAR, TOTAIS E FILTROS)
   ============================================================ */
.rp-advanced-section {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  max-width: 800px;
}

.rp-advanced-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rp-advanced-desc {
  font-size: 0.825rem;
  color: #64748b;
  margin-bottom: 14px;
}

.rp-totals-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

/* ============================================================
   PASSO 5: REVISAR E SALVAR (PRÉVIA REAL + METADADOS)
   ============================================================ */
.rp-review-form {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 22px;
  margin-bottom: 24px;
}

.rp-form-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 18px;
}

.rp-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rp-form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e293b;
}

.rp-form-input {
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.rp-form-input:focus {
  border-color: var(--primary, #1a56db);
  box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.15);
}

.rp-color-picker-swatches {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

.rp-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s;
}

.rp-color-swatch:hover {
  transform: scale(1.15);
}

.rp-color-swatch.selected {
  border-color: #0f172a;
  box-shadow: 0 0 0 2px #ffffff;
}

.rp-summary-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
}

.rp-summary-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: #334155;
}

.rp-summary-item i,
.rp-summary-item svg {
  color: var(--primary, #1a56db);
  width: 16px;
  height: 16px;
}

/* Área de Prévia com Dados Reais */
.rp-preview-container {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.rp-preview-header {
  padding: 14px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rp-preview-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rp-preview-table-box {
  max-height: 340px;
  overflow: auto;
}

.rp-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
  text-align: left;
}

.rp-preview-table th {
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.rp-preview-table td {
  padding: 9px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  white-space: nowrap;
}

.rp-preview-table tr:hover td {
  background: #f8fafc;
}

/* ============================================================
   TELA DE EXECUÇÃO / VISUALIZAÇÃO DO RELATÓRIO SALVO
   ============================================================ */
.rp-exec-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin-bottom: 16px;
}

.rp-exec-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.rp-exec-totals-cards {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* Barra de Filtro de Período / Data */
.rp-date-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin-bottom: 14px;
}

.rp-date-filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.rp-date-filter-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rp-date-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.825rem;
  color: #64748b;
}

.rp-date-inputs input[type="date"] {
  padding: 5px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 0.825rem;
  color: #1e293b;
  outline: none;
}

.rp-date-quick-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-xs {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 4px;
}

/* Rodapé de Totais na Própria Tabela */
.rp-table-footer td {
  background: #f8fafc !important;
  border-top: 2px solid #cbd5e1 !important;
  border-bottom: 2px solid #cbd5e1 !important;
  padding: 10px 14px !important;
}

.rp-footer-total-cell {
  background: #f1f5f9 !important;
}

/* Responsividade */
@media (max-width: 900px) {
  .rp-wizard-wrapper {
    flex-direction: column;
  }
  .rp-wizard-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
  }
  .rp-columns-builder {
    grid-template-columns: 1fr;
  }
  .rp-form-row {
    grid-template-columns: 1fr;
  }
}
