/* 
  📊 CSV Importer Styles - Design Aprimorado
  Baseado no padrão visual dos modais existentes (especialmente agrupamento)
  Cores e estilos consistentes com o sistema
*/

:host {
  // ✨ Cores do sistema (seguindo padrão dos modais + tema adaptativo)
  --primary-color: #007bff;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --secondary-color: #6c757d;
  --dark-color: #495057;
  --light-color: #f8f9fa;
  --white: #ffffff;
  --border-color: #dee2e6;
  --accent-color: #ffc107; // Amarelo como no modal de agrupamento
  
  // ✨ Cores adaptativas para tema escuro
  --surface-color: var(--white);
  --text-primary: var(--dark-color);
  --text-secondary: var(--secondary-color);
  --background-overlay: rgba(248, 249, 250, 0.95);
  
  // ✨ Sombras e bordas
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.15);
  --border-radius: 8px;
  --border-radius-lg: 12px;
  
  // ✨ Transições
  --transition: all 0.2s ease;
  --transition-fast: all 0.15s ease;
}

// ✨ Tema Escuro - Variáveis adaptativas
:host-context(.dark-theme) {
  --surface-color: #2d3748;
  --text-primary: #ffffff;
  --text-secondary: #a0aec0;
  --light-color: #4a5568;
  --border-color: #4a5568;
  --background-overlay: rgba(45, 55, 72, 0.95);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
  
  // ✅ Ajuste do ícone para tema escuro
  .enhanced-modal-header .header-content .header-icon {
    background: rgba(0, 0, 0, 0.25); // Fundo mais escuro no tema escuro
    color: #ffffff; // ✅ Ícone branco no tema escuro também
    
    // ✅ Força cor branca para todos os ícones FontAwesome no tema escuro
    i, .fas, .far, .fab, .fal, .fad {
      color: #ffffff !important;
    }
  }
}

// ========================================
// 🪟 MODAL HEADER APRIMORADO
// ========================================

.enhanced-modal-header {
  position: relative;
  background: var(--accent-color);
  border-radius: 0;
  overflow: hidden;
  
  .header-accent {
    display: none; // ✅ Remove barra dupla
  }
  
  .header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    
    .header-left {
      display: flex;
      align-items: center;
      gap: 1rem;
    }
    
    .header-icon {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 40px;
      height: 40px;
      background: rgba(0, 0, 0, 0.15); // ✅ Fundo semi-transparente escuro
      color: #ffffff; // ✅ Ícone branco
      border-radius: 50%;
      font-size: 1.25rem;
      box-shadow: var(--shadow-sm);
      
      // ✅ Força cor branca para todos os ícones FontAwesome
      i, .fas, .far, .fab, .fal, .fad {
        color: #ffffff !important;
      }
    }
    
    .header-text {
      .modal-title {
        margin: 0 0 0.25rem 0;
        font-size: 1.25rem;
        font-weight: 600;
        color: var(--dark-color);
      }
      
      .modal-subtitle {
        margin: 0;
        font-size: 0.875rem;
        color: var(--dark-color);
        opacity: 0.8;
      }
    }
    
    .enhanced-close-button {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 32px;
      height: 32px;
      background: none;
      border: none;
      color: var(--dark-color);
      border-radius: 50%;
      cursor: pointer;
      transition: var(--transition);
      font-size: 1.1rem;
      
      &:hover {
        background: rgba(0, 0, 0, 0.1);
        color: var(--dark-color);
      }
    }
  }
}

// ========================================
// 📋 CONTAINER PRINCIPAL
// ========================================

.enhanced-csv-container {
  padding: 0; // ✅ Remove padding para eliminar bordas laterais
  min-height: 400px;
  background: transparent; // ✅ Sem fundo branco
  
  &.modal-mode {
    max-height: 70vh;
    overflow-y: auto;
    background: transparent;
    padding: 0; // ✅ Zero padding no modal
  }
}

// ========================================
// 🏷️ SECTION HEADERS (PADRÃO CONSISTENTE)
// ========================================

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--light-color);
  
  i {
    color: var(--accent-color);
    font-size: 1.1rem;
  }
  
  span {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
  }
}

// ========================================
// 📁 UPLOAD SECTION
// ========================================

.upload-section {
  margin-bottom: 2rem;
  padding: 2rem; // ✅ Padding específico para esta seção
  background: var(--surface-color); // ✅ Fundo adaptativo ao tema
}

.enhanced-drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius-lg);
  background: var(--light-color);
  cursor: pointer;
  transition: var(--transition);
  
  &:hover {
    border-color: var(--primary-color);
    background: rgba(0, 123, 255, 0.05);
  }
  
  &.drag-over {
    border-color: var(--success-color);
    background: rgba(40, 167, 69, 0.08);
    transform: scale(1.01);
    box-shadow: var(--shadow-md);
  }
  
  &.has-file {
    border-color: var(--primary-color);
    background: var(--white);
    padding: 1.5rem;
  }
  
  &.processing {
    opacity: 0.7;
    pointer-events: none;
  }
}

// Estado: Nenhum arquivo
.drop-zone-content {
  padding: 3rem 2rem;
  text-align: center;
  
  .upload-icon {
    font-size: 3.5rem;
    color: var(--accent-color);
    margin-bottom: 1.5rem;
  }
  
  .upload-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
  }
  
  .upload-description {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    
    strong {
      color: var(--primary-color);
    }
  }
  
  .upload-specs {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1rem;
    
         .spec-item {
       display: flex;
       align-items: center;
       gap: 0.5rem;
       font-size: 0.875rem;
       color: var(--text-secondary);
       
       i {
         color: var(--accent-color);
       }
     }
  }
}

// Estado: Arquivo selecionado
.selected-file {
  .file-card {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    
    .file-header {
      display: flex;
      align-items: center;
      padding: 1.5rem;
      gap: 1rem;
      
      .file-icon-large {
        font-size: 2.5rem;
        color: var(--success-color);
      }
      
      .file-info {
        flex: 1;
        
        .file-name {
          font-size: 1.1rem;
          font-weight: 600;
          color: var(--text-primary);
          margin-bottom: 0.5rem;
        }
        
        .file-details {
          font-size: 0.875rem;
          color: var(--text-secondary);
          margin: 0;
        }
        
        .status-badge {
          display: inline-flex;
          align-items: center;
          gap: 0.25rem;
          padding: 0.25rem 0.5rem;
          border-radius: 12px;
          font-size: 0.75rem;
          font-weight: 500;
          
          &.pending { background: rgba(255, 193, 7, 0.1); color: var(--warning-color); }
          &.validating { background: rgba(0, 123, 255, 0.1); color: var(--primary-color); }
          &.valid { background: rgba(40, 167, 69, 0.1); color: var(--success-color); }
          &.invalid { background: rgba(220, 53, 69, 0.1); color: var(--danger-color); }
        }
      }
      
      .remove-file-btn {
        width: 32px;
        height: 32px;
        border: none;
        background: var(--light-color);
        color: var(--secondary-color);
        border-radius: 50%;
        cursor: pointer;
        transition: var(--transition);
        
        &:hover {
          background: var(--danger-color);
          color: var(--white);
        }
      }
    }
  }
}

// ========================================
// 📊 VALIDATION SECTION
// ========================================

.validation-section {
  margin: 0 2rem 2rem 2rem; // ✅ Margens direita e esquerda para melhor visualização
}

.validation-card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.validation-status {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.5rem;
  
  &.valid {
    background: rgba(40, 167, 69, 0.05);
    border-left: 4px solid var(--success-color);
  }
  
  &.invalid {
    background: rgba(255, 193, 7, 0.05);
    border-left: 4px solid var(--warning-color);
  }
  
  .status-icon {
    font-size: 1.5rem;
    
    .fa-check-circle { color: var(--success-color); }
    .fa-exclamation-triangle { color: var(--warning-color); }
  }
  
  .status-text {
    h4 {
      font-size: 1.1rem;
      font-weight: 600;
      color: var(--text-primary);
      margin-bottom: 0.5rem;
    }
    
    p {
      font-size: 0.9rem;
      color: var(--text-secondary);
      margin: 0;
    }
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  padding: 1.5rem;
  background: var(--light-color);
  
      .stat-card {
      text-align: center;
      padding: 1rem;
      background: var(--surface-color);
      border-radius: var(--border-radius);
      box-shadow: var(--shadow-sm);
      
      .stat-number {
        font-size: 1.75rem;
        font-weight: 700;
        margin-bottom: 0.25rem;
      }
      
      .stat-label {
        font-size: 0.875rem;
        color: var(--text-secondary);
        font-weight: 500;
      }
    
    &.total .stat-number { color: var(--primary-color); }
    &.valid .stat-number { color: var(--success-color); }
    &.invalid .stat-number { color: var(--danger-color); }
  }
}

.issues-container {
  padding: 1.5rem;
  
  .issues-section {
    margin-bottom: 1.5rem;
    
    &:last-child {
      margin-bottom: 0;
    }
    
    h5 {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      font-size: 1rem;
      font-weight: 600;
      margin-bottom: 1rem;
    }
    
    &.errors {
      h5 { color: var(--danger-color); }
      .issue-item i { color: var(--danger-color); }
    }
    
    &.warnings {
      h5 { color: var(--warning-color); }
      .issue-item i { color: var(--warning-color); }
    }
    
    .issues-list {
      list-style: none;
      padding: 0;
      margin: 0;
      
      .issue-item {
        display: flex;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.75rem;
        background: var(--light-color);
        border-radius: var(--border-radius);
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
        
        &:last-child {
          margin-bottom: 0;
        }
      }
    }
  }
}

.data-preview-section {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  
  h5 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    
    i {
      color: var(--primary-color);
    }
  }
  
  .preview-container {
    background: var(--light-color);
    border-radius: var(--border-radius);
    overflow-x: auto; // ✅ Scroll horizontal habilitado
    overflow-y: hidden;
    margin-bottom: 1rem;
    
    // ✅ Customização da barra de scroll
    &::-webkit-scrollbar {
      height: 8px;
    }
    
    &::-webkit-scrollbar-track {
      background: var(--light-color);
      border-radius: 4px;
    }
    
    &::-webkit-scrollbar-thumb {
      background: var(--border-color);
      border-radius: 4px;
      
      &:hover {
        background: var(--secondary-color);
      }
    }
    
    .data-table {
      width: 100%;
      min-width: max-content; // ✅ Permite tabela expandir além do container
      font-size: 0.875rem;
      white-space: nowrap; // ✅ Evita quebra de linha nas células
      
      th, td {
        padding: 0.75rem;
        text-align: left;
        border-bottom: 1px solid var(--border-color);
        white-space: nowrap; // ✅ Mantém conteúdo em uma linha
        min-width: 120px; // ✅ Largura mínima para colunas
      }
      
      th {
        background: var(--surface-color);
        font-weight: 600;
        color: var(--text-primary);
        position: sticky; // ✅ Headers fixos durante scroll
        top: 0;
        z-index: 10;
      }
      
      td {
        background: var(--surface-color);
        color: var(--text-secondary);
        max-width: 200px; // ✅ Largura máxima para evitar células muito largas
        overflow: hidden;
        text-overflow: ellipsis; // ✅ Reticências para texto longo
      }
    }
  }
  
  .preview-note {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
  }
  
  // ✅ Indicador de scroll horizontal
  .scroll-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    opacity: 0.7;
    
    i {
      font-size: 0.875rem;
    }
  }
}

// ========================================
// 🎮 ACTIONS SECTION
// ========================================

.actions-section {
  margin-bottom: 2rem;
  padding: 0 2rem; // ✅ Alinha "Ações Disponíveis" com "Selecionar Arquivo"
}

.enhanced-actions {
  display: flex;
  justify-content: center; // ✅ Centralizar botões
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 0;
  
  .action-btn {
    display: flex;
    align-items: center;
    justify-content: center; // ✅ Centralizar conteúdo do botão
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    min-width: 160px; // ✅ Largura mínima para alinhamento
    
    &:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }
    
    &.primary {
      background: var(--primary-color);
      color: var(--white);
      &:hover:not(:disabled) { background: #0056b3; }
    }
    
    &.success {
      background: var(--success-color);
      color: var(--white);
      &:hover:not(:disabled) { background: #218838; }
    }
    
    &.warning {
      background: var(--warning-color);
      color: var(--dark-color);
      &:hover:not(:disabled) { background: #e0a800; }
    }
    
    &.secondary {
      background: var(--secondary-color);
      color: var(--white);
      &:hover:not(:disabled) { background: #545b62; }
    }
  }
}

// ========================================
// 📊 PROCESSING INDICATOR
// ========================================

.enhanced-processing {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  
  .processing-content {
    text-align: center;
    
    .spinner-container {
      margin-bottom: 1.5rem;
      
      .processing-spinner {
        width: 48px;
        height: 48px;
        border: 4px solid var(--light-color);
        border-top: 4px solid var(--accent-color);
        border-radius: 50%;
        animation: spin 1s linear infinite;
      }
    }
    
    h4 {
      font-size: 1.1rem;
      font-weight: 600;
      color: var(--text-primary);
      margin-bottom: 0.5rem;
    }
    
    p {
      font-size: 0.9rem;
      color: var(--text-secondary);
      margin: 0;
    }
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

// ========================================
// 🪟 MODAL FOOTER APRIMORADO
// ========================================

.enhanced-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  background: var(--light-color);
  border-top: 1px solid var(--border-color);
  border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
  
  .footer-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    
    i {
      color: var(--primary-color);
    }
  }
  
  .footer-actions {
    display: flex;
    gap: 1rem;
    
    .footer-btn {
      padding: 0.75rem 1.5rem;
      border: none;
      border-radius: var(--border-radius);
      font-size: 0.9rem;
      font-weight: 500;
      cursor: pointer;
      transition: var(--transition);
      
      &.secondary {
        background: var(--secondary-color);
        color: var(--white);
        &:hover { background: #545b62; }
      }
      
      &.primary {
        background: var(--accent-color);
        color: var(--dark-color);
        display: flex;
        align-items: center;
        gap: 0.5rem;
        &:hover { background: #e0a800; }
      }
      
      &:disabled {
        opacity: 0.6;
        cursor: not-allowed;
      }
    }
  }
}

// ========================================
// 📱 RESPONSIVIDADE
// ========================================

@media (max-width: 768px) {
  .enhanced-csv-container {
    padding: 1rem;
    
    &.modal-mode {
      max-height: 85vh;
    }
  }
  
  .enhanced-modal-header .header-content {
    padding: 1rem;
  }
  
  .enhanced-modal-footer {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    
    .footer-info {
      order: 2;
    }
    
    .footer-actions {
      order: 1;
      width: 100%;
      
      .footer-btn {
        flex: 1;
      }
    }
  }
  
  .enhanced-actions {
    flex-direction: column;
    align-items: stretch; // ✅ Esticar botões em mobile
    
    .action-btn {
      justify-content: center;
      width: 100%; // ✅ Largura total em mobile
      min-width: auto; // ✅ Remove largura mínima em mobile
    }
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .upload-specs {
    flex-direction: column;
    gap: 1rem !important;
  }
} 